@Immutable public class LongSortedArraySet extends AbstractLongSortedSet implements java.io.Serializable
A sorted set of longs implemented using a sorted array. It’s much faster than LongArraySet as it is able to use binary searches, while maintaining the space compactness of array-backed sets. Long sorted array sets are immutable.
No orders are supported other than the natural ordering.
| Constructor and Description |
|---|
LongSortedArraySet(java.util.Collection<java.lang.Long> items)
Construct a new array set from a collection of items.
|
LongSortedArraySet(long[] items)
Construct a new array set from an array of items.
|
LongSortedArraySet(SortedKeyIndex ks)
Construct a new long sorted array set from a key domain.
|
| Modifier and Type | Method and Description |
|---|---|
LongComparator |
comparator() |
boolean |
contains(long key) |
long |
firstLong() |
SortedKeyIndex |
getDomain()
Deprecated.
Use
getIndex(). |
SortedKeyIndex |
getIndex()
Get the underlying key index implementation.
|
LongSortedSet |
headSet(long key) |
LongBidirectionalIterator |
iterator() |
LongBidirectionalIterator |
iterator(long key) |
long |
lastLong() |
LongSortedSet |
randomSubset(java.util.Random rng,
int n,
LongSet... exclude)
Compute a random subset of this set.
|
int |
size() |
LongSortedSet |
subSet(long startKey,
long endKey) |
LongSortedSet |
tailSet(long key) |
equals, hashCode, rem, removeadd, add, addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toLongArray, toLongArray, toStringaddAll, clear, containsAll, isEmpty, removeAll, retainAll, toArray, toArrayclone, finalize, getClass, notify, notifyAll, wait, wait, waitfirst, headSet, last, subSet, tailSetadd, contains, rem, remove, removeadd, addAll, containsAll, removeAll, retainAll, toArray, toLongArray, toLongArrayforEach, forEachpublic LongSortedArraySet(@Nonnull
SortedKeyIndex ks)
Construct a new long sorted array set from a key domain.
ks - The key set storage.public LongSortedArraySet(@Nonnull
java.util.Collection<java.lang.Long> items)
Construct a new array set from a collection of items.
items - The set’s contents.public LongSortedArraySet(long[] items)
Construct a new array set from an array of items.
items - The items to initialize the set with. The items are copied, the array is not reused.public SortedKeyIndex getIndex()
Get the underlying key index implementation.
@Deprecated public SortedKeyIndex getDomain()
getIndex().Get the index backing this array set.
public LongComparator comparator()
comparator in interface LongSortedSetcomparator in interface java.util.SortedSet<java.lang.Long>public long firstLong()
firstLong in interface LongSortedSetpublic long lastLong()
lastLong in interface LongSortedSetpublic LongBidirectionalIterator iterator()
iterator in interface LongBidirectionalIterableiterator in interface LongCollectioniterator in interface LongIterableiterator in interface LongSetiterator in interface LongSortedSetiterator in interface java.lang.Iterable<java.lang.Long>iterator in interface java.util.Collection<java.lang.Long>iterator in interface java.util.Set<java.lang.Long>iterator in class AbstractLongSortedSetpublic LongBidirectionalIterator iterator(long key)
iterator in interface LongSortedSetpublic LongSortedSet subSet(long startKey, long endKey)
subSet in interface LongSortedSetpublic LongSortedSet headSet(long key)
headSet in interface LongSortedSetpublic LongSortedSet tailSet(long key)
tailSet in interface LongSortedSetpublic int size()
size in interface java.util.Collection<java.lang.Long>size in interface java.util.Set<java.lang.Long>size in class java.util.AbstractCollection<java.lang.Long>public boolean contains(long key)
contains in interface LongCollectioncontains in class AbstractLongCollectionpublic LongSortedSet randomSubset(java.util.Random rng, int n, LongSet... exclude)
Compute a random subset of this set.
n - The desired set size.exclude - One or more sets of items to exclude.exclude.