Spec-Zone .ru
спецификации, руководства, описания, API

JavaFX: Bringing Rich Experiences To All the Screens Of Your Life

Profile: desktop, common

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 Variables

Script Function Summary

public binarySearch(seq: java.lang.Comparable[], key: java.lang.Comparable) : Integer

Searches the specified sequence for the specified object using the binary search algorithm.

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 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.

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

&nbsp;
public indexByIdentity(seq: java.lang.Object[], key: java.lang.Object) : Integer

Searches the specified sequence for the specified object.

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 nextIndexByIdentity() 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

&nbsp;
public indexOf(seq: java.lang.Object[], key: java.lang.Object) : Integer

Searches the specified sequence for an object with the same value.

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

&nbsp;
public isEqualByContentIdentity(seq1: java.lang.Object[], seq2: java.lang.Object[]) : Boolean

Returns true if the two specified sequences are equal to one another.

Returns true if the two specified sequences are equal to one another. The two sequences are considered equal if both sequences contain the same number of elements, and all corresponding pairs of elements in the two sequences are identical. In other words, the two sequences are equal if they contain the same elements in the same order.

Parameters
seq1
One sequence to be tested for equality
seq2
The other array to be tested for equality
Returns
Boolean

Profile: common

&nbsp;
public 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.

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

&nbsp;
public 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.

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

&nbsp;
public 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.

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

&nbsp;
public 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.

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

&nbsp;
public nextIndexByIdentity(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.

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

&nbsp;
public nextIndexOf(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.

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

&nbsp;
public reverse(seq: java.lang.Object[]) : java.lang.Object[]

Reverses the order of the elements in the specified sequence.

Reverses the order of the elements in the specified sequence.

This method is immutative, the result is returned in a new sequence, while the original sequence is left untouched.

Parameters
seq
The sequence which elements are to be reversed.
Returns
Object[]
The reversed sequence.

Profile: common

&nbsp;
public shuffle(seq: java.lang.Object[]) : java.lang.Object[]

Randomly permutes the specified list using a default source of randomness.

Randomly permutes the specified list using a default source of randomness. All permutations occur with approximately equal likelihood.

The hedge "approximately" is used in the foregoing description because default source of randomness is only approximately an unbiased source of independently chosen bits. If it were a perfect source of randomly chosen bits, then the algorithm would choose permutations with perfect uniformity.

This method is immutative, the result is returned in a new sequence, while the original sequence is left untouched.

Parameters
seq
The sequence to be shuffled.
Returns
Object[]
The shuffled sequence.

Profile: common

&nbsp;
public sort(seq: java.lang.Comparable[]) : java.lang.Object[]

Sorts the specified sequence of objects into ascending order, according to the natural ordering of its elements.

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
Object[]
The sorted sequence.

Profile: common

&nbsp;
public sort(seq: java.lang.Object[], c: java.util.Comparator) : java.lang.Object[]

Sorts the specified sequence of objects according to the order induced by the specified Comparator.

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
Object[]
The sorted sequence.

Profile: common

&nbsp;

Inherited Functions