edu.emory.mathcs.util.collections.longs
Class LongRadkeHashSet

java.lang.Object
  extended byedu.emory.mathcs.util.collections.longs.AbstractLongCollection
      extended byedu.emory.mathcs.util.collections.longs.AbstractLongSet
          extended byedu.emory.mathcs.util.collections.longs.LongRadkeHashSet
All Implemented Interfaces:
java.lang.Cloneable, LongCollection, LongSet, java.io.Serializable

public class LongRadkeHashSet
extends AbstractLongSet
implements java.lang.Cloneable, java.io.Serializable

Hash set of long numbers. It uses open addressing with quadratic residue search to avoid clustering. No additional memory per entry is needed, there is therefore no memory allocation on add() unless rehashing is required.

Version:
1.0
Author:
Dawid Kurzyniec
See Also:
Serialized Form

Constructor Summary
LongRadkeHashSet()
           
LongRadkeHashSet(int minInitialCapacity)
           
LongRadkeHashSet(int minInitialCapacity, float loadFactor, float resizeTreshold)
           
LongRadkeHashSet(int minInitialCapacity, long min, long max)
           
LongRadkeHashSet(int minInitialCapacity, long min, long max, float loadFactor, float resizeTreshold)
           
LongRadkeHashSet(LongCollection c)
           
LongRadkeHashSet(LongSet m)
           
 
Method Summary
 boolean add(long elem)
          Adds the specified number to this set if it is not already present and if it falls within the domain.
 void clear()
          Removes all of the elements from this set.
 java.lang.Object clone()
           
 boolean contains(long elem)
          Returns true if this set contains the specified number; false otherwise.
 boolean equals(java.lang.Object other)
          Two sets are equal if they consists of the same elements.
 int hashCode()
           
 boolean isEmpty()
          Returns true if this set is empty; false otherwise.
 LongIterator iterator()
          Returns the iterator over numbers contained in this set.
 long max()
          The largest number that can be stored in this set.
 long min()
          The smallest number that can be stored in this set.
 boolean remove(long elem)
          Removes the specified number from this set if it is present.
 boolean removeAll(LongCollection c)
          Removes from this set all of its elements that are contained in the specified collection.
 boolean retainAll(LongCollection c)
          Retains only the elements in this set that are contained in the specified collection.
 int size()
          Returns the number of elements in this set.
 long size64()
          // PREPROC: Long,Int only Returns the number of elements in this set.
 long[] toArray()
          Returns the newly allocated array containing all numbers from this set, in the order returned by its iterator.
 long[] toArray(long[] a)
          Returns an array containing all of the numbers in this set.
 
Methods inherited from class edu.emory.mathcs.util.collections.longs.AbstractLongSet
addAll, addInterval, complementSet, containsInterval, removeInterval, retainInterval
 
Methods inherited from class edu.emory.mathcs.util.collections.longs.AbstractLongCollection
containsAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.emory.mathcs.util.collections.longs.LongSet
containsAll
 

Constructor Detail

LongRadkeHashSet

public LongRadkeHashSet()

LongRadkeHashSet

public LongRadkeHashSet(int minInitialCapacity)

LongRadkeHashSet

public LongRadkeHashSet(int minInitialCapacity,
                        long min,
                        long max)

LongRadkeHashSet

public LongRadkeHashSet(int minInitialCapacity,
                        float loadFactor,
                        float resizeTreshold)

LongRadkeHashSet

public LongRadkeHashSet(int minInitialCapacity,
                        long min,
                        long max,
                        float loadFactor,
                        float resizeTreshold)

LongRadkeHashSet

public LongRadkeHashSet(LongSet m)

LongRadkeHashSet

public LongRadkeHashSet(LongCollection c)
Method Detail

min

public long min()
Description copied from interface: LongSet
The smallest number that can be stored in this set.

Specified by:
min in interface LongSet
Overrides:
min in class AbstractLongSet

max

public long max()
Description copied from interface: LongSet
The largest number that can be stored in this set.

Specified by:
max in interface LongSet
Overrides:
max in class AbstractLongSet

add

public boolean add(long elem)
Description copied from interface: LongSet
Adds the specified number to this set if it is not already present and if it falls within the domain.

Specified by:
add in interface LongSet
Overrides:
add in class AbstractLongCollection

contains

public boolean contains(long elem)
Description copied from interface: LongSet
Returns true if this set contains the specified number; false otherwise.

Specified by:
contains in interface LongSet
Overrides:
contains in class AbstractLongCollection

remove

public boolean remove(long elem)
Description copied from interface: LongSet
Removes the specified number from this set if it is present.

Specified by:
remove in interface LongSet
Overrides:
remove in class AbstractLongCollection

clear

public void clear()
Description copied from interface: LongSet
Removes all of the elements from this set. The set will be empty after this call returns.

Specified by:
clear in interface LongSet
Overrides:
clear in class AbstractLongCollection

isEmpty

public boolean isEmpty()
Description copied from interface: LongSet
Returns true if this set is empty; false otherwise.

Specified by:
isEmpty in interface LongSet
Overrides:
isEmpty in class AbstractLongSet

size64

public long size64()
Description copied from interface: LongSet
// PREPROC: Long,Int only Returns the number of elements in this set. // PREPROC: Long,Int only

Specified by:
size64 in interface LongSet
Overrides:
size64 in class AbstractLongCollection

size

public int size()
Description copied from interface: LongSet
Returns the number of elements in this set. If exceeds Integer.MAX_VALUE, then Integer.MAX_VALUE is returned. // PREPROC: Long,Int only

Specified by:
size in interface LongSet
Overrides:
size in class AbstractLongCollection

iterator

public LongIterator iterator()
Description copied from interface: LongSet
Returns the iterator over numbers contained in this set.

Specified by:
iterator in interface LongSet
Specified by:
iterator in class AbstractLongCollection

equals

public boolean equals(java.lang.Object other)
Description copied from interface: LongSet
Two sets are equal if they consists of the same elements.

Specified by:
equals in interface LongSet
Overrides:
equals in class AbstractLongSet

hashCode

public int hashCode()
Specified by:
hashCode in interface LongSet
Overrides:
hashCode in class AbstractLongSet

clone

public java.lang.Object clone()

removeAll

public boolean removeAll(LongCollection c)
Description copied from interface: LongSet
Removes from this set all of its elements that are contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.

Specified by:
removeAll in interface LongSet
Overrides:
removeAll in class AbstractLongSet

retainAll

public boolean retainAll(LongCollection c)
Description copied from interface: LongSet
Retains only the elements in this set that are contained in the specified collection. In other words, removes from this set all of its elements that are not contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the intersection of the two sets.

Specified by:
retainAll in interface LongSet
Overrides:
retainAll in class AbstractLongSet

toArray

public long[] toArray(long[] a)
Description copied from interface: LongSet
Returns an array containing all of the numbers in this set. If the set fits in the specified array, it is returned therein. Otherwise, a new array is allocated.

If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

Like the LongSet.toArray() method, this method acts as bridge between array-based and collection-based APIs. Further, this method may, under certain circumstances, be used to save allocation costs.

Specified by:
toArray in interface LongSet
Overrides:
toArray in class AbstractLongCollection

toArray

public long[] toArray()
Description copied from interface: LongSet
Returns the newly allocated array containing all numbers from this set, in the order returned by its iterator.

Specified by:
toArray in interface LongSet
Overrides:
toArray in class AbstractLongCollection