edu.emory.mathcs.util.collections.shorts
Class ShortRadkeHashSet

java.lang.Object
  extended byedu.emory.mathcs.util.collections.shorts.AbstractShortCollection
      extended byedu.emory.mathcs.util.collections.shorts.AbstractShortSet
          extended byedu.emory.mathcs.util.collections.shorts.ShortRadkeHashSet
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, ShortCollection, ShortSet

public class ShortRadkeHashSet
extends AbstractShortSet
implements java.lang.Cloneable, java.io.Serializable

Hash set of short 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
ShortRadkeHashSet()
           
ShortRadkeHashSet(int minInitialCapacity)
           
ShortRadkeHashSet(int minInitialCapacity, float loadFactor, float resizeTreshold)
           
ShortRadkeHashSet(int minInitialCapacity, short min, short max)
           
ShortRadkeHashSet(int minInitialCapacity, short min, short max, float loadFactor, float resizeTreshold)
           
ShortRadkeHashSet(ShortCollection c)
           
ShortRadkeHashSet(ShortSet m)
           
 
Method Summary
 boolean add(short 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(short 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.
 ShortIterator iterator()
          Returns the iterator over numbers contained in this set.
 short max()
          The largest number that can be stored in this set.
 short min()
          The smallest number that can be stored in this set.
 boolean remove(short elem)
          Removes the specified number from this set if it is present.
 boolean removeAll(ShortCollection c)
          Removes from this set all of its elements that are contained in the specified collection.
 boolean retainAll(ShortCollection 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.
 short[] toArray()
          Returns the newly allocated array containing all numbers from this set, in the order returned by its iterator.
 short[] toArray(short[] a)
          Returns an array containing all of the numbers in this set.
 
Methods inherited from class edu.emory.mathcs.util.collections.shorts.AbstractShortSet
addAll, addInterval, complementSet, containsInterval, removeInterval, retainInterval
 
Methods inherited from class edu.emory.mathcs.util.collections.shorts.AbstractShortCollection
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.shorts.ShortSet
containsAll
 

Constructor Detail

ShortRadkeHashSet

public ShortRadkeHashSet()

ShortRadkeHashSet

public ShortRadkeHashSet(int minInitialCapacity)

ShortRadkeHashSet

public ShortRadkeHashSet(int minInitialCapacity,
                         short min,
                         short max)

ShortRadkeHashSet

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

ShortRadkeHashSet

public ShortRadkeHashSet(int minInitialCapacity,
                         short min,
                         short max,
                         float loadFactor,
                         float resizeTreshold)

ShortRadkeHashSet

public ShortRadkeHashSet(ShortSet m)

ShortRadkeHashSet

public ShortRadkeHashSet(ShortCollection c)
Method Detail

min

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

Specified by:
min in interface ShortSet
Overrides:
min in class AbstractShortSet

max

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

Specified by:
max in interface ShortSet
Overrides:
max in class AbstractShortSet

add

public boolean add(short elem)
Description copied from interface: ShortSet
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 ShortSet
Overrides:
add in class AbstractShortCollection

contains

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

Specified by:
contains in interface ShortSet
Overrides:
contains in class AbstractShortCollection

remove

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

Specified by:
remove in interface ShortSet
Overrides:
remove in class AbstractShortCollection

clear

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

Specified by:
clear in interface ShortSet
Overrides:
clear in class AbstractShortCollection

isEmpty

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

Specified by:
isEmpty in interface ShortSet
Overrides:
isEmpty in class AbstractShortSet

size

public int size()
Description copied from interface: ShortSet
Returns the number of elements in this set.

Specified by:
size in interface ShortSet
Overrides:
size in class AbstractShortCollection

iterator

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

Specified by:
iterator in interface ShortSet
Specified by:
iterator in class AbstractShortCollection

equals

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

Specified by:
equals in interface ShortSet
Overrides:
equals in class AbstractShortSet

hashCode

public int hashCode()
Specified by:
hashCode in interface ShortSet
Overrides:
hashCode in class AbstractShortSet

clone

public java.lang.Object clone()

removeAll

public boolean removeAll(ShortCollection c)
Description copied from interface: ShortSet
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 ShortSet
Overrides:
removeAll in class AbstractShortSet

retainAll

public boolean retainAll(ShortCollection c)
Description copied from interface: ShortSet
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 ShortSet
Overrides:
retainAll in class AbstractShortSet

toArray

public short[] toArray(short[] a)
Description copied from interface: ShortSet
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 ShortSet.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 ShortSet
Overrides:
toArray in class AbstractShortCollection

toArray

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

Specified by:
toArray in interface ShortSet
Overrides:
toArray in class AbstractShortCollection