T - the type of elements maintained by this setpublic interface ExtendedSet<T> extends SortedSet<T>, Cloneable, Comparable<ExtendedSet<T>>
SortedSet by adding
intersection/union/difference and other set operations.AbstractExtendedSet,
IndexedSet,
GenericExtendedSet,
ArraySet,
IntegerSet,
LongSet,
PairSet| Modifier and Type | Interface and Description |
|---|---|
static interface |
ExtendedSet.ExtendedIterator<X>
Extended version of the
Iterator interface that allows to "skip"
some elements of the set |
| Modifier and Type | Method and Description |
|---|---|
double |
bitmapCompressionRatio()
|
void |
clear(T from,
T to)
Removes from the set all the elements between
first and
last, both included. |
ExtendedSet<T> |
clone()
See the
clone() of Object |
double |
collectionCompressionRatio()
|
int |
compareTo(ExtendedSet<T> o)
Compares this object with the specified object for order.
|
void |
complement()
Complements the current set.
|
ExtendedSet<T> |
complemented()
Generates the complement set.
|
int |
complementSize()
Computes the complement set size.
|
boolean |
containsAny(Collection<? extends T> other)
Returns
true if the specified Collection instance
contains any elements that are also contained within this
ExtendedSet instance |
boolean |
containsAtLeast(Collection<? extends T> other,
int minElements)
Returns
true if the specified Collection instance
contains at least minElements elements that are also
contained within this ExtendedSet instance |
ExtendedSet<T> |
convert(Collection<?> c)
Converts a given
Collection instance into an instance of the
current class. |
ExtendedSet<T> |
convert(Object... e)
Converts a given integer array into an instance of the current class
|
String |
debugInfo()
Prints debug info about the given
ExtendedSet implementation |
Iterable<T> |
descending()
Allows to use the Java "for-each" statement in descending order
|
ExtendedSet.ExtendedIterator<T> |
descendingIterator()
Gets the descending order iterator over the elements of type
T |
ExtendedSet<T> |
difference(Collection<? extends T> other)
Generates the difference set
|
int |
differenceSize(Collection<? extends T> other)
Computes the difference set size.
|
ExtendedSet<T> |
empty()
Generates an empty set
|
void |
fill(T from,
T to)
Adds to the set all the elements between
first and
last, both included. |
void |
flip(T e)
Adds the element if it not existing, or removes it if existing
|
T |
get(int i)
Gets the
ith element of the set |
ExtendedSet<T> |
headSet(T toElement) |
int |
indexOf(T e)
Provides position of element within the set.
|
ExtendedSet<T> |
intersection(Collection<? extends T> other)
Generates the intersection set
|
int |
intersectionSize(Collection<? extends T> other)
Computes the intersection set size.
|
ExtendedSet.ExtendedIterator<T> |
iterator() |
double |
jaccardDistance(ExtendedSet<T> other)
Computes the Jaccard distance between this set and the given set.
|
double |
jaccardSimilarity(ExtendedSet<T> other)
Computes the Jaccard similarity coefficient between this set and the
given set.
|
List<? extends ExtendedSet<T>> |
powerSet()
Computes the power-set of the current set.
|
List<? extends ExtendedSet<T>> |
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. |
ExtendedSet<T> |
subSet(T fromElement,
T toElement) |
ExtendedSet<T> |
symmetricDifference(Collection<? extends T> other)
Generates the symmetric difference set
|
int |
symmetricDifferenceSize(Collection<? extends T> other)
Computes the symmetric difference set size.
|
ExtendedSet<T> |
tailSet(T fromElement) |
ExtendedSet<T> |
union(Collection<? extends T> other)
Generates the union set
|
int |
unionSize(Collection<? extends T> other)
Computes the union set size.
|
ExtendedSet<T> |
unmodifiable()
Gets the read-only version of the current set
|
double |
weightedJaccardDistance(ExtendedSet<T> other)
Computes the weighted version of the Jaccard distance between this set
and the given set.
|
double |
weightedJaccardSimilarity(ExtendedSet<T> other)
Computes the weighted version of the Jaccard similarity coefficient
between this set and the given set.
|
comparator, first, lastExtendedSet<T> intersection(Collection<? extends T> other)
other - ExtendedSet instance that represents the right
operandSet.retainAll(java.util.Collection)ExtendedSet<T> union(Collection<? extends T> other)
other - ExtendedSet instance that represents the right
operandSet.addAll(java.util.Collection)ExtendedSet<T> difference(Collection<? extends T> other)
other - ExtendedSet instance that represents the right
operandSet.removeAll(java.util.Collection)ExtendedSet<T> symmetricDifference(Collection<? extends T> other)
other - ExtendedSet instance that represents the right
operandflip(Object)ExtendedSet<T> complemented()
SortedSet.last() that do not exist in the
current set.complement()void complement()
SortedSet.last() that do not exist in the
current set.complemented()boolean containsAny(Collection<? extends T> other)
true if the specified Collection instance
contains any elements that are also contained within this
ExtendedSet instanceother - ExtendedSet to intersect withExtendedSet intersects
the specified ExtendedSet.boolean containsAtLeast(Collection<? extends T> other, int minElements)
true if the specified Collection instance
contains at least minElements elements that are also
contained within this ExtendedSet instanceother - Collection instance to intersect withminElements - minimum number of elements to be contained within this
ExtendedSet instanceExtendedSet intersects
the specified Collection.IllegalArgumentException - if minElements < 1int intersectionSize(Collection<? extends T> other)
This is faster than calling intersection(Collection) and
then Set.size()
other - Collection instance that represents the right
operandint unionSize(Collection<? extends T> other)
This is faster than calling union(Collection) and then
Set.size()
other - Collection instance that represents the right
operandint symmetricDifferenceSize(Collection<? extends T> other)
This is faster than calling
symmetricDifference(Collection) and then Set.size()
other - Collection instance that represents the right
operandint differenceSize(Collection<? extends T> other)
This is faster than calling difference(Collection) and
then Set.size()
other - Collection instance that represents the right
operandint complementSize()
This is faster than calling complemented() and then
Set.size()
ExtendedSet<T> empty()
ExtendedSet<T> clone()
clone() of Objectdouble bitmapCompressionRatio()
BitSet, 2 means twice the size of BitSet, etc.)double collectionCompressionRatio()
ArrayList, 2 means twice the size of ArrayList, etc.)ExtendedSet.ExtendedIterator<T> iterator()
ExtendedSet.ExtendedIterator<T> descendingIterator()
TIterable<T> descending()
Iterable instance to iterate items in descending
orderList<? extends ExtendedSet<T>> 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 sorted set.
powerSet(int, int),
powerSetSize()List<? extends ExtendedSet<T>> 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 sorted 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)String debugInfo()
ExtendedSet implementationvoid fill(T from, T to)
first and
last, both included. It supposes that there is an ordering
of the elements of type T and that the universe of all
possible elements is known.from - first elementto - last elementvoid clear(T from, T to)
first and
last, both included. It supposes that there is an ordering
of the elements of type T and that the universe of all
possible elements is known.from - first elementto - last elementvoid flip(T e)
e - element to flipsymmetricDifference(Collection)ExtendedSet<T> unmodifiable()
T get(int i)
ith element of the seti - position of the element in the sorted setith element of the setIndexOutOfBoundsException - if i is less than zero, or greater or equal to
Set.size()int indexOf(T e)
It returns -1 if the element does not exist within the set.
e - element of the setExtendedSet<T> subSet(T fromElement, T toElement)
ExtendedSet<T> convert(Collection<?> c)
Collection instance into an instance of the
current class. NOTE: when the collection is already an instance of
the current class, the method returns the collection itself.c - collection to use to generate the new instanceconvert(Object...)ExtendedSet<T> convert(Object... e)
e - objects to use to generate the new instanceconvert(Collection)double jaccardSimilarity(ExtendedSet<T> other)
The coefficient is defined as
|A intersection B| / |A union B|.
other - the other setjaccardDistance(ExtendedSet)double jaccardDistance(ExtendedSet<T> other)
The coefficient is defined as
1 - jaccardSimilarity(ExtendedSet).
other - the other setjaccardSimilarity(ExtendedSet)double weightedJaccardSimilarity(ExtendedSet<T> other)
The coefficient is defined as
sum of min(A_i, B_i) / sum of max(A_i, B_i).
NOTE: T must be a number, namely one of
Integer, Double, Float, Byte,
Long, Short.
other - the other setIllegalArgumentException - if T is not a numberweightedJaccardDistance(ExtendedSet)double weightedJaccardDistance(ExtendedSet<T> other)
The coefficient is defined as 1 -
weightedJaccardSimilarity(ExtendedSet).
NOTE: T must be a number, namely one of
Integer, Double, Float, Byte,
Long, Short.
other - the other setIllegalArgumentException - if T is not a numberweightedJaccardSimilarity(ExtendedSet)int compareTo(ExtendedSet<T> o)
IntSet
instance A is less than another IntSet instance
B if B-A (that is, the elements in
B that are not contained in A) contains at
least one element that is greater than all the elements in
A-B.
The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception iff y.compareTo(x) throws an exception.)
The implementor must also ensure that the relation is transitive: (x.compareTo(y)>0 && y.compareTo(z)>0) implies x.compareTo(z)>0.
Finally, the implementor must ensure that x.compareTo(y)==0 implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for all z.
It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any class that implements the Comparable interface and violates this condition should clearly indicate this fact. The recommended language is "Note: this class has a natural ordering that is inconsistent with equals."
In the foregoing description, the notation sgn(expression ) designates the mathematical signum function, which is defined to return one of -1, 0, or 1 according to whether the value of expression is negative, zero or positive.
compareTo in interface Comparable<ExtendedSet<T>>o - the object to be compared.ClassCastException - if the specified object's type prevents it from being
compared to this object.Copyright © 2016. All rights reserved.