public interface IntSet extends Cloneable, Comparable<IntSet>
Modifier and Type | Interface and Description |
---|---|
static interface |
IntSet.IntIterator
An
Iterator -like interface that allows to "skip" some elements of
the 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 from,
int to)
Removes from the set all the elements between
first and
last , both included. |
IntSet |
clone()
See the
clone() of Object |
double |
collectionCompressionRatio()
|
void |
complement()
Complements the current set.
|
IntSet |
complemented()
Generates the complement set.
|
int |
complementSize()
Computes the complement set size.
|
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 other)
|
boolean |
containsAtLeast(IntSet other,
int minElements)
|
IntSet |
convert(Collection<Integer> c)
Converts a given collection into an instance of the current class.
|
IntSet |
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() |
IntSet |
difference(IntSet other)
Generates the difference set
|
int |
differenceSize(IntSet other)
Computes the difference set size.
|
IntSet |
empty()
Generates an empty set
|
void |
fill(int from,
int to)
Adds to the set all the elements between
first and
last , both included. |
int |
first()
Returns the first (lowest) element currently in this set.
|
void |
flip(int e)
Adds the element if it not existing, or removes it if existing
|
int |
get(int i)
Gets the
i th element of the set |
int |
indexOf(int e)
Provides position of element within the set.
|
IntSet |
intersection(IntSet other)
Generates the intersection set
|
int |
intersectionSize(IntSet other)
Computes the intersection set size.
|
boolean |
isEmpty() |
IntSet.IntIterator |
iterator() |
double |
jaccardDistance(IntSet other)
Computes the Jaccard distance between this set and the given set.
|
double |
jaccardSimilarity(IntSet other)
Computes the Jaccard similarity coefficient between this set and the
given set.
|
int |
last()
Returns the last (highest) element currently in this set.
|
List<? extends IntSet> |
powerSet()
Computes the power-set of the current set.
|
List<? extends IntSet> |
powerSet(int min,
int max)
Computes a subset of the power-set of the current set, composed by those
subsets that have cardinality between
min and
max . |
int |
powerSetSize()
Computes the power-set size of the current set.
|
int |
powerSetSize(int min,
int max)
Computes the power-set size of the current set, composed by those subsets
that have cardinality between
min and max . |
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() |
IntSet |
symmetricDifference(IntSet other)
Generates the symmetric difference set
|
int |
symmetricDifferenceSize(IntSet other)
Computes the symmetric difference set size.
|
int[] |
toArray() |
int[] |
toArray(int[] a)
Returns an array containing all of the elements in this set.
|
IntSet |
union(IntSet other)
Generates the union set
|
int |
unionSize(IntSet other)
Computes the union set size.
|
double |
weightedJaccardDistance(IntSet other)
Computes the weighted version of the Jaccard distance between this set
and the given set.
|
double |
weightedJaccardSimilarity(IntSet other)
Computes the weighted version of the Jaccard similarity coefficient
between this set and the given set.
|
compareTo
IntSet intersection(IntSet other)
other
- IntSet
instance that represents the right
operandretainAll(IntSet)
IntSet union(IntSet other)
other
- IntSet
instance that represents the right
operandaddAll(IntSet)
IntSet difference(IntSet other)
other
- IntSet
instance that represents the right
operandremoveAll(IntSet)
IntSet complemented()
last()
that do not exist in the
current set.complement()
void complement()
last()
that do not exist in the
current set.complemented()
boolean containsAny(IntSet other)
boolean containsAtLeast(IntSet other, int minElements)
true
if the specified IntSet
instance contains at least minElements
elements that are
also contained within this IntSet
instanceother
- IntSet
instance to intersect withminElements
- minimum number of elements to be contained within this
IntSet
instanceIntSet
intersects the specified IntSet
.IllegalArgumentException
- if minElements < 1
int intersectionSize(IntSet other)
This is faster than calling intersection(IntSet)
and
then size()
other
- IntSet
instance that represents the right
operandint unionSize(IntSet other)
This is faster than calling union(IntSet)
and then
size()
other
- IntSet
instance that represents the right
operandint symmetricDifferenceSize(IntSet other)
This is faster than calling symmetricDifference(IntSet)
and then size()
other
- IntSet
instance that represents the right
operandint differenceSize(IntSet other)
This is faster than calling difference(IntSet)
and then
size()
other
- IntSet
instance that represents the right
operandint complementSize()
This is faster than calling complemented()
and then
size()
IntSet empty()
double bitmapCompressionRatio()
BitSet
, 2 means twice the size of BitSet
, etc.)double collectionCompressionRatio()
ArrayList
, 2 means twice the size of ArrayList
, etc.)IntSet.IntIterator iterator()
IntSet.IntIterator
instance to iterate over the setIntSet.IntIterator descendingIterator()
IntSet.IntIterator
instance to iterate over the set in
descending orderString debugInfo()
IntSet
implementationvoid fill(int from, int to)
first
and
last
, both included.from
- first elementto
- last elementvoid clear(int from, int to)
first
and
last
, both included.from
- first elementto
- last elementvoid flip(int e)
e
- element to flipsymmetricDifference(IntSet)
int get(int i)
i
th element of the seti
- position of the element in the sorted seti
th element of the setIndexOutOfBoundsException
- if i
is less than zero, or greater or equal to
size()
int indexOf(int e)
It returns -1 if the element does not exist within the set.
e
- element of the setIntSet convert(int... a)
a
- array to use to generate the new instanceIntSet convert(Collection<Integer> c)
c
- array to use to generate the new instanceint first()
NoSuchElementException
- if this set is emptyint last()
NoSuchElementException
- if this set is emptyint size()
boolean isEmpty()
boolean contains(int i)
i
- element whose presence in this set is to be testedboolean add(int i)
i
- element to be added to this setIllegalArgumentException
- if some property of the specified element prevents it from
being added to this setboolean remove(int i)
i
- object to be removed from this set, if presentUnsupportedOperationException
- if the remove operation is not supported by this setboolean containsAll(IntSet c)
c
- collection to be checked for containment in this setNullPointerException
- if the specified collection contains one or more null
elements and this set does not permit null elements
(optional), or if the specified collection is nullcontains(int)
boolean addAll(IntSet c)
c
- collection containing elements to be added to this setNullPointerException
- if the specified collection contains one or more null
elements and this set does not permit null elements, or if
the specified collection is nullIllegalArgumentException
- if some property of an element of the specified collection
prevents it from being added to this setadd(int)
boolean retainAll(IntSet c)
c
- collection containing elements to be retained in this setNullPointerException
- if this set contains a null element and the specified
collection does not permit null elements (optional), or if
the specified collection is nullremove(int)
boolean removeAll(IntSet c)
c
- collection containing elements to be removed from this setNullPointerException
- if this set contains a null element and the specified
collection does not permit null elements (optional), or if
the specified collection is nullremove(int)
,
contains(int)
void clear()
UnsupportedOperationException
- if the clear method is not supported by this setint[] toArray()
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.
a
- the array into which the elements of this set are to be
stored.NullPointerException
- if the specified array is nullIllegalArgumentException
- if this set does not fit in the specified arrayList<? extends IntSet> powerSet()
It is a particular implementation of the algorithm Apriori (see: Rakesh Agrawal, Ramakrishnan Srikant, Fast Algorithms for Mining Association Rules in Large Databases, in Proceedings of the 20th International Conference on Very Large Data Bases, p.487-499, 1994). The returned power-set does not contain the empty set.
The subsets composing the powerset are returned in a list that is sorted according to the lexicographical order provided by the integer set.
powerSet(int, int)
,
powerSetSize()
List<? extends IntSet> powerSet(int min, int max)
min
and
max
.
It is a particular implementation of the algorithm Apriori (see: Rakesh Agrawal, Ramakrishnan Srikant, Fast Algorithms for Mining Association Rules in Large Databases, in Proceedings of the 20th International Conference on Very Large Data Bases, p.487-499, 1994). The power-set does not contains the empty set.
The subsets composing the powerset are returned in a list that is sorted according to the lexicographical order provided by the integer set.
min
- minimum subset size (greater than zero)max
- maximum subset sizepowerSet()
,
powerSetSize(int, int)
int powerSetSize()
The power-set does not contains the empty set.
powerSet()
int powerSetSize(int min, int max)
min
and max
.
The returned power-set does not contain the empty set.
min
- minimum subset size (greater than zero)max
- maximum subset sizepowerSet(int, int)
double jaccardSimilarity(IntSet other)
The coefficient is defined as
|A intersection B| / |A union B|
.
other
- the other setjaccardDistance(IntSet)
double jaccardDistance(IntSet other)
The coefficient is defined as
1 -
jaccardSimilarity(IntSet)
.
other
- the other setjaccardSimilarity(IntSet)
double weightedJaccardSimilarity(IntSet other)
The coefficient is defined as
sum of min(A_i, B_i) / sum of max(A_i, B_i)
.
other
- the other setweightedJaccardDistance(IntSet)
double weightedJaccardDistance(IntSet other)
The coefficient is defined as 1 -
weightedJaccardSimilarity(IntSet)
.
other
- the other setweightedJaccardSimilarity(IntSet)
Copyright © 2011–2017. All rights reserved.