public class IntegerSet extends AbstractExtendedSet<Integer>
IntSet instance in order to be used as an ExtendedSet instance.AbstractExtendedSet.ExtendedSubSet, AbstractExtendedSet.FilteredSet, AbstractExtendedSet.UnmodifiableExtendedSetExtendedSet.ExtendedIterator<X>| Constructor and Description |
|---|
IntegerSet(IntSet items)
Wraps an instance of
IntSet |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Integer e) |
boolean |
addAll(Collection<? extends Integer> c) |
double |
bitmapCompressionRatio()
|
void |
clear() |
void |
clear(Integer from,
Integer to)
Removes from the set all the elements between
first and
last, both included. |
IntegerSet |
clone()
See the
clone() of Object |
double |
collectionCompressionRatio()
|
Comparator<? super Integer> |
comparator() |
int |
compareTo(ExtendedSet<Integer> o)
Compares this object with the specified object for order.
|
void |
complement()
Complements the current set.
|
IntegerSet |
complemented()
Generates the complement set.
|
int |
complementSize()
Computes the complement set size.
|
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
containsAny(Collection<? extends Integer> other)
Returns
true if the specified Collection instance
contains any elements that are also contained within this
ExtendedSet instance |
boolean |
containsAtLeast(Collection<? extends Integer> other,
int minElements)
Returns
true if the specified Collection instance
contains at least minElements elements that are also
contained within this ExtendedSet instance |
IntegerSet |
convert(Collection<?> c)
Converts a given
Collection instance into an instance of the
current class. |
IntegerSet |
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 |
ExtendedSet.ExtendedIterator<Integer> |
descendingIterator()
Gets the descending order iterator over the elements of type
T |
IntegerSet |
difference(Collection<? extends Integer> other)
Generates the difference set
|
int |
differenceSize(Collection<? extends Integer> other)
Computes the difference set size.
|
IntegerSet |
empty()
Generates an empty set
|
boolean |
equals(Object o) |
void |
fill(Integer from,
Integer to)
Adds to the set all the elements between
first and
last, both included. |
Integer |
first() |
void |
flip(Integer e)
Adds the element if it not existing, or removes it if existing
|
Integer |
get(int i)
Gets the
ith element of the set |
int |
hashCode() |
int |
indexOf(Integer e)
Provides position of element within the set.
|
IntegerSet |
intersection(Collection<? extends Integer> other)
Generates the intersection set
|
int |
intersectionSize(Collection<? extends Integer> other)
Computes the intersection set size.
|
IntSet |
intSet() |
boolean |
isEmpty() |
ExtendedSet.ExtendedIterator<Integer> |
iterator() |
double |
jaccardSimilarity(ExtendedSet<Integer> other)
Computes the Jaccard similarity coefficient between this set and the
given set.
|
Integer |
last() |
List<? extends IntegerSet> |
powerSet()
Computes the power-set of the current set.
|
List<? extends IntegerSet> |
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. |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
IntegerSet |
symmetricDifference(Collection<? extends Integer> other)
Generates the symmetric difference set
|
int |
symmetricDifferenceSize(Collection<? extends Integer> other)
Computes the symmetric difference set size.
|
String |
toString() |
IntegerSet |
union(Collection<? extends Integer> other)
Generates the union set
|
int |
unionSize(Collection<? extends Integer> other)
Computes the union set size.
|
double |
weightedJaccardSimilarity(ExtendedSet<Integer> other)
Computes the weighted version of the Jaccard similarity coefficient
between this set and the given set.
|
descending, headSet, jaccardDistance, powerSetSize, powerSetSize, subSet, tailSet, unmodifiable, weightedJaccardDistancetoArray, toArraypublic IntSet intSet()
public boolean addAll(Collection<? extends Integer> c)
addAll in interface Collection<Integer>addAll in interface Set<Integer>addAll in class AbstractCollection<Integer>public double bitmapCompressionRatio()
BitSet, 2 means twice the size of BitSet, etc.)bitmapCompressionRatio in interface ExtendedSet<Integer>bitmapCompressionRatio in class AbstractExtendedSet<Integer>public void clear(Integer from, Integer 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<Integer>clear in class AbstractExtendedSet<Integer>from - first elementto - last elementpublic IntegerSet 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<Integer>clone in class AbstractExtendedSet<Integer>public double collectionCompressionRatio()
ArrayList, 2 means twice the size of ArrayList, etc.)collectionCompressionRatio in interface ExtendedSet<Integer>collectionCompressionRatio in class AbstractExtendedSet<Integer>public int compareTo(ExtendedSet<Integer> 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<Integer>compareTo in interface Comparable<ExtendedSet<Integer>>compareTo in class AbstractExtendedSet<Integer>o - the object to be compared.public IntegerSet complemented()
SortedSet.last() that do not exist in the
current set.complemented in interface ExtendedSet<Integer>complemented in class AbstractExtendedSet<Integer>ExtendedSet.complement()public int complementSize()
This is faster than calling ExtendedSet.complemented() and then
Set.size()
complementSize in interface ExtendedSet<Integer>complementSize in class AbstractExtendedSet<Integer>public boolean containsAny(Collection<? extends Integer> other)
true if the specified Collection instance
contains any elements that are also contained within this
ExtendedSet instancecontainsAny in interface ExtendedSet<Integer>containsAny in class AbstractExtendedSet<Integer>other - ExtendedSet to intersect withExtendedSet intersects
the specified ExtendedSet.public boolean containsAtLeast(Collection<? extends Integer> 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<Integer>containsAtLeast in class AbstractExtendedSet<Integer>other - Collection instance to intersect withminElements - minimum number of elements to be contained within this
ExtendedSet instanceExtendedSet intersects
the specified Collection.public IntegerSet 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<Integer>convert in class AbstractExtendedSet<Integer>c - collection to use to generate the new instanceExtendedSet.convert(Object...)public IntegerSet convert(Object... e)
convert in interface ExtendedSet<Integer>convert in class AbstractExtendedSet<Integer>e - objects to use to generate the new instanceExtendedSet.convert(Collection)public String debugInfo()
ExtendedSet implementationdebugInfo in interface ExtendedSet<Integer>debugInfo in class AbstractExtendedSet<Integer>public ExtendedSet.ExtendedIterator<Integer> descendingIterator()
TdescendingIterator in interface ExtendedSet<Integer>descendingIterator in class AbstractExtendedSet<Integer>public IntegerSet difference(Collection<? extends Integer> other)
difference in interface ExtendedSet<Integer>difference in class AbstractExtendedSet<Integer>other - ExtendedSet instance that represents the right
operandSet.removeAll(java.util.Collection)public int differenceSize(Collection<? extends Integer> other)
This is faster than calling ExtendedSet.difference(Collection) and
then Set.size()
differenceSize in interface ExtendedSet<Integer>differenceSize in class AbstractExtendedSet<Integer>other - Collection instance that represents the right
operandpublic IntegerSet empty()
empty in interface ExtendedSet<Integer>empty in class AbstractExtendedSet<Integer>public boolean equals(Object o)
equals in interface Collection<Integer>equals in interface Set<Integer>equals in class AbstractSet<Integer>public void fill(Integer from, Integer 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<Integer>fill in class AbstractExtendedSet<Integer>from - first elementto - last elementpublic Integer first()
public void flip(Integer e)
flip in interface ExtendedSet<Integer>flip in class AbstractExtendedSet<Integer>e - element to flipExtendedSet.symmetricDifference(Collection)public Integer get(int i)
ith element of the setget in interface ExtendedSet<Integer>get in class AbstractExtendedSet<Integer>i - position of the element in the sorted setith element of the setpublic int indexOf(Integer e)
It returns -1 if the element does not exist within the set.
indexOf in interface ExtendedSet<Integer>indexOf in class AbstractExtendedSet<Integer>e - element of the setpublic IntegerSet intersection(Collection<? extends Integer> other)
intersection in interface ExtendedSet<Integer>intersection in class AbstractExtendedSet<Integer>other - ExtendedSet instance that represents the right
operandSet.retainAll(java.util.Collection)public int intersectionSize(Collection<? extends Integer> other)
This is faster than calling ExtendedSet.intersection(Collection) and
then Set.size()
intersectionSize in interface ExtendedSet<Integer>intersectionSize in class AbstractExtendedSet<Integer>other - Collection instance that represents the right
operandpublic ExtendedSet.ExtendedIterator<Integer> iterator()
iterator in interface ExtendedSet<Integer>iterator in interface Iterable<Integer>iterator in interface Collection<Integer>iterator in interface Set<Integer>iterator in class AbstractExtendedSet<Integer>public Integer last()
public List<? extends IntegerSet> 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<Integer>powerSet in class AbstractExtendedSet<Integer>ExtendedSet.powerSet(int, int),
ExtendedSet.powerSetSize()public List<? extends IntegerSet> 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<Integer>powerSet in class AbstractExtendedSet<Integer>min - minimum subset size (greater than zero)max - maximum subset sizeExtendedSet.powerSet(),
ExtendedSet.powerSetSize(int, int)public boolean removeAll(Collection<?> c)
removeAll in interface Collection<Integer>removeAll in interface Set<Integer>removeAll in class AbstractSet<Integer>public boolean retainAll(Collection<?> c)
retainAll in interface Collection<Integer>retainAll in interface Set<Integer>retainAll in class AbstractCollection<Integer>public IntegerSet symmetricDifference(Collection<? extends Integer> other)
symmetricDifference in interface ExtendedSet<Integer>symmetricDifference in class AbstractExtendedSet<Integer>other - ExtendedSet instance that represents the right
operandExtendedSet.flip(Object)public int symmetricDifferenceSize(Collection<? extends Integer> other)
This is faster than calling
ExtendedSet.symmetricDifference(Collection) and then Set.size()
symmetricDifferenceSize in interface ExtendedSet<Integer>symmetricDifferenceSize in class AbstractExtendedSet<Integer>other - Collection instance that represents the right
operandpublic IntegerSet union(Collection<? extends Integer> other)
union in interface ExtendedSet<Integer>union in class AbstractExtendedSet<Integer>other - ExtendedSet instance that represents the right
operandSet.addAll(java.util.Collection)public int unionSize(Collection<? extends Integer> other)
This is faster than calling ExtendedSet.union(Collection) and then
Set.size()
unionSize in interface ExtendedSet<Integer>unionSize in class AbstractExtendedSet<Integer>other - Collection instance that represents the right
operandpublic int hashCode()
hashCode in interface Collection<Integer>hashCode in interface Set<Integer>hashCode in class AbstractSet<Integer>public void complement()
SortedSet.last() that do not exist in the
current set.ExtendedSet.complemented()public Comparator<? super Integer> comparator()
public boolean add(Integer e)
add in interface Collection<Integer>add in interface Set<Integer>add in class AbstractCollection<Integer>public void clear()
clear in interface Collection<Integer>clear in interface Set<Integer>clear in class AbstractCollection<Integer>public boolean contains(Object o)
contains in interface Collection<Integer>contains in interface Set<Integer>contains in class AbstractCollection<Integer>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<Integer>containsAll in interface Set<Integer>containsAll in class AbstractCollection<Integer>public boolean isEmpty()
isEmpty in interface Collection<Integer>isEmpty in interface Set<Integer>isEmpty in class AbstractCollection<Integer>public boolean remove(Object o)
remove in interface Collection<Integer>remove in interface Set<Integer>remove in class AbstractCollection<Integer>public int size()
size in interface Collection<Integer>size in interface Set<Integer>size in class AbstractCollection<Integer>public String toString()
toString in class AbstractCollection<Integer>public double jaccardSimilarity(ExtendedSet<Integer> other)
The coefficient is defined as
|A intersection B| / |A union B|.
jaccardSimilarity in interface ExtendedSet<Integer>jaccardSimilarity in class AbstractExtendedSet<Integer>other - the other setExtendedSet.jaccardDistance(ExtendedSet)public double weightedJaccardSimilarity(ExtendedSet<Integer> 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<Integer>weightedJaccardSimilarity in class AbstractExtendedSet<Integer>other - the other setExtendedSet.weightedJaccardDistance(ExtendedSet)Copyright © 2016. All rights reserved.