| Modifier and Type | Method and Description |
|---|---|
static String |
commaSeparate(Iterable<?> items)
Concatenate the string representation of the items with a comma
separating each item.
|
static <T> String |
commaSeparate(T[] items)
Concatenate the string representation of the items with a comma
separating each item.
|
static <T> T[] |
concat(T[][] arrays)
Concatenates all the arrays in the given order into one array.
|
static int[] |
cons(int item,
int[] array)
Append the item at the start of the array.
|
static <T> List<T> |
cons(T head,
List<? extends T> tail)
Functional-programming cons.
|
static <T> T[] |
cons(T item,
T[] array)
Append the item at the start of the array.
|
static <T> List<T> |
dropUntil(T item,
List<T> list)
Returns a sublist from the index of the item (inclusive) to the end of
the list.
|
static <T> boolean |
endsWith(List<T> string,
List<T> suffix)
Checks if the list ends with specific elements.
|
static boolean |
equals(Object a,
Object b)
Check equality in a null-friendly fashion.
|
static int[] |
falses(boolean[] array)
Returns the position of all the
false elements in the array. |
static int[] |
fromTo(int from,
int to) |
static int |
hashCode(Object o)
Compute a hash code in a null-friendly fashion.
|
static boolean |
in(int item,
int[] array)
Check if the array contains the item at least once.
|
static <T> boolean |
in(T item,
T[] array)
Check if the array contains the item at least once.
|
static String |
intercalate(String separator,
Iterable<?> items)
Concatenate the string representation of the items with a separator
separating each item.
|
static <T> String |
intercalate(String separator,
T[] items)
Concatenate the string representation of the items with a separator
separating each item.
|
static boolean |
isUnique(int[] array)
Check if every element in the array is unique.
|
static <T> boolean |
isUnique(T[] array)
Check if every element in the array is unique.
|
static int[] |
iterate(util.iterators.IntIterator iter)
Enumerate the iterator and return the values discovered.
|
static int |
max(int... array) |
static int |
max(gnu.trove.iterator.TIntIterator iter) |
static int |
min(int... array) |
static int |
min(gnu.trove.iterator.TIntIterator iter) |
static int |
permutation(int n,
int r) |
static <T> T[][] |
permutations(T[] array,
int choose)
Returns all permutations of picking a fixed number of distinct elements
in the array.
|
static int[] |
range(int low,
int high) |
static <T> T[] |
replicate(T item,
int times)
Repeat the item.
|
static void |
reverse(int[] array)
Reverse an array in place.
|
static void |
reverse(int[] array,
int to)
Reverse part of an array in place.
|
static <T> void |
reverse(T[] array)
Reverse an array in place.
|
static <T> void |
reverse(T[] array,
int to)
Reverse part of an array in place.
|
static <T> T[][] |
sequence(T[][] arrays)
Returns all possibilities of picking one element in each array.
|
static <T> T[][] |
sequence(T[] array,
int choose)
Returns all possibilities of picking a fixed number of elements in the
array.
|
static <T> void |
shuffle(T[] array,
Random rand)
Randomly shuffle an array in place.
|
static int[] |
snoc(int[] array,
int item)
Append the item at the end of the array.
|
static <T> List<T> |
snoc(List<? extends T> head,
T tail)
Functional-programming snoc.
|
static <T> T[] |
snoc(T[] array,
T item)
Append the item at the end of the array.
|
static <T> boolean |
startsWith(List<T> string,
List<T> prefix)
Checks if the list starts with specific elements.
|
static int |
sum(int... array) |
static int |
sum(gnu.trove.iterator.TIntIterator iter) |
static <T> List<T> |
takeUntil(T item,
List<T> list)
Returns a sublist from index 0 to the index of the item (inclusive).
|
static int[] |
trues(boolean[] array)
Returns the position of all the
true elements in the array. |
public static boolean equals(Object a, Object b)
a - an objectb - an object to compare with apublic static int hashCode(Object o)
o - the object to compute the hash forpublic static int permutation(int n, int r)
public static int[] range(int low, int high)
low - the lowest integer in the rangehigh - the highest integer in the rangepublic static int[] fromTo(int from, int to)
from - the lowest integer in the rangeto - the integer after the highest integer in the rangepublic static int[] trues(boolean[] array)
true elements in the array. The
positions are returned in sorted order.array - the arraytrue elementspublic static int[] falses(boolean[] array)
false elements in the array. The
positions are returned in sorted order.array - the arrayfalse elementspublic static <T> void shuffle(T[] array, Random rand)
array - the array to shufflerand - the random number generatorpublic static void reverse(int[] array, int to)
array - the array to reverseto - reverse from index 0 to herepublic static void reverse(int[] array)
array - the array to reversepublic static <T> void reverse(T[] array, int to)
T - the type of the elementsarray - the array to reverseto - reverse from index 0 to herepublic static <T> void reverse(T[] array)
T - the type of the elementsarray - the array to reversepublic static boolean in(int item, int[] array)
item - check if this item exists in the arrayarray - the array that may contain the itemtrue if and only if item is in array, false
otherwisepublic static <T> boolean in(T item, T[] array)
T - the type of the elementsitem - check if this item exists in the arrayarray - the array that may contain the itemtrue if and only if item is in array, false
otherwisepublic static boolean isUnique(int[] array)
array - the arraytrue if and only if the elements in the array never
repeat, false otherwisepublic static <T> boolean isUnique(T[] array)
T - the type of the elementsarray - the arraytrue if and only if the elements in the array never
repeat, false otherwisepublic static <T> List<T> cons(T head, List<? extends T> tail)
T - the type of the elementshead - the beginning of the new listtail - the end of the new listpublic static <T> List<T> snoc(List<? extends T> head, T tail)
T - the type of the elementshead - the beginning of the new listtail - the end of the new listpublic static <T> T[] cons(T item, T[] array)
T - the type of the elementsitem - the beginning of the new arrayarray - the end of the new arraypublic static <T> T[] snoc(T[] array, T item)
T - the type of the elementsarray - the beginning of the new arrayitem - the end of the new arraypublic static int[] cons(int item, int[] array)
item - the beginning of the new arrayarray - the end of the new arraypublic static int[] snoc(int[] array, int item)
array - the beginning of the new arrayitem - the end of the new arraypublic static <T> T[] concat(T[][] arrays)
T - the type of the elementsarrays - the array of arrayspublic static <T> T[] replicate(T item, int times)
T - the type of the itemitem - the itemtimes - the number of times to repeatpublic static <T> T[][] permutations(T[] array, int choose)
T - the type of the elementsarray - the arraychoose - the number of elements to pickpublic static <T> T[][] sequence(T[] array, int choose)
T - the type of the elementsarray - the arraychoose - the number of elements to pickpublic static <T> T[][] sequence(T[][] arrays)
sequence for lists, except for edge cases.T - the type of the elementsarrays - the arrayspublic static <T> List<T> takeUntil(T item, List<T> list)
takeWhile (== item) listT - the element typeitem - the item to findlist - the list of itemslist ending at the first item if
found, otherwise the entire listpublic static <T> List<T> dropUntil(T item, List<T> list)
dropWhile (/= item) listT - the element typeitem - the item to findlist - the list of itemslist starting at the first item
if found, otherwise the entire listpublic static <T> boolean startsWith(List<T> string, List<T> prefix)
T - the element typestring - the listprefix - the starting elements of the listtrue if and only if string starts with prefix,
false otherwisepublic static <T> boolean endsWith(List<T> string, List<T> suffix)
T - the element typestring - the listsuffix - the ending elements of the listtrue if and only if string ends with suffix,
false otherwisepublic static int sum(int... array)
array - an array of integerspublic static int sum(gnu.trove.iterator.TIntIterator iter)
iter - an iterator of integerspublic static int min(int... array)
array - an array of integerspublic static int min(gnu.trove.iterator.TIntIterator iter)
iter - an iterator of integerspublic static int max(int... array)
array - an array of integerspublic static int max(gnu.trove.iterator.TIntIterator iter)
iter - an iterator of integerspublic static int[] iterate(util.iterators.IntIterator iter)
iter - an iteratorpublic static <T> String commaSeparate(T[] items)
T - the type of the elementsitems - the items to displaypublic static String commaSeparate(Iterable<?> items)
items - the items to displaypublic static <T> String intercalate(String separator, T[] items)
T - the type of the elementsseparator - the string to separate each itemitems - the items to displaypublic static String intercalate(String separator, Iterable<?> items)
separator - the string to separate each itemitems - the items to displayCopyright © 2013. All Rights Reserved.