public final class Ints extends Object
IntRanges
,
IntSets
, and SparseSequences
.
The methods in this class all throw a NullPointerException if given a null reference unless otherwise specified.
Modifier and Type | Field and Description |
---|---|
static SparseSequence<?> |
EMPTY_SEQUENCE
An immutable empty sequence.
|
static IntSet |
EMPTY_SET
An immutable empty int set.
|
Modifier and Type | Method and Description |
---|---|
static IntVector |
asIntVector(int[] ints)
Returns an unmodifiable IntArray backed by the given array of integers.
|
static IntSet |
asSet(int[] ints)
Returns an IntSet that is backed by the given array of integers.
|
static IntSet |
bestSet(int max)
Returns an implementation of the int set interface
that offers the best time/space trade-off for a
set that can store all elements in the half open
range [0..max).
|
static IntSet |
bestSet(int min,
int max)
Returns an implementation of the int set interface
that offers the best time/space trade-off for a
set that can store all elements in the closed range [min..max].
|
static <V> SparseSequence<V> |
emptySequence()
Returns EMPTY_SEQUENCE cast to a sequence of type SparseSequence
|
static IntRange |
merge(IntRange r1,
IntRange r2)
Returns the smallest IntRange r that contains
both r1 and r2.
|
static IntVector |
nCopies(int n,
int elt)
Returns an unmodifiable IntArray of length n which contains the given
element at each position.
|
static IntRange |
range(int min,
int max)
Returns an integer range from min, inclusive, to max, inclusive.
|
static IntSet |
rangeSet(IntRange range)
Returns an unmodifiable IntSet that contains
all the elements in the given range.
|
static IntSet |
singleton(int i)
Returns an unmodifiable IntSet whose sole
element is the given integer.
|
static int |
superFastHash(int... key)
An implementation of Paul Hsieh's hashing function,
described at http://www.azillionmonkeys.com/qed/hash.html.
|
static int |
superFastHash(int key)
An implementation of Paul Hsieh's hashing function,
described at http://www.azillionmonkeys.com/qed/hash.html.
|
static int |
superFastHash(Object... key)
An implementation of Paul Hsieh's hashing function,
described at http://www.azillionmonkeys.com/qed/hash.html.
|
static int |
superFastHashAvalanche(int hash)
Performs the bit avalanching step of Paul Hsieh's
hashing function (http://www.azillionmonkeys.com/qed/hash.html)
|
static int |
superFastHashIncremental(int key,
int hash)
Performs the hashing step of Paul Hsieh's hashing function,
described at http://www.azillionmonkeys.com/qed/hash.html.
|
static IntSet |
unmodifiableIntSet(IntSet s)
Returns an unmodifiable view of the specified set.
|
static <V> SparseSequence<V> |
unmodifiableSequence(SparseSequence<V> s)
Returns an unmodifiable view of the specified sparse sequence.
|
public static final SparseSequence<?> EMPTY_SEQUENCE
public static final IntSet EMPTY_SET
public static IntVector asIntVector(int[] ints)
public static IntSet asSet(int[] ints)
all i, j: [0..ints.length) | i < j => array[i] <= Sarray[j]
public static IntSet bestSet(int max)
public static IntSet bestSet(int min, int max)
IllegalArgumentException
- min > maxpublic static <V> SparseSequence<V> emptySequence()
public static IntRange merge(IntRange r1, IntRange r2)
NullPointerException
- range = nullpublic static IntVector nCopies(int n, int elt)
public static IntRange range(int min, int max)
IllegalArgumentException
- min > maxpublic static IntSet rangeSet(IntRange range)
public static IntSet singleton(int i)
public static int superFastHash(int... key)
public static int superFastHash(int key)
public static int superFastHash(Object... key)
public static int superFastHashAvalanche(int hash)
public static int superFastHashIncremental(int key, int hash)
public static IntSet unmodifiableIntSet(IntSet s)
NullPointerException
- s = nullpublic static <V> SparseSequence<V> unmodifiableSequence(SparseSequence<V> s)
NullPointerException
- s = null
© Emina Torlak 2005-present