elemental.util.
Interface ArrayOfNumber
-
public interface ArrayOfNumber
A lightweight array of numbers.
See Also:
JsArrayOfNumber
-
-
Method Summary
All Methods Modifier and Type Method and Description ArrayOfNumber
concat(ArrayOfNumber values)
Returns a new array that is the concatenation of this array and
values
.double
get(int index)
Gets the value at a given index.
void
insert(int index, double value)
Inserts a new element into the array at the specified index.
boolean
isEmpty()
Returns true if the length of the array is zero.
boolean
isSet(int index)
Check that the specified
index
has been initialized to a valid value.String
join()
Convert each element of the array to a String and join them with a comma separator.
String
join(String separator)
Convert each element of the array to a String and join them with a comma separator.
int
length()
Gets the length of the array.
double
peek()
Returns the last value of the array;
double
pop()
Remove and return the element from the end of the array.
void
push(double value)
Pushes the given number onto the end of the array.
void
removeByIndex(int index)
Removes the element at the specified index.
void
set(int index, double value)
Sets the value value at a given index.
void
setLength(int length)
Reset the length of the array.
double
shift()
Shifts the first value off the array.
void
sort()
Sorts the contents of the array in ascending order.
void
sort(CanCompareNumber comparator)
Sorts the contents of the Array based on the
CanCompareNumber
.ArrayOfNumber
splice(int index, int count)
Removes the specified number of elements starting at index and returns the removed elements.
void
unshift(double value)
Shifts a value onto the beginning of the array.
-
-
-
Method Detail
-
concat
ArrayOfNumber concat(ArrayOfNumber values)
Returns a new array that is the concatenation of this array and
values
. This method does not mutate the current array.
-
get
double get(int index)
Gets the value at a given index. If an undefined or non-numeric value exists at the given index, a type-conversion error will occur in hosted mode and unpredictable behavior may occur in web mode.
Parameters:
index
- the index to be retrievedReturns:
the value at the given index
-
insert
void insert(int index, double value)
Inserts a new element into the array at the specified index. Note: If index >= the length of the array, the element will be appended to the end. Also if the index is negative, the element will be inserted starting from the end of the array.
-
isEmpty
boolean isEmpty()
Returns true if the length of the array is zero.
Returns:
true when length is zero
-
isSet
boolean isSet(int index)
Check that the specified
index
has been initialized to a valid value.
-
join
String join()
Convert each element of the array to a String and join them with a comma separator. The value returned from this method may vary between browsers based on how JavaScript values are converted into strings.
-
join
String join(String separator)
Convert each element of the array to a String and join them with a comma separator. The value returned from this method may vary between browsers based on how JavaScript values are converted into strings.
-
length
int length()
Gets the length of the array.
Returns:
the array length
-
peek
double peek()
Returns the last value of the array;
Returns:
the last value
-
pop
double pop()
Remove and return the element from the end of the array.
Returns:
the removed value
-
push
void push(double value)
Pushes the given number onto the end of the array.
-
removeByIndex
void removeByIndex(int index)
Removes the element at the specified index.
-
set
void set(int index, double value)
Sets the value value at a given index. If the index is out of bounds, the value will still be set. The array's length will be updated to encompass the bounds implied by the added value.
Parameters:
index
- the index to be setvalue
- the value to be stored
-
setLength
void setLength(int length)
Reset the length of the array.
Parameters:
length
- the new length of the array
-
shift
double shift()
Shifts the first value off the array.
Returns:
the shifted value
-
sort
void sort()
Sorts the contents of the array in ascending order.
-
sort
void sort(CanCompareNumber comparator)
Sorts the contents of the Array based on the
CanCompareNumber
.Parameters:
comparator
-
-
splice
ArrayOfNumber splice(int index, int count)
Removes the specified number of elements starting at index and returns the removed elements.
-
unshift
void unshift(double value)
Shifts a value onto the beginning of the array.
Parameters:
value
- the value to the stored
-
-