public class ConciseSet extends AbstractIntSet implements Serializable
IntSet internally represented by
compressed bitmaps though a RLE (Run-Length Encoding) compression algorithm.
See http
://ricerca.mat.uniroma3.it/users/colanton/docs/concise.pdf for more
details.
Notice that the iterator by iterator() is fail-fast,
similar to most Collection-derived classes. If the set is
structurally modified at any time after the iterator is created, the iterator
will throw 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. The iterator throws a ConcurrentModificationException on a
best-effort basis. Therefore, it would be wrong to write a program that
depended on this exception for its correctness: the fail-fast behavior of
iterators should be used only to detect bugs.IntSet.IntIterator| Constructor and Description |
|---|
ConciseSet()
Creates an empty integer set
|
ConciseSet(boolean simulateWAH)
Creates an empty integer set
|
ConciseSet(int[] words,
boolean simulateWAH) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(int e)
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 from,
int to)
Removes from the set all the elements between
first and
last, both included. |
ConciseSet |
clone()
See the
clone() of Object |
double |
collectionCompressionRatio()
|
int |
compareTo(IntSet o) |
void |
complement()
Complements the current set.
|
ConciseSet |
complemented()
Generates the complement set.
|
boolean |
contains(int o)
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)
|
ConciseSet |
convert(Collection<Integer> c)
Converts a given collection into an instance of the current class.
|
ConciseSet |
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() |
ConciseSet |
difference(IntSet other)
Generates the difference set
|
ConciseSet |
empty()
Generates an empty set
|
boolean |
equals(Object obj) |
void |
fill(int from,
int to)
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 i)
Gets the
ith element of the set |
int[] |
getWords() |
int |
hashCode() |
int |
indexOf(int e)
Provides position of element within the set.
|
ConciseSet |
intersection(IntSet other)
Generates the intersection set
|
int |
intersectionSize(IntSet o)
Computes the intersection set size.
|
boolean |
isEmpty() |
IntSet.IntIterator |
iterator() |
int |
last()
Returns the last (highest) element currently in this set.
|
boolean |
remove(int o)
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() |
ConciseSet |
symmetricDifference(IntSet other)
Generates the symmetric difference set
|
ByteBuffer |
toByteBuffer() |
ConciseSet |
union(IntSet other)
Generates the union set
|
complementSize, differenceSize, first, jaccardDistance, jaccardSimilarity, powerSet, powerSet, powerSetSize, powerSetSize, symmetricDifferenceSize, toArray, toArray, toString, unionSize, weightedJaccardDistance, weightedJaccardSimilaritypublic ConciseSet()
public ConciseSet(boolean simulateWAH)
simulateWAH - true if the class must simulate the behavior of
WAHpublic ConciseSet(int[] words,
boolean simulateWAH)
public ConciseSet clone()
clone() of Objectclone in interface IntSetclone in class AbstractIntSetpublic int intersectionSize(IntSet o)
This is faster than calling IntSet.intersection(IntSet) and
then IntSet.size()
intersectionSize in interface IntSetintersectionSize in class AbstractIntSeto - IntSet instance that represents the right
operandpublic ByteBuffer toByteBuffer()
public int[] getWords()
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 ConciseSet intersection(IntSet other)
intersection in interface IntSetintersection in class AbstractIntSetother - IntSet instance that represents the right
operandIntSet.retainAll(IntSet)public ConciseSet union(IntSet other)
union in interface IntSetunion in class AbstractIntSetother - IntSet instance that represents the right
operandIntSet.addAll(IntSet)public ConciseSet difference(IntSet other)
difference in interface IntSetdifference in class AbstractIntSetother - IntSet instance that represents the right
operandIntSet.removeAll(IntSet)public ConciseSet symmetricDifference(IntSet other)
symmetricDifference in interface IntSetsymmetricDifference in class AbstractIntSetother - IntSet instance that represents the right
operandIntSet.flip(int)public ConciseSet complemented()
IntSet.last() that do not exist in the
current set.complemented in interface IntSetcomplemented in class AbstractIntSetIntSet.complement()public void complement()
IntSet.last() that do not exist in the
current set.complement in interface IntSetcomplement in class AbstractIntSetIntSet.complemented()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 void clear()
clear in interface IntSetclear in class AbstractIntSetpublic int last()
last in interface IntSetlast in class AbstractIntSetpublic ConciseSet convert(int... a)
convert in interface IntSetconvert in class AbstractIntSeta - array to use to generate the new instancepublic ConciseSet convert(Collection<Integer> c)
convert in interface IntSetconvert in class AbstractIntSetc - array to use to generate the new instancepublic boolean add(int e)
add in interface IntSetadd in class AbstractIntSete - element to be added to this setpublic boolean remove(int o)
remove in interface IntSetremove in class AbstractIntSeto - object to be removed from this set, if presentpublic boolean contains(int o)
contains in interface IntSetcontains in class AbstractIntSeto - 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 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 boolean isEmpty()
isEmpty in interface IntSetisEmpty in class AbstractIntSetpublic boolean retainAll(IntSet c)
retainAll in interface IntSetretainAll in class AbstractIntSetc - collection containing elements to be retained in this setIntSet.remove(int)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 int size()
size in interface IntSetsize in class AbstractIntSetpublic ConciseSet empty()
empty in interface IntSetempty in class AbstractIntSetpublic int hashCode()
hashCode in class AbstractIntSetpublic boolean equals(Object obj)
equals in class AbstractIntSetpublic int compareTo(IntSet o)
compareTo in interface Comparable<IntSet>compareTo in class AbstractIntSetpublic void clear(int from,
int to)
first and
last, both included.clear in interface IntSetclear in class AbstractIntSetfrom - first elementto - last elementpublic void fill(int from,
int to)
first and
last, both included.fill in interface IntSetfill in class AbstractIntSetfrom - first elementto - last elementpublic void flip(int e)
flip in interface IntSetflip in class AbstractIntSete - element to flipIntSet.symmetricDifference(IntSet)public 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 AbstractIntSetCopyright © 2011–2017. All rights reserved.