Overview
This class contains various functions for manipulating sequences (such as sorting and searching). All of these functions are nonmutative, they do not change the input-parameters, but create new instances for output.
Profile: common
Inherited Attributes
Function Summary
- public static binarySearch(seq: java.lang.Comparable[], key: java.lang.Comparable) : Integer
-
Searches the specified sequence for the specified object using the binary search algorithm.
More: [+]Searches the specified sequence for the specified object using the binary search algorithm. The sequence must be sorted into ascending order according to the natural ordering of its elements (as by the sort(Sequence
) method) prior to making this call. If it is not sorted, the results are undefined. If the array contains multiple elements equal to the specified object, there is no guarantee which one will be found. -
Parameters
- seq
- The sequence to be searched.
- key
- The value to be searched for.
-
Returns
- Integer
- Index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.
Profile: common
- public static binarySearch(seq: java.lang.Object[], key: java.lang.Object, c: java.util.Comparator) : Integer
-
Searches the specified array for the specified object using the binary search algorithm.
More: [+]Searches the specified array for the specified object using the binary search algorithm. The array must be sorted into ascending order according to the specified comparator (as by the sort(Sequence
, Comparator super T>) method) prior to making this call. If it is not sorted, the results are undefined. If the array contains multiple elements equal to the specified object, there is no guarantee which one will be found. -
Parameters
- seq
- The sequence to be searched.
- key
- The value to be searched for.
- c
- The comparator by which the array is ordered. A null value indicates that the elements' natural ordering should be used.
-
Returns
- Integer
- Index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.
Profile: common
- public static indexByIdentity(seq: java.lang.Object[], key: java.lang.Object) : Integer
-
Searches the specified sequence for the specified object.
More: [+]Searches the specified sequence for the specified object. If the sequence contains multiple elements equal to the specified object, the first occurence in the sequence will be returned. The method nextIndexOf can be used in consecutive calls to iterate through all occurences of a specified object.
-
Parameters
- seq
- The sequence to be searched.
- key
- The value to be searched for.
-
Returns
- Integer
- Index of the search key, if it is contained in the array; otherwise -1.
Profile: common
- public static indexOf(seq: java.lang.Object[], key: java.lang.Object) : Integer
-
Searches the specified sequence for an object with the same value.
More: [+]Searches the specified sequence for an object with the same value. The objects are compared using the method equals(). If the sequence is sorted, binarySearch should be used instead. If the sequence contains multiple elements equal to the specified object, the first occurence in the sequence will be returned. The method nextIndexOf can be used in consecutive calls to iterate through all occurences of a specified object.
-
Parameters
- seq
- The sequence to be searched.
- key
- The value to be searched for.
-
Returns
- Integer
- Index of the search key, if it is contained in the array; otherwise -1.
Profile: common
- public static isEqualByContentIdentity(seq1: java.lang.Object[], seq2: java.lang.Object[]) : Boolean
-
More: [+]
-
Parameters
- seq1
- seq2
-
Returns
- Boolean
Profile: common
- public static max(seq: java.lang.Comparable[]) : java.lang.Comparable
-
Returns the element with the maximum value in the specified sequence, according to the natural ordering of its elements.
More: [+]Returns the element with the maximum value in the specified sequence, according to the natural ordering of its elements. All elements in the sequence must implement the Comparable interface. Furthermore, all elements in the sequence must be mutually comparable (that is, e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the sequence). If the sequence contains multiple elements with the maximum value, there is no guarantee which one will be found.
-
Parameters
- seq
- The sequence to be searched.
-
Returns
- Comparable
- The element with the maximum value.
Profile: common
- public static max(seq: java.lang.Object[], c: java.util.Comparator) : java.lang.Object
-
Returns the element with the maximum value in the specified sequence, according to the specified comparator.
More: [+]Returns the element with the maximum value in the specified sequence, according to the specified comparator. All elements in the sequence must be mutually comparable by the specified comparator (that is, c.compare(e1, e2) must not throw a ClassCastException for any elements e1 and e2 in the sequence). If the sequence contains multiple elements with the maximum value, there is no guarantee which one will be found.
-
Parameters
- seq
- The sequence to be searched.
- c
- The comparator to determine the order of the sequence. A null value indicates that the elements' natural ordering should be used.
-
Returns
- Object
- The element with the maximum value.
Profile: common
- public static min(seq: java.lang.Comparable[]) : java.lang.Comparable
-
Returns the element with the minimum value in the specified sequence, according to the natural ordering of its elements.
More: [+]Returns the element with the minimum value in the specified sequence, according to the natural ordering of its elements. All elements in the sequence must implement the Comparable interface. Furthermore, all elements in the sequence must be mutually comparable (that is, e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the sequence). If the sequence contains multiple elements with the minimum value, there is no guarantee which one will be found.
-
Parameters
- seq
- The sequence to be searched.
-
Returns
- Comparable
- The element with the maximum value.
Profile: common
- public static min(seq: java.lang.Object[], c: java.util.Comparator) : java.lang.Object
-
Returns the element with the minimum value in the specified sequence, according to the specified comparator.
More: [+]Returns the element with the minimum value in the specified sequence, according to the specified comparator. All elements in the sequence must be mutually comparable by the specified comparator (that is, c.compare(e1, e2) must not throw a ClassCastException for any elements e1 and e2 in the sequence). If the sequence contains multiple elements with the minimum value, there is no guarantee which one will be found.
-
Parameters
- seq
- The sequence to be searched.
- c
- The comparator to determine the order of the sequence. A null value indicates that the elements' natural ordering should be used.
-
Returns
- Object
- The element with the minimum value.
Profile: common
- public static nextIndexByIdentity(seq: java.lang.Object[], key: java.lang.Object, pos: Integer) : Integer
-
Searches the specified sequence for an object with the same value, starting the search at the specified position.
More: [+]Searches the specified sequence for an object with the same value, starting the search at the specified position. The objects are compared using the method equals(). If the sequence contains multiple elements equal to the specified object, the first occurence in the subsequence will be returned.
-
Parameters
- seq
- The sequence to be searched.
- key
- The value to be searched for.
- pos
- The position in the sequence to start the search. If pos is negative or 0 the whole sequence will be searched.
-
Returns
- Integer
- Index of the search key, if it is contained in the array; otherwise -1.
Profile: common
- public static nextIndexOf(seq: java.lang.Object[], key: java.lang.Object, pos: Integer) : Integer
-
Searches the specified sequence for the specified object, starting the search at the specified position.
More: [+]Searches the specified sequence for the specified object, starting the search at the specified position. If the sequence contains multiple elements equal to the specified object, the first occurence in the subsequence will be returned.
-
Parameters
- seq
- The sequence to be searched.
- key
- The value to be searched for.
- pos
- The position in the sequence to start the search. If pos is negative or 0 the whole sequence will be searched.
-
Returns
- Integer
- Index of the search key, if it is contained in the array; otherwise -1.
Profile: common
- public static reverse(seq: java.lang.Object[]) : <any>[]
-
More: [+]
-
Parameters
- seq
-
Returns
- <any>[]
Profile: common
- public static shuffle(seq: java.lang.Object[]) : <any>[]
-
More: [+]
-
Parameters
- seq
-
Returns
- <any>[]
Profile: common
- public static sort(seq: java.lang.Comparable[]) : <any>[]
-
Sorts the specified sequence of objects into ascending order, according to the natural ordering of its elements.
More: [+]Sorts the specified sequence of objects into ascending order, according to the natural ordering of its elements. All elements in the sequence must implement the Comparable interface. Furthermore, all elements in the sequence must be mutually comparable (that is, e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the sequence). This method is immutative, the result is returned in a new sequence, while the original sequence is left untouched. This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort. The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance.
-
Parameters
- seq
- The sequence to be sorted.
-
Returns
- <any>[]
- The sorted sequence.
Profile: common
- public static sort(seq: java.lang.Object[], c: java.util.Comparator) : <any>[]
-
Sorts the specified sequence of objects according to the order induced by the specified comparator.
More: [+]Sorts the specified sequence of objects according to the order induced by the specified comparator. All elements in the sequence must be mutually comparable by the specified comparator (that is, c.compare(e1, e2) must not throw a ClassCastException for any elements e1 and e2 in the sequence). This method is immutative, the result is returned in a new sequence, while the original sequence is left untouched. This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort. The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance.
-
Parameters
- seq
- The sequence to be sorted.
- c
- The comparator to determine the order of the sequence. A null value indicates that the elements' natural ordering should be used.
-
Returns
- <any>[]
- The sorted sequence.
Profile: common