public class LongSet extends Object implements Cloneable, Comparable<LongSet>, Serializable, Iterable<Long>
ExtendedSet but for the primitive long type.| Modifier and Type | Class and Description |
|---|---|
class |
LongSet.ExtendedLongIterator
A
Iterator -like interface that allows to "skip" some elements of the set |
| Constructor and Description |
|---|
LongSet(IntSet block)
Creates an empty set
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(long i)
Adds the specified element to this set if it is not already present.
|
boolean |
addAll(LongSet other)
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(long from,
long to)
Removes from the set all the elements between
first and
last, both included. |
LongSet |
clone()
See the
clone() of Object |
double |
collectionCompressionRatio()
|
int |
compareTo(LongSet o) |
void |
complement()
Complements the current set.
|
LongSet |
complemented()
Generates the complement set.
|
long |
complementSize()
Computes the complement set size.
|
boolean |
contains(long i)
Returns true if this set contains the specified element.
|
boolean |
containsAll(LongSet other)
Returns true if this set contains all of the elements of the
specified collection.
|
boolean |
containsAny(LongSet other)
|
boolean |
containsAtLeast(LongSet other,
long minElements)
|
LongSet |
convert(Collection<Long> a)
Converts a given array into an instance of the current class.
|
LongSet |
convert(long... a)
Converts a given array into an instance of the current class.
|
String |
debugInfo()
Prints debug info about the given
LongSet implementation |
LongSet.ExtendedLongIterator |
descendingLongIterator() |
LongSet |
difference(LongSet other)
Generates the difference set
|
long |
differenceSize(LongSet other)
Computes the difference set size.
|
LongSet |
empty()
Generates an empty set
|
IntSet |
emptyBlock() |
boolean |
equals(Object obj) |
void |
fill(long from,
long to)
Adds to the set all the elements between
first and
last, both included. |
long |
first()
Returns the first (lowest) element currently in this set.
|
void |
flip(long e)
Adds the element if it not existing, or removes it if existing
|
long |
get(long index)
Gets the
ith element of the set |
int |
hashCode() |
long |
indexOf(long i)
Provides position of element within the set.
|
LongSet |
intersection(LongSet other)
Generates the intersection set
|
long |
intersectionSize(LongSet other)
Computes the intersection set size.
|
boolean |
isEmpty() |
Iterator<Long> |
iterator() |
long |
last()
Returns the last (highest) element currently in this set.
|
LongSet.ExtendedLongIterator |
longIterator() |
boolean |
remove(long i)
Removes the specified element from this set if it is present.
|
boolean |
removeAll(LongSet other)
Removes from this set all of its elements that are contained in the
specified collection.
|
boolean |
retainAll(LongSet other)
Retains only the elements in this set that are contained in the specified
collection.
|
long |
size() |
LongSet |
symmetricDifference(LongSet other)
Generates the symmetric difference set
|
long |
symmetricDifferenceSize(LongSet other)
Computes the symmetric difference set size.
|
long[] |
toArray() |
long[] |
toArray(long[] a)
Returns an array containing all of the elements in this set.
|
String |
toString() |
LongSet |
union(LongSet other)
Generates the union set
|
long |
unionSize(LongSet other)
Computes the union set size.
|
public IntSet emptyBlock()
IntSet instance of the same type of that of
internally used to represent integerspublic boolean retainAll(LongSet other)
other - 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(long)public LongSet intersection(LongSet other)
other - LongSet instance that represents the right
operandretainAll(LongSet)public boolean addAll(LongSet other)
other - 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(long)public LongSet union(LongSet other)
other - LongSet instance that represents the right
operandaddAll(LongSet)public boolean removeAll(LongSet other)
other - 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(long),
contains(long)public LongSet difference(LongSet other)
other - LongSet instance that represents the right
operandremoveAll(LongSet)public LongSet symmetricDifference(LongSet other)
other - LongSet instance that represents the right
operandflip(long)public LongSet complemented()
last() that do not exist in the
current set.complement()public void complement()
last() that do not exist in the
current set.complemented()public long intersectionSize(LongSet other)
This is faster than calling intersection(LongSet) and
then size()
other - LongSet instance that represents the right
operandpublic long unionSize(LongSet other)
This is faster than calling union(LongSet) and then
size()
other - LongSet instance that represents the right
operandpublic long symmetricDifferenceSize(LongSet other)
This is faster than calling symmetricDifference(LongSet)
and then size()
other - LongSet instance that represents the right
operandpublic long differenceSize(LongSet other)
This is faster than calling difference(LongSet) and then
size()
other - LongSet instance that represents the right
operandpublic long complementSize()
This is faster than calling complemented() and then
size()
public LongSet empty()
public double bitmapCompressionRatio()
BitSet, 2 means twice the size of BitSet, etc.)public double collectionCompressionRatio()
ArrayList, 2 means twice the size of ArrayList, etc.)public LongSet.ExtendedLongIterator longIterator()
LongSet.ExtendedLongIterator instance to iterate over the setpublic LongSet.ExtendedLongIterator descendingLongIterator()
LongSet.ExtendedLongIterator instance to iterate over the set in
descending orderpublic String debugInfo()
LongSet implementationpublic void fill(long from,
long to)
first and
last, both included.from - first elementto - last elementpublic void clear(long from,
long to)
first and
last, both included.from - first elementto - last elementpublic void flip(long e)
e - element to flipsymmetricDifference(LongSet)public long get(long index)
ith element of the setindex - position of the element in the sorted setith element of the setIndexOutOfBoundsException - if i is less than zero, or greater or equal to
size()public long indexOf(long i)
It returns -1 if the element does not exist within the set.
i - element of the setpublic LongSet convert(long... a)
a - array to use to generate the new instancepublic LongSet convert(Collection<Long> a)
a - array to use to generate the new instancepublic long first()
NoSuchElementException - if this set is emptypublic long last()
NoSuchElementException - if this set is emptypublic long size()
public boolean isEmpty()
public boolean contains(long i)
i - element whose presence in this set is to be testedpublic boolean add(long i)
i - element to be added to this setIllegalArgumentException - if some property of the specified element prevents it from
being added to this setpublic boolean remove(long i)
i - object to be removed from this set, if presentUnsupportedOperationException - if the remove operation is not supported by this setpublic boolean containsAll(LongSet other)
other - 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(long)public boolean containsAny(LongSet other)
public boolean containsAtLeast(LongSet other, long minElements)
true if the specified LongSet
instance contains at least minElements elements that are
also contained within this LongSet instanceother - LongSet instance to intersect withminElements - minimum number of elements to be contained within this
LongSet instanceLongSet
intersects the specified LongSet.IllegalArgumentException - if minElements < 1public void clear()
public long[] toArray()
public long[] toArray(long[] 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 arraypublic int compareTo(LongSet o)
compareTo in interface Comparable<LongSet>Copyright © 2016. All rights reserved.