|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkodkod.util.collections.Containers
public final class Containers
Provides utility methods for working with arrays and collections.
Method Summary | ||
---|---|---|
static
|
asHashSet(T[] array)
Returns a set backed by the given array (i.e. |
|
static
|
asIdentitySet(T[] array)
Returns an identity set backed by the given array (i.e. |
|
static
|
emptyIterator()
Returns an iterator that has no elements. |
|
static int |
hashBinarySearch(java.lang.Object[] array,
java.lang.Object key)
Searches the specified array for the specified object using the binary search algorithm and object equality. |
|
static java.util.Comparator<java.lang.Object> |
hashComparator()
Returns a comparator that compares objects according to their hashcodes . |
|
static
|
hashSort(T[] array)
Calls Arrays.sort(Object[], Comparator) on the
given array and returns it. |
|
static int |
identityBinarySearch(java.lang.Object[] array,
java.lang.Object key)
Searches the specified array for the specified object using the binary search algorithm and reference equality. |
|
static java.util.Comparator<java.lang.Object> |
identityComparator()
Returns a comparator that compares objects according to their identity hashcodes . |
|
static
|
identitySort(T[] array)
Calls Arrays.sort(Object[], Comparator) on the
given array and returns it. |
|
static
|
iterate(E... items)
Returns a new iterator over the given array of items. |
|
static
|
iterate(int start,
int end,
E... items)
Returns a new iterator over the given array of items. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static final <T,E extends T> java.util.Iterator<T> iterate(E... items)
java.lang.NullPointerException
- - items = nullpublic static final <T,E extends T> java.util.Iterator<T> iterate(int start, int end, E... items)
java.lang.NullPointerException
- - items = null
java.lang.IllegalArgumentException
- - start < end && (start < 0 || end > items.length) ||
start > end && (start >= items.length || end < -1)public static final <T> java.util.Iterator<T> emptyIterator()
public static final java.util.Comparator<java.lang.Object> identityComparator()
identity hashcodes
.
identity hashcodes
.public static final java.util.Comparator<java.lang.Object> hashComparator()
hashcodes
. The null reference is
considered to have a hashcode of 0.
hashcodes
.public static final <T> T[] identitySort(T[] array)
Arrays.sort(Object[], Comparator)
on the
given array and returns it. The elements are sorted in the ascending
order of their identity hashcodes.
java.util.Arrays.sort(array, {@link #identityComparator()}) |
public static final <T> T[] hashSort(T[] array)
Arrays.sort(Object[], Comparator)
on the
given array and returns it. The elements are sorted in the ascending
order of their hashcodes.
java.util.Arrays.sort(array, {@link #hashComparator()}) |
public static final int identityBinarySearch(java.lang.Object[] array, java.lang.Object key)
identitySort(Object[])
) prior to making this call. If it is not sorted,
the results are undefined. If the array contains multiple occurences of the specified object,
there is no guarantee which one will be found.
all i, j: [0..array.length) | i < j => array[i].hashCode() <= array[j].hashCode()) |
public static final int hashBinarySearch(java.lang.Object[] array, java.lang.Object key)
hashSort(Object[])
) prior to making this call. If it is not sorted,
the results are undefined. If the array contains multiple occurences of the specified object,
there is no guarantee which one will be found.
all i, j: [0..array.length) | i < j => System.identityHashCode(array[i]) <= System.identityHashCode(array[j]) |
public static final <T> java.util.Set<T> asIdentitySet(T[] array)
identitySort(Object[])
), and its contents
must not be changed while it is in use by the returned set.
all i, j: [0..array.length) | i < j => System.identityHashCode(array[i]) <= System.identityHashCode(array[j]) |
public static final <T> java.util.Set<T> asHashSet(T[] array)
hashSort(Object[])
), and its contents
must not be changed while it is in use by the returned set.
all i, j: [0..array.length) | i < j => array[i].hashCode() <= array[j].hashCode |
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |