|
|||||||||
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 negativepublic 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 nullMethod Detail |
---|
public boolean add(long v)
add
in interface LongCollection
add
in interface LongSet
add
in class AbstractLongCollection
v
- the Object to add to this Set
public void clear()
clear
in interface LongCollection
clear
in interface LongSet
clear
in class AbstractLongCollection
LongIterator.remove()
public boolean contains(long v)
contains
in interface LongCollection
contains
in interface LongSet
contains
in class AbstractLongCollection
v
- the long to look for
public boolean isEmpty()
isEmpty
in interface LongCollection
isEmpty
in interface LongSet
isEmpty
in class AbstractLongCollection
size() == 0
.AbstractLongCollection.size()
public LongIterator iterator()
ConcurrentModificationException
if the set is modified externally.
iterator
in interface LongCollection
iterator
in interface LongIterable
iterator
in interface LongSet
iterator
in class AbstractLongCollection
public boolean remove(long v)
remove
in interface LongCollection
remove
in interface LongSet
remove
in class AbstractLongCollection
v
- the long to remove
LongIterator.remove()
public int size()
size
in interface LongCollection
size
in interface LongSet
size
in class AbstractLongCollection
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |