T - the type of elements maintained by this setpublic abstract class AbstractExtendedSet<T> extends AbstractSet<T> implements ExtendedSet<T>
ExtendedSet
interface to minimize the effort required to implement this interface.
The process of implementing a set by extending this class is very similar,
for example, to that of implementing a Collection by extending
AbstractCollection.
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractExtendedSet.ExtendedSubSet
Used by
AbstractExtendedSet#headSet(T) , AbstractExtendedSet#tailSet(T) and AbstractExtendedSet#subSet(T,T) to offer a restricted view of the entire set |
protected class |
AbstractExtendedSet.FilteredSet
Base class for
AbstractExtendedSet.ExtendedSubSet and AbstractExtendedSet.UnmodifiableExtendedSet |
protected class |
AbstractExtendedSet.UnmodifiableExtendedSet
Read-only view of the set.
|
ExtendedSet.ExtendedIterator<X>| Constructor and Description |
|---|
AbstractExtendedSet() |
| Modifier and Type | Method and Description |
|---|---|
abstract 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 |
abstract double |
collectionCompressionRatio()
|
int |
compareTo(ExtendedSet<T> o)
Compares this object with the specified object for order.
|
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.
|
abstract 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. |
T |
first() |
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.
|
abstract 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.
|
T |
last() |
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.
|
equals, hashCode, removeAlladd, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, size, toArray, toArray, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitcomplementcomparatorpublic ExtendedSet<T> intersection(Collection<? extends T> other)
intersection in interface ExtendedSet<T>other - ExtendedSet instance that represents the right
operandSet.retainAll(java.util.Collection)public ExtendedSet<T> union(Collection<? extends T> other)
union in interface ExtendedSet<T>other - ExtendedSet instance that represents the right
operandSet.addAll(java.util.Collection)public ExtendedSet<T> difference(Collection<? extends T> other)
difference in interface ExtendedSet<T>other - ExtendedSet instance that represents the right
operandSet.removeAll(java.util.Collection)public ExtendedSet<T> symmetricDifference(Collection<? extends T> other)
symmetricDifference in interface ExtendedSet<T>other - ExtendedSet instance that represents the right
operandExtendedSet.flip(Object)public ExtendedSet<T> complemented()
SortedSet.last() that do not exist in the
current set.complemented in interface ExtendedSet<T>ExtendedSet.complement()public boolean containsAny(Collection<? extends T> other)
true if the specified Collection instance
contains any elements that are also contained within this
ExtendedSet instancecontainsAny in interface ExtendedSet<T>other - ExtendedSet to intersect withExtendedSet intersects
the specified ExtendedSet.public 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 instancecontainsAtLeast in interface ExtendedSet<T>other - Collection instance to intersect withminElements - minimum number of elements to be contained within this
ExtendedSet instanceExtendedSet intersects
the specified Collection.public int intersectionSize(Collection<? extends T> other)
This is faster than calling ExtendedSet.intersection(Collection) and
then Set.size()
intersectionSize in interface ExtendedSet<T>other - Collection instance that represents the right
operandpublic int unionSize(Collection<? extends T> other)
This is faster than calling ExtendedSet.union(Collection) and then
Set.size()
unionSize in interface ExtendedSet<T>other - Collection instance that represents the right
operandpublic int symmetricDifferenceSize(Collection<? extends T> other)
This is faster than calling
ExtendedSet.symmetricDifference(Collection) and then Set.size()
symmetricDifferenceSize in interface ExtendedSet<T>other - Collection instance that represents the right
operandpublic int differenceSize(Collection<? extends T> other)
This is faster than calling ExtendedSet.difference(Collection) and
then Set.size()
differenceSize in interface ExtendedSet<T>other - Collection instance that represents the right
operandpublic int complementSize()
This is faster than calling ExtendedSet.complemented() and then
Set.size()
complementSize in interface ExtendedSet<T>public abstract ExtendedSet<T> empty()
empty in interface ExtendedSet<T>public ExtendedSet<T> headSet(T toElement)
public ExtendedSet<T> subSet(T fromElement, T toElement)
public ExtendedSet<T> tailSet(T fromElement)
public ExtendedSet<T> clone()
clone() of Object
NOTE: When overriding this method, please note that
Object.clone() is much slower then performing
new and "manually" copying data!
clone in interface ExtendedSet<T>clone in class Objectpublic abstract double bitmapCompressionRatio()
BitSet, 2 means twice the size of BitSet, etc.)bitmapCompressionRatio in interface ExtendedSet<T>public abstract double collectionCompressionRatio()
ArrayList, 2 means twice the size of ArrayList, etc.)collectionCompressionRatio in interface ExtendedSet<T>public ExtendedSet.ExtendedIterator<T> descendingIterator()
TdescendingIterator in interface ExtendedSet<T>public Iterable<T> descending()
descending in interface ExtendedSet<T>Iterable instance to iterate items in descending
orderpublic List<? 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 in interface ExtendedSet<T>ExtendedSet.powerSet(int, int),
ExtendedSet.powerSetSize()public 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.
powerSet in interface ExtendedSet<T>min - minimum subset size (greater than zero)max - maximum subset sizeExtendedSet.powerSet(),
ExtendedSet.powerSetSize(int, int)public int powerSetSize()
The power-set does not contains the empty set.
powerSetSize in interface ExtendedSet<T>ExtendedSet.powerSet()public int powerSetSize(int min,
int max)
min and max.
The returned power-set does not contain the empty set.
powerSetSize in interface ExtendedSet<T>min - minimum subset size (greater than zero)max - maximum subset sizeExtendedSet.powerSet(int, int)public 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 ExtendedSet<T>compareTo in interface Comparable<ExtendedSet<T>>o - the object to be compared.public void 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.fill in interface ExtendedSet<T>from - first elementto - last elementpublic void 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.clear in interface ExtendedSet<T>from - first elementto - last elementpublic void flip(T e)
flip in interface ExtendedSet<T>e - element to flipExtendedSet.symmetricDifference(Collection)public T get(int i)
ith element of the setget in interface ExtendedSet<T>i - position of the element in the sorted setith element of the setpublic int indexOf(T e)
It returns -1 if the element does not exist within the set.
indexOf in interface ExtendedSet<T>e - element of the setpublic ExtendedSet<T> unmodifiable()
unmodifiable in interface ExtendedSet<T>public abstract ExtendedSet.ExtendedIterator<T> iterator()
iterator in interface ExtendedSet<T>iterator in interface Iterable<T>iterator in interface Collection<T>iterator in interface Set<T>iterator in class AbstractCollection<T>public double jaccardSimilarity(ExtendedSet<T> other)
The coefficient is defined as
|A intersection B| / |A union B|.
jaccardSimilarity in interface ExtendedSet<T>other - the other setExtendedSet.jaccardDistance(ExtendedSet)public double jaccardDistance(ExtendedSet<T> other)
The coefficient is defined as
1 - ExtendedSet.jaccardSimilarity(ExtendedSet).
jaccardDistance in interface ExtendedSet<T>other - the other setExtendedSet.jaccardSimilarity(ExtendedSet)public 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.
weightedJaccardSimilarity in interface ExtendedSet<T>other - the other setExtendedSet.weightedJaccardDistance(ExtendedSet)public double weightedJaccardDistance(ExtendedSet<T> other)
The coefficient is defined as 1 -
ExtendedSet.weightedJaccardSimilarity(ExtendedSet).
NOTE: T must be a number, namely one of
Integer, Double, Float, Byte,
Long, Short.
weightedJaccardDistance in interface ExtendedSet<T>other - the other setExtendedSet.weightedJaccardSimilarity(ExtendedSet)public ExtendedSet<T> convert(Object... e)
convert in interface ExtendedSet<T>e - objects to use to generate the new instanceExtendedSet.convert(Collection)public 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.convert in interface ExtendedSet<T>c - collection to use to generate the new instanceExtendedSet.convert(Object...)public String debugInfo()
ExtendedSet implementationdebugInfo in interface ExtendedSet<T>Copyright © 2016. All rights reserved.