|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectfabric.common.util.AbstractLongCollection
fabric.common.util.AbstractLongSet
fabric.common.util.LongHashSet
public class LongHashSet
This class provides a HashMap-backed implementation of the Set interface.
Most operations are O(1), assuming no hash collisions. In the worst case (where all hashes collide), operations are O(n). Setting the initial capacity too low will force many resizing operations, but setting the initial capacity too high (or loadfactor too low) leads to wasted memory and slower iteration.
HashSet accepts the null key and null values. It is not synchronized,
so if you need multi-threaded access, consider using:
Set s = Collections.synchronizedSet(new HashSet(...));
The iterators are fail-fast, meaning that any structural
modification, except for remove() called on the iterator
itself, cause the iterator to throw a
ConcurrentModificationException rather than exhibit
non-deterministic behavior.
LongCollection,
LongSet,
LongKeyHashMap| Constructor Summary | |
|---|---|
LongHashSet()
Construct a new, empty HashSet whose backing HashMap has the default capacity (11) and loadFacor (0.75). |
|
LongHashSet(int initialCapacity)
Construct a new, empty HashSet whose backing HashMap has the supplied capacity and the default load factor (0.75). |
|
LongHashSet(int initialCapacity,
float loadFactor)
Construct a new, empty HashSet whose backing HashMap has the supplied capacity and load factor. |
|
LongHashSet(LongCollection c)
Construct a new HashSet with the same elements as are in the supplied collection (eliminating any duplicates, of course). |
|
| Method Summary | |
|---|---|
boolean |
add(long v)
Adds the given Object to the set if it is not already in the Set. |
void |
clear()
Empties this Set of all elements; this takes constant time. |
boolean |
contains(long v)
Returns true if the supplied element is in this Set. |
boolean |
isEmpty()
Returns true if this set has no elements in it. |
LongIterator |
iterator()
Returns an Iterator over the elements of this Set, which visits the elements in no particular order. |
boolean |
remove(long v)
Removes the supplied Object from this Set if it is in the Set. |
int |
size()
Returns the number of elements in this Set (its cardinality). |
| Methods inherited from class fabric.common.util.AbstractLongSet |
|---|
equals, hashCode, removeAll |
| Methods inherited from class fabric.common.util.AbstractLongCollection |
|---|
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 fabric.common.util.LongSet |
|---|
addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray |
| Constructor Detail |
|---|
public LongHashSet()
public LongHashSet(int initialCapacity)
initialCapacity - the initial capacity of the backing HashMap
java.lang.IllegalArgumentException - if the capacity is negative
public LongHashSet(int initialCapacity,
float loadFactor)
initialCapacity - the initial capacity of the backing HashMaploadFactor - the load factor of the backing HashMap
java.lang.IllegalArgumentException - if either argument is negative, or
if loadFactor is POSITIVE_INFINITY or NaNpublic LongHashSet(LongCollection c)
c - a collection of initial set elements
java.lang.NullPointerException - if c is null| Method Detail |
|---|
public boolean add(long v)
add in interface LongCollectionadd in interface LongSetadd in class AbstractLongCollectionv - the Object to add to this Set
public void clear()
clear in interface LongCollectionclear in interface LongSetclear in class AbstractLongCollectionLongIterator.remove()public boolean contains(long v)
contains in interface LongCollectioncontains in interface LongSetcontains in class AbstractLongCollectionv - the long to look for
public boolean isEmpty()
isEmpty in interface LongCollectionisEmpty in interface LongSetisEmpty in class AbstractLongCollectionsize() == 0.AbstractLongCollection.size()public LongIterator iterator()
ConcurrentModificationException if the set is modified externally.
iterator in interface LongCollectioniterator in interface LongIterableiterator in interface LongSetiterator in class AbstractLongCollectionpublic boolean remove(long v)
remove in interface LongCollectionremove in interface LongSetremove in class AbstractLongCollectionv - the long to remove
LongIterator.remove()public int size()
size in interface LongCollectionsize in interface LongSetsize in class AbstractLongCollection
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||