public class FastSet extends AbstractIntSet implements Serializable
IntSet implementation, representing a set of integers, based on an
uncompressed bitmap.
It actually is an extension of BitSet. More specifically, union and
intersection operations are mainly derived from the code of BitSet to
provide bitwise "or" and "and".
The iterator implemented for this class allows for modifications during the
iteration, that is it is possible to add/remove elements through
add(int), remove(int), addAll(IntSet),
removeAll(IntSet), retainAll(IntSet), etc.. In this case,
IntSet.IntIterator.next() returns the first integral greater than the last
visited one.IntSet.IntIterator| Constructor and Description |
|---|
FastSet()
Creates a new, empty set.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(int i)
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.
|
void |
clear(int fromIndex,
int toIndex)
Removes from the set all the elements between
first and
last, both included. |
FastSet |
clone()
See the
clone() of Object |
double |
collectionCompressionRatio()
|
int |
compareTo(IntSet o) |
void |
complement()
Complements the current set.
|
FastSet |
complemented()
Generates the complement set.
|
boolean |
contains(int i)
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)
|
FastSet |
convert(Collection<Integer> c)
Converts a given collection into an instance of the current class.
|
FastSet |
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() |
FastSet |
difference(IntSet other)
Generates the difference set
|
FastSet |
empty()
Generates an empty set
|
boolean |
equals(Object obj) |
void |
fill(int fromIndex,
int toIndex)
Adds to the set all the elements between
first and
last, both included. |
void |
flip(int e)
Adds the element if it not existing, or removes it if existing
|
int |
get(int index)
Gets the
ith element of the set |
int |
hashCode() |
int |
indexOf(int e)
Provides position of element within the set.
|
FastSet |
intersection(IntSet other)
Generates the intersection set
|
int |
intersectionSize(IntSet c)
Computes the intersection set size.
|
boolean |
isEmpty() |
IntSet.IntIterator |
iterator() |
int |
last()
Returns the last (highest) element currently in this set.
|
boolean |
remove(int i)
Removes the specified element from this set if it is present.
|
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() |
FastSet |
symmetricDifference(IntSet other)
Generates the symmetric difference set
|
FastSet |
union(IntSet other)
Generates the union set
|
complementSize, differenceSize, first, jaccardDistance, jaccardSimilarity, powerSet, powerSet, powerSetSize, powerSetSize, symmetricDifferenceSize, toArray, toArray, toString, unionSize, weightedJaccardDistance, weightedJaccardSimilaritypublic FastSet clone()
clone() of Objectclone in interface IntSetclone in class AbstractIntSetpublic int hashCode()
hashCode in class AbstractIntSetpublic boolean equals(Object obj)
equals in class AbstractIntSetpublic boolean isEmpty()
isEmpty in interface IntSetisEmpty in class AbstractIntSetpublic int size()
size in interface IntSetsize in class AbstractIntSetpublic boolean add(int i)
add in interface IntSetadd in class AbstractIntSeti - element to be added to this setpublic boolean remove(int i)
remove in interface IntSetremove in class AbstractIntSeti - object to be removed from this set, if presentpublic 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 void clear()
clear in interface IntSetclear in class AbstractIntSetpublic boolean contains(int i)
contains in interface IntSetcontains in class AbstractIntSeti - element whose presence in this set is to be testedpublic boolean containsAll(IntSet c)
containsAll in interface IntSetcontainsAll in class AbstractIntSetc - collection to be checked for containment in this setIntSet.contains(int)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 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 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 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 int last()
last in interface IntSetlast in class AbstractIntSetpublic void complement()
IntSet.last() that do not exist in the
current set.complement in interface IntSetcomplement in class AbstractIntSetIntSet.complemented()public FastSet complemented()
IntSet.last() that do not exist in the
current set.complemented in interface IntSetcomplemented in class AbstractIntSetIntSet.complement()public FastSet empty()
empty in interface IntSetempty 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 FastSet convert(Collection<Integer> c)
convert in interface IntSetconvert in class AbstractIntSetc - array to use to generate the new instancepublic FastSet convert(int... a)
convert in interface IntSetconvert in class AbstractIntSeta - array to use to generate the new instancepublic void fill(int fromIndex,
int toIndex)
first and
last, both included.fill in interface IntSetfill in class AbstractIntSetfromIndex - first elementtoIndex - last elementpublic void clear(int fromIndex,
int toIndex)
first and
last, both included.clear in interface IntSetclear in class AbstractIntSetfromIndex - first elementtoIndex - last elementpublic void flip(int e)
flip in interface IntSetflip in class AbstractIntSete - element to flipIntSet.symmetricDifference(IntSet)public int compareTo(IntSet o)
compareTo in interface Comparable<IntSet>compareTo in class AbstractIntSetpublic int get(int index)
ith element of the setget in interface IntSetget in class AbstractIntSetindex - 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 FastSet intersection(IntSet other)
intersection in interface IntSetintersection in class AbstractIntSetother - IntSet instance that represents the right
operandIntSet.retainAll(IntSet)public FastSet union(IntSet other)
union in interface IntSetunion in class AbstractIntSetother - IntSet instance that represents the right
operandIntSet.addAll(IntSet)public FastSet difference(IntSet other)
difference in interface IntSetdifference in class AbstractIntSetother - IntSet instance that represents the right
operandIntSet.removeAll(IntSet)public FastSet symmetricDifference(IntSet other)
symmetricDifference in interface IntSetsymmetricDifference in class AbstractIntSetother - IntSet instance that represents the right
operandIntSet.flip(int)Copyright © 2016. All rights reserved.