|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractSet<Long>
com.devexperts.util.AbstractLongSet
com.devexperts.util.LongHashSet
public final class LongHashSet
This class implements the LongSet
interface, backed by a hash table
(actually a LongHashMap
instance). It makes no guarantees as to the
iteration order of the set; in particular, it does not guarantee that the
order will remain constant over time.
Note that this implementation is not synchronized. If multiple
threads access a set concurrently, and at least one of the threads modifies
the set, it must be synchronized externally. This is typically
accomplished by synchronizing on some object that naturally encapsulates
the set. If no such object exists, the set should be "wrapped" using the
Collections.synchronizedSet(java.util.Set
method. This is best done
at creation time, to prevent accidental unsynchronized access to the set.
The iterators returned by this class's iterator method are
fail-fast: if the set is modified at any time after the iterator is
created, in any way except through the iterator's own remove
method, the Iterator throws a ConcurrentModificationException
.
Thus, in the face of concurrent modification, the iterator fails quickly
and cleanly, rather than risking arbitrary, non-deterministic behavior at
an undetermined time in the future.
Constructor Summary | |
---|---|
LongHashSet()
Constructs a new, empty set. |
|
LongHashSet(Collection<? extends Long> c)
Constructs a new set containing all elements from the specified collection. |
|
LongHashSet(int capacity)
Constructs a new set with a specified capacity. |
Method Summary | |
---|---|
boolean |
add(long key)
Ensures that this collection contains the specified element. |
void |
clear()
|
void |
clearAndCompact()
Removes all elements and frees all memory. |
void |
clearAndCompact(int capacity)
Removes all elements and compacts memory usage of this hashtable, but requested capacity is retained. |
Object |
clone()
Returns a shallow copy of this set: the elements themselves are not cloned. |
void |
compact()
Compacts memory usage of this hashtable. |
void |
compact(int capacity)
Compacts memory usage of this hashtable, but requested capacity is retained. |
boolean |
contains(long key)
Returns true if this collection contains the specified element. |
void |
ensureCapacity(int capacity)
Makes sure that no rehashes or memory reallocations will be needed until size() <= capacity . |
boolean |
isEmpty()
|
LongIterator |
longIterator()
Returns an iterator over the elements in this collection. |
boolean |
remove(long key)
Removes a single instance of the specified element from this collection, if it is present. |
int |
size()
|
Methods inherited from class com.devexperts.util.AbstractLongSet |
---|
add, addAll, contains, containsAll, iterator, remove, removeAll, retainAll, toLongArray |
Methods inherited from class java.util.AbstractSet |
---|
equals, hashCode |
Methods inherited from class java.util.AbstractCollection |
---|
toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Set |
---|
equals, hashCode, toArray, toArray |
Constructor Detail |
---|
public LongHashSet()
public LongHashSet(Collection<? extends Long> c)
public LongHashSet(int capacity)
Method Detail |
---|
public LongIterator longIterator()
LongCollection
longIterator
in interface LongCollection
longIterator
in class AbstractLongSet
Collection.iterator()
public int size()
size
in interface Collection<Long>
size
in interface Set<Long>
size
in class AbstractLongSet
public boolean isEmpty()
isEmpty
in interface Collection<Long>
isEmpty
in interface Set<Long>
isEmpty
in class AbstractCollection<Long>
public boolean contains(long key)
LongCollection
contains
in interface LongCollection
contains
in class AbstractLongSet
Collection.contains(Object)
public boolean add(long key)
LongCollection
add
in interface LongCollection
add
in class AbstractLongSet
Collection.add(Object)
public boolean remove(long key)
LongCollection
remove
in interface LongCollection
remove
in class AbstractLongSet
Collection.remove(Object)
public void clear()
clear
in interface Collection<Long>
clear
in interface Set<Long>
clear
in class AbstractLongSet
public Object clone()
clone
in class Object
public void ensureCapacity(int capacity)
size() <= capacity
.
LongHashMap.ensureCapacity(int)
public void compact()
LongHashMap.compact()
public void compact(int capacity)
public void clearAndCompact()
LongHashMap.clearAndCompact()
public void clearAndCompact(int capacity)
LongHashMap.clearAndCompact(int)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |