T
- The type of object stored in this ListSetpublic class ListSet<T>
extends java.util.AbstractSet<T>
implements java.util.Set<T>
Constructor and Description |
---|
ListSet()
Construct a new, empty ListSet.
|
ListSet(java.util.Collection<T> otherSet)
Construct a new ListSet with the contents of the given Set.
|
ListSet(java.util.Comparator<T> comp)
Construct a new, empty ListSet, which will use the given Comparator to
determine equality for purposes of determining presence in the Set.
|
ListSet(int size)
Construct a new, empty ListSet, initializing the internal List to the
given size.
|
ListSet(int size,
java.util.Comparator<T> comp)
Construct a new, empty ListSet, which will use the given Comparator to
determine equality for purposes of determining presence in the Set, and
initializing the internal List to the given size.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(T element)
Adds the given Object to this set if it was not already part of the Set.
|
void |
clear()
Clears this Set (removes all Objects from the Set).
|
boolean |
contains(java.lang.Object element)
Returns true if the given object is present in this Set.
|
void |
ensureCapacity(int capacity)
Ensures that the list underlying this Set has the given capacity.
|
boolean |
isEmpty()
Returns true if this Set is Empty.
|
java.util.Iterator<T> |
iterator()
Returns an Iterator over the Set.
|
boolean |
remove(java.lang.Object element)
Removes the given Object from this Set.
|
int |
size()
Returns the number of Objects in this Set.
|
void |
trimToSize()
Trims the list underlying this Set to a capacity equal to the number of
elements in the Set.
|
addAll, containsAll, retainAll, toArray, toArray, toString
public ListSet()
public ListSet(int size)
size
- The initial size of the List backing this Setpublic ListSet(java.util.Comparator<T> comp)
comp
- The Comparator this Set will use to determine equalitypublic ListSet(int size, java.util.Comparator<T> comp)
size
- The initial size of the List backing this Setcomp
- The Comparator this Set will use to determine equalitypublic ListSet(java.util.Collection<T> otherSet)
otherSet
- The Set to use as a source of objects for initializing this
ListSetjava.lang.NullPointerException
- if the given Set is nullpublic int size()
public java.util.Iterator<T> iterator()
public boolean add(T element)
public void ensureCapacity(int capacity)
capacity
- The desired capacity of the underlying Listpublic void trimToSize()
public void clear()
public boolean contains(java.lang.Object element)
public boolean isEmpty()
public boolean remove(java.lang.Object element)