com.compoze.collab.util
Class ArraySet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet
          extended by com.compoze.collab.util.ArraySet
All Implemented Interfaces
Iterable, Collection, Set

public class ArraySet
extends AbstractSet

A Set implementation backed by an ArrayMap. This class does not permit the null element. Note that this class is only appropriate for holding very small sets, as most operations are quadratic time.


Constructor Summary
ArraySet()
          Constructs an ArraySet with the default initial capacity (5).
ArraySet(Collection c)
          Constructs an ArraySet containing the elements of a collection.
ArraySet(int iInitialCapacity)
          Constructs an ArraySet with the specified initial capacity.
 
Method Summary
 boolean add(Object o)
          Adds the specified element to this set if it is not already present.
 void clear()
          Remove all the elements from this set
 boolean contains(Object o)
          Returns true if this set contains the specified element.
 boolean isEmpty()
          Returns true if this set contains no elements.
 Iterator iterator()
          Returns an iterator over the elements in this set.
 boolean remove(Object o)
          Removes the given element from this set if it is present.
 int size()
          Returns the number of elements in this set.
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, containsAll, retainAll, toArray, toArray
 

Constructor Detail

ArraySet

public ArraySet()
Constructs an ArraySet with the default initial capacity (5).


ArraySet

public ArraySet(Collection c)
Constructs an ArraySet containing the elements of a collection.

Parameters
c - the collection whose elements are to be placed into this set.

ArraySet

public ArraySet(int iInitialCapacity)
Constructs an ArraySet with the specified initial capacity.

Parameters
iInitialCapacity - the initial capacity
Method Detail

iterator

public Iterator iterator()
Returns an iterator over the elements in this set. The elements are returned in no particular order.

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface Set
Specified by:
iterator in class AbstractCollection
See Also
Collection.iterator()

size

public int size()
Returns the number of elements in this set.

Specified by:
size in interface Collection
Specified by:
size in interface Set
Specified by:
size in class AbstractCollection
See Also
Collection.size()

isEmpty

public boolean isEmpty()
Returns true if this set contains no elements.

Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface Set
Overrides:
isEmpty in class AbstractCollection
See Also
Collection.isEmpty()

contains

public boolean contains(Object o)
Returns true if this set contains the specified element.

Specified by:
contains in interface Collection
Specified by:
contains in interface Set
Overrides:
contains in class AbstractCollection
Parameters
o - element to be tested for membership
Returns
true if this set contains the specified element.
See Also
Collection.contains(java.lang.Object)

add

public boolean add(Object o)
Adds the specified element to this set if it is not already present.

Specified by:
add in interface Collection
Specified by:
add in interface Set
Overrides:
add in class AbstractCollection
Parameters
o - element to be added to this set
Returns
true if this set did not already contain o
See Also
Collection.add(java.lang.Object)

remove

public boolean remove(Object o)
Removes the given element from this set if it is present.

Specified by:
remove in interface Collection
Specified by:
remove in interface Set
Overrides:
remove in class AbstractCollection
Parameters
o - the element to remove
Returns
true if o was in this set
See Also
Collection.remove(java.lang.Object)

clear

public void clear()
Remove all the elements from this set

Specified by:
clear in interface Collection
Specified by:
clear in interface Set
Overrides:
clear in class AbstractCollection
See Also
Collection.clear()


Copyright © 2006 BEA Systems, Inc. All Rights Reserved