public abstract class AbstractIntSet extends Object implements IntSet
IntSet
interface to minimize the effort required to implement this interface.IntSet.IntIterator
Constructor and Description |
---|
AbstractIntSet() |
Modifier and Type | Method and Description |
---|---|
abstract 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.
|
abstract 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. |
abstract IntSet |
clone()
See the
clone() of Object |
abstract double |
collectionCompressionRatio()
|
int |
compareTo(IntSet o) |
void |
complement()
Complements the current set.
|
IntSet |
complemented()
Generates the complement set.
|
int |
complementSize()
Computes the complement set size.
|
abstract 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)
|
abstract IntSet |
convert(Collection<Integer> c)
Converts a given collection into an instance of the current class.
|
abstract IntSet |
convert(int... a)
Converts a given array into an instance of the current class.
|
abstract String |
debugInfo()
Prints debug info about the given
IntSet implementation |
abstract IntSet.IntIterator |
descendingIterator() |
IntSet |
difference(IntSet other)
Generates the difference set
|
int |
differenceSize(IntSet other)
Computes the difference set size.
|
abstract IntSet |
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. |
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
|
abstract int |
get(int i)
Gets the
i th element of the set |
int |
hashCode() |
abstract int |
indexOf(int e)
Provides position of element within the set.
|
IntSet |
intersection(IntSet other)
Generates the intersection set
|
int |
intersectionSize(IntSet c)
Computes the intersection set size.
|
abstract boolean |
isEmpty() |
abstract 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.
|
abstract 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 . |
abstract 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.
|
abstract int |
size() |
IntSet |
symmetricDifference(IntSet c)
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.
|
String |
toString() |
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.
|
public IntSet union(IntSet other)
union
in interface IntSet
other
- IntSet
instance that represents the right
operandIntSet.addAll(IntSet)
public IntSet difference(IntSet other)
difference
in interface IntSet
other
- IntSet
instance that represents the right
operandIntSet.removeAll(IntSet)
public IntSet intersection(IntSet other)
intersection
in interface IntSet
other
- IntSet
instance that represents the right
operandIntSet.retainAll(IntSet)
public IntSet symmetricDifference(IntSet c)
symmetricDifference
in interface IntSet
c
- IntSet
instance that represents the right
operandIntSet.flip(int)
public IntSet complemented()
IntSet.last()
that do not exist in the
current set.complemented
in interface IntSet
IntSet.complement()
public void complement()
IntSet.last()
that do not exist in the
current set.complement
in interface IntSet
IntSet.complemented()
public boolean containsAll(IntSet c)
containsAll
in interface IntSet
c
- 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 IntSet
c
- IntSet
to intersect withIntSet
intersects the specified IntSet
.public boolean containsAtLeast(IntSet c, int minElements)
public int intersectionSize(IntSet c)
This is faster than calling IntSet.intersection(IntSet)
and
then IntSet.size()
intersectionSize
in interface IntSet
c
- IntSet
instance that represents the right
operandpublic int unionSize(IntSet other)
This is faster than calling IntSet.union(IntSet)
and then
IntSet.size()
public int symmetricDifferenceSize(IntSet other)
This is faster than calling IntSet.symmetricDifference(IntSet)
and then IntSet.size()
symmetricDifferenceSize
in interface IntSet
other
- IntSet
instance that represents the right
operandpublic int differenceSize(IntSet other)
This is faster than calling IntSet.difference(IntSet)
and then
IntSet.size()
differenceSize
in interface IntSet
other
- IntSet
instance that represents the right
operandpublic int complementSize()
This is faster than calling IntSet.complemented()
and then
IntSet.size()
complementSize
in interface IntSet
public abstract IntSet empty()
public abstract double bitmapCompressionRatio()
BitSet
, 2 means twice the size of BitSet
, etc.)bitmapCompressionRatio
in interface IntSet
public abstract double collectionCompressionRatio()
ArrayList
, 2 means twice the size of ArrayList
, etc.)collectionCompressionRatio
in interface IntSet
public abstract IntSet.IntIterator iterator()
iterator
in interface IntSet
IntSet.IntIterator
instance to iterate over the setpublic abstract IntSet.IntIterator descendingIterator()
descendingIterator
in interface IntSet
IntSet.IntIterator
instance to iterate over the set in
descending orderpublic abstract String debugInfo()
IntSet
implementationpublic void clear()
public void clear(int from, int to)
first
and
last
, both included.public void fill(int from, int to)
first
and
last
, both included.public void flip(int e)
flip
in interface IntSet
e
- element to flipIntSet.symmetricDifference(IntSet)
public abstract int get(int i)
i
th element of the setpublic abstract int indexOf(int e)
It returns -1 if the element does not exist within the set.
public abstract IntSet convert(int... a)
public abstract IntSet convert(Collection<Integer> c)
public int first()
public abstract int last()
public abstract int size()
public abstract boolean isEmpty()
public abstract boolean contains(int i)
public abstract boolean add(int i)
public abstract boolean remove(int i)
public boolean addAll(IntSet c)
addAll
in interface IntSet
c
- collection containing elements to be added to this setIntSet.add(int)
public boolean removeAll(IntSet c)
removeAll
in interface IntSet
c
- collection containing elements to be removed from this setIntSet.remove(int)
,
IntSet.contains(int)
public boolean retainAll(IntSet c)
retainAll
in interface IntSet
c
- collection containing elements to be retained in this setIntSet.remove(int)
public int[] toArray()
public 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.
public int compareTo(IntSet o)
compareTo
in interface Comparable<IntSet>
public List<? 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
in interface IntSet
IntSet.powerSet(int, int)
,
IntSet.powerSetSize()
public 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.
powerSet
in interface IntSet
min
- minimum subset size (greater than zero)max
- maximum subset sizeIntSet.powerSet()
,
IntSet.powerSetSize(int, int)
public int powerSetSize()
The power-set does not contains the empty set.
powerSetSize
in interface IntSet
IntSet.powerSet()
public int powerSetSize(int min, int max)
min
and max
.
The returned power-set does not contain the empty set.
powerSetSize
in interface IntSet
min
- minimum subset size (greater than zero)max
- maximum subset sizeIntSet.powerSet(int, int)
public double jaccardSimilarity(IntSet other)
The coefficient is defined as
|A intersection B| / |A union B|
.
jaccardSimilarity
in interface IntSet
other
- the other setIntSet.jaccardDistance(IntSet)
public double jaccardDistance(IntSet other)
The coefficient is defined as
1 -
IntSet.jaccardSimilarity(IntSet)
.
jaccardDistance
in interface IntSet
other
- the other setIntSet.jaccardSimilarity(IntSet)
public double weightedJaccardSimilarity(IntSet other)
The coefficient is defined as
sum of min(A_i, B_i) / sum of max(A_i, B_i)
.
weightedJaccardSimilarity
in interface IntSet
other
- the other setIntSet.weightedJaccardDistance(IntSet)
public double weightedJaccardDistance(IntSet other)
The coefficient is defined as 1 -
IntSet.weightedJaccardSimilarity(IntSet)
.
weightedJaccardDistance
in interface IntSet
other
- the other setIntSet.weightedJaccardSimilarity(IntSet)
Copyright © 2011–2017. All rights reserved.