public class HashIntSet extends AbstractIntSet
IntSet.IntIterator| Modifier and Type | Field and Description |
|---|---|
protected int[] |
cells
cells
|
protected static int |
EMPTY
empty cell
|
protected int |
freecells
This is the number of empty cells.
|
protected static int |
INITIAL_SIZE |
protected static double |
LOAD_FACTOR |
protected int |
modCount
concurrent modification during iteration
|
protected static int |
REMOVED
When an object is deleted this object is put into the hashtable in its
place, so that other objects with the same key (collisions) further down
the hashtable are not lost after we delete an object in the collision
chain.
|
protected int |
size
number of elements
|
| Constructor and Description |
|---|
HashIntSet()
Constructs a new, empty set.
|
HashIntSet(int initialSize)
Constructs a new, empty set.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(int element)
Adds the specified element to this set if it is not already present.
|
boolean |
addAll(IntSet c)
Adds all of the elements in the specified collection to this set if
they're not already present.
|
double |
bitmapCompressionRatio()
|
void |
clear()
Removes all of the elements from this set.
|
HashIntSet |
clone()
See the
clone() of Object |
double |
collectionCompressionRatio()
|
HashIntSet |
complemented()
Generates the complement set.
|
boolean |
contains(int element)
Returns true if this set contains the specified element.
|
boolean |
containsAll(IntSet c)
Returns true if this set contains all of the elements of the
specified collection.
|
boolean |
containsAny(IntSet c)
|
boolean |
containsAtLeast(IntSet c,
int minElements)
|
HashIntSet |
convert(Collection<Integer> c)
Converts a given collection into an instance of the current class.
|
HashIntSet |
convert(int... a)
Converts a given array into an instance of the current class.
|
String |
debugInfo()
Prints debug info about the given
IntSet implementation |
IntSet.IntIterator |
descendingIterator() |
HashIntSet |
difference(IntSet other)
Generates the difference set
|
HashIntSet |
empty()
Generates an empty set
|
boolean |
equals(Object obj) |
int |
first()
Returns the first (lowest) element currently in this set.
|
void |
flip(int element)
Adds the element if it not existing, or removes it if existing
|
int |
get(int i)
Gets the
ith element of the set |
int |
hashCode() |
int |
indexOf(int e)
Provides position of element within the set.
|
HashIntSet |
intersection(IntSet other)
Generates the intersection set
|
int |
intersectionSize(IntSet c)
Computes the intersection set size.
|
boolean |
isEmpty()
Returns true if this set contains no elements.
|
IntSet.IntIterator |
iterator() |
int |
last()
Returns the last (highest) element currently in this set.
|
protected void |
rehash()
Figures out correct size for rehashed set, then does the rehash.
|
protected void |
rehash(int newCapacity)
Rehashes to a bigger size.
|
boolean |
remove(int element)
Removes the specified element from the set.
|
boolean |
removeAll(IntSet c)
Removes from this set all of its elements that are contained in the
specified collection.
|
boolean |
retainAll(IntSet 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 (its cardinality).
|
HashIntSet |
symmetricDifference(IntSet c)
Generates the symmetric difference set
|
int[] |
toArray(int[] a)
Returns an array containing all of the elements in this set.
|
String |
toString() |
HashIntSet |
union(IntSet other)
Generates the union set
|
IntSet.IntIterator |
unsortedIterator()
Similar to
iterator(), but with no particular order |
clear, compareTo, complement, complementSize, differenceSize, fill, jaccardDistance, jaccardSimilarity, powerSet, powerSet, powerSetSize, powerSetSize, symmetricDifferenceSize, toArray, unionSize, weightedJaccardDistance, weightedJaccardSimilarityprotected static final int INITIAL_SIZE
protected static final double LOAD_FACTOR
protected static final int EMPTY
protected static final int REMOVED
protected int size
protected int freecells
protected int[] cells
protected int modCount
public HashIntSet()
public HashIntSet(int initialSize)
initialSize - public IntSet.IntIterator iterator()
iterator in interface IntSetiterator in class AbstractIntSetIntSet.IntIterator instance to iterate over the setpublic IntSet.IntIterator descendingIterator()
descendingIterator in interface IntSetdescendingIterator in class AbstractIntSetIntSet.IntIterator instance to iterate over the set in
descending orderpublic IntSet.IntIterator unsortedIterator()
iterator(), but with no particular orderpublic int size()
size in interface IntSetsize in class AbstractIntSetpublic boolean isEmpty()
isEmpty in interface IntSetisEmpty in class AbstractIntSetpublic boolean contains(int element)
contains in interface IntSetcontains in class AbstractIntSetelement - element whose presence in this set is to be tested.public boolean add(int element)
add in interface IntSetadd in class AbstractIntSetelement - element to be added to this set.public boolean remove(int element)
remove in interface IntSetremove in class AbstractIntSetelement - object to be removed from this set, if presentpublic void clear()
clear in interface IntSetclear in class AbstractIntSetprotected void rehash()
protected void rehash(int newCapacity)
public boolean addAll(IntSet c)
addAll in interface IntSetaddAll in class AbstractIntSetc - collection containing elements to be added to this setIntSet.add(int)public boolean removeAll(IntSet c)
removeAll in interface IntSetremoveAll in class AbstractIntSetc - collection containing elements to be removed from this setIntSet.remove(int),
IntSet.contains(int)public boolean retainAll(IntSet c)
retainAll in interface IntSetretainAll in class AbstractIntSetc - collection containing elements to be retained in this setIntSet.remove(int)public HashIntSet clone()
clone() of Objectclone in interface IntSetclone in class AbstractIntSetpublic double bitmapCompressionRatio()
BitSet, 2 means twice the size of BitSet, etc.)bitmapCompressionRatio in interface IntSetbitmapCompressionRatio in class AbstractIntSetpublic double collectionCompressionRatio()
ArrayList, 2 means twice the size of ArrayList, etc.)collectionCompressionRatio in interface IntSetcollectionCompressionRatio in class AbstractIntSetpublic HashIntSet complemented()
IntSet.last() that do not exist in the
current set.complemented in interface IntSetcomplemented in class AbstractIntSetIntSet.complement()public boolean containsAll(IntSet c)
containsAll in interface IntSetcontainsAll in class AbstractIntSetc - collection to be checked for containment in this setIntSet.contains(int)public boolean containsAny(IntSet c)
true if the specified IntSet
instance contains any elements that are also contained within this
IntSet instancecontainsAny in interface IntSetcontainsAny in class AbstractIntSetc - IntSet to intersect withIntSet
intersects the specified IntSet.public boolean containsAtLeast(IntSet c, int minElements)
true if the specified IntSet
instance contains at least minElements elements that are
also contained within this IntSet instancecontainsAtLeast in interface IntSetcontainsAtLeast in class AbstractIntSetc - IntSet instance to intersect withminElements - minimum number of elements to be contained within this
IntSet instanceIntSet
intersects the specified IntSet.public HashIntSet convert(int... a)
convert in interface IntSetconvert in class AbstractIntSeta - array to use to generate the new instancepublic HashIntSet convert(Collection<Integer> c)
convert in interface IntSetconvert in class AbstractIntSetc - array to use to generate the new instancepublic String debugInfo()
IntSet implementationdebugInfo in interface IntSetdebugInfo in class AbstractIntSetpublic HashIntSet symmetricDifference(IntSet c)
symmetricDifference in interface IntSetsymmetricDifference in class AbstractIntSetc - IntSet instance that represents the right
operandIntSet.flip(int)public HashIntSet union(IntSet other)
union in interface IntSetunion in class AbstractIntSetother - IntSet instance that represents the right
operandIntSet.addAll(IntSet)public HashIntSet difference(IntSet other)
difference in interface IntSetdifference in class AbstractIntSetother - IntSet instance that represents the right
operandIntSet.removeAll(IntSet)public HashIntSet intersection(IntSet other)
intersection in interface IntSetintersection in class AbstractIntSetother - IntSet instance that represents the right
operandIntSet.retainAll(IntSet)public HashIntSet empty()
empty in interface IntSetempty in class AbstractIntSetpublic void flip(int element)
flip in interface IntSetflip in class AbstractIntSetelement - element to flipIntSet.symmetricDifference(IntSet)public int get(int i)
ith element of the setget in interface IntSetget in class AbstractIntSeti - position of the element in the sorted setith element of the setpublic int indexOf(int e)
It returns -1 if the element does not exist within the set.
indexOf in interface IntSetindexOf in class AbstractIntSete - element of the setpublic int intersectionSize(IntSet c)
This is faster than calling IntSet.intersection(IntSet) and
then IntSet.size()
intersectionSize in interface IntSetintersectionSize in class AbstractIntSetc - IntSet instance that represents the right
operandpublic int last()
last in interface IntSetlast in class AbstractIntSetpublic int first()
first in interface IntSetfirst in class AbstractIntSetpublic int[] toArray(int[] a)
If this set fits in the specified array with room to spare (i.e., the array has more elements than this set), the element in the array immediately following the end of the set are left unchanged.
toArray in interface IntSettoArray in class AbstractIntSeta - the array into which the elements of this set are to be
stored.public String toString()
toString in class AbstractIntSetpublic int hashCode()
hashCode in class AbstractIntSetpublic boolean equals(Object obj)
equals in class AbstractIntSetCopyright © 2016. All rights reserved.