T
- public class Array<T>
extends com.google.gwt.core.client.JavaScriptObject
Although strong typed with a generic type, the array may in fact contains any value type.
Use factory methods (fromInts(int...)
, ... ) to create Array
instance from primitive values.
You may turn a Java Iterable
instance to an array using the
fromIterable(Iterable)
method.
This class provides the properties and methods defined on this page
Modifier | Constructor and Description |
---|---|
protected |
Array() |
Modifier and Type | Method and Description |
---|---|
Iterable<Value> |
asIterable() |
List<T> |
asList() |
Array<?> |
concat(Array<?> array1)
Return a new array containing the values of this array and the given
array.
|
Array<?> |
concat(Array<?> array1,
Array<?> array2)
Return a new array containing the values of this array and the given
array.
|
Array<?> |
concat(Array<?> array1,
Array<?> array2,
Array<?> array3)
Return a new array containing the values of this array and the given
array.
|
Array<?> |
concat(Array<?> array1,
Array<?> array2,
Array<?> array3,
Array<?> array4)
Return a new array containing the values of this array and the given
array.
|
Array<?> |
concat(Array<?> array1,
Array<?> array2,
Array<?> array3,
Array<?> array4,
Array<?> array5)
Return a new array containing the values of this array and the given
array.
|
static <R> Array<R> |
create()
Create a new empty array.
|
boolean |
every(ForEachCallback<Boolean> callback)
Executes the provided callback function once for each element present in
the array until it finds one where callback returns a falsy value.
|
boolean |
every(ForEachCallback<Boolean> callback,
Object thisArg)
Executes the provided callback function once for each element present in
the array until it finds one where callback returns a falsy value.
|
Array<T> |
filter(ForEachCallback<Boolean> callback)
Calls the provided callback function once for each element in an array,
and constructs a new array of all the values for which callback returns a
true value.
|
Array<T> |
filter(ForEachCallback<Boolean> callback,
Object thisArg)
Calls the provided callback function once for each element in an array,
and constructs a new array of all the values for which callback returns a
true value.
|
void |
forEach(ForEachCallback<Void> callback)
Executes the provided callback once for each element of the array with an
assigned value.
|
void |
forEach(ForEachCallback<Void> callback,
Object thisArg)
Executes the provided callback once for each element of the array with an
assigned value.
|
static Array<Byte> |
fromBytes(byte... args)
Create a new Array from the given values.
|
static Array<Character> |
fromChars(char... args)
Create a new Array from the given values.
|
static Array<Double> |
fromDoubles(double... args)
Create a new Array from the given values.
|
static Array<Float> |
fromFloats(float... args)
Create a new Array from the given values.
|
static Array<Integer> |
fromInts(int... args)
Create a new Array from the given values.
|
static <T> Array<T> |
fromIterable(Iterable<T> iterable)
Create a new Array
|
static Array<Object> |
fromJavaArray(Object[] args)
Create a new Array from the given values.
|
static Array<Long> |
fromLongs(long... args)
Create a new Array from the given values.
|
static <R> Array<R> |
fromObjects(R... args)
Create a new Array from the given values.
|
static Array<Short> |
fromShorts(short... args)
Create a new Array from the given values.
|
T |
get(int index)
Return the element at the specified index as the parameterized type.
|
boolean |
getBoolean(int i)
Return the item at the index i.
|
int |
getInt(int index)
Return the item at the index i.
|
double |
getNumber(int index)
Return the item at the index i.
|
T |
getObject(int i)
Return the item at the index i.
|
String |
getString(int i)
Return the item at the index i.
|
Value |
getValue(int i)
Return the element at the given index wrapped by a
Value object. |
<R> int |
indexOf(R item)
Search the array for the specified item, and returns its position, or -1
of the item is not found.
|
<R> int |
indexOf(R item,
int startIndex)
Search the array for the specified item, and returns its position, or -1
of the item is not found.
|
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 the
given separator.
|
<R> int |
lastIndexOf(R item)
Search the array for the specified item, and returns its position, or -1
of the item is not found.
|
<R> int |
lastIndexOf(R item,
int startIndex)
Search the array for the specified item, and returns its position, or -1
of the item is not found.
|
int |
length()
Gets the length of the array.
|
<R> Array<R> |
map(ForEachCallback<R> callback)
Calls the provided callback function once for each element in the array,
and constructs a new array of all the values returned by the callback.
|
<R> Array<R> |
map(ForEachCallback<R> callback,
Object thisArg)
Calls the provided callback function once for each element in the array,
and constructs a new array of all the values returned by the callback.
|
<R> Array<R> |
map(com.google.gwt.core.client.JavaScriptObject callback)
Alias for
map(ForEachCallback) . |
T |
pop()
Removes the last element of an array, and returns that element.
|
boolean |
popBoolean()
Removes the last element of an array, and returns that element.
|
double |
popNumber()
Removes the last element of an array, and returns that element.
|
<R extends com.google.gwt.core.client.JavaScriptObject> |
popObject()
Removes the last element of an array, and returns that element.
|
String |
popString()
Removes the last element of an array, and returns that element.
|
int |
push(boolean value)
Pushes the given boolean onto the end of the array.
|
int |
push(double value)
Pushes the given double onto the end of the array.
|
int |
push(com.google.gwt.core.client.JavaScriptObject value)
Pushes the given
JavaScriptObject onto the end of the array. |
int |
push(T value)
Pushes the given item onto the end of the array.
|
Array<T> |
reverse()
Reverse the order of the elements in the array.
|
void |
set(int index,
boolean value)
Sets the boolean value at a given index.
|
void |
set(int index,
double value)
Sets the double value at a given index.
|
void |
set(int index,
com.google.gwt.core.client.JavaScriptObject value)
Sets the object value at a given index.
|
void |
set(int index,
String value)
Sets the String value at a given index.
|
void |
set(int index,
T value)
Sets the value at a given index.
|
void |
setLength(int newLength)
Reset the length of the array.
|
boolean |
shiftBoolean()
Shifts the first value off the array.
|
double |
shiftNumber()
Shifts the first value off the array.
|
<R extends com.google.gwt.core.client.JavaScriptObject> |
shiftObject()
Shifts the first value off the array.
|
String |
shiftString()
Shifts the first value off the array.
|
Array<T> |
slice(int startIndex)
Selects the elements starting at the given startIndex, until the last
element, and return the selected elements in a new array.
|
Array<T> |
slice(int startIndex,
int endIndex)
Selects the elements starting at the given startIndex, extending at the
element just before the endIndex, and return the selected elements in a
new array.
|
boolean |
some(ForEachCallback<Boolean> callback)
Executes the provided callback function once for each element present in
the array until it finds one where callback returns a true value.
|
boolean |
some(ForEachCallback<Boolean> callback,
Object thisArg)
Executes the provided callback function once for each element present in
the array until it finds one where callback returns a true value.
|
Array<?> |
sortAlphaAsc()
Sort the elements alphabetically and ascending.
|
Array<?> |
sortAlphaDesc()
Sort the elements alphabetically and descending.
|
Array<?> |
sortNumericAsc()
Sort the elements numerically and ascending.
|
Array<?> |
sortNumericDesc()
Sort the elements numerically and ascending.
|
Array<T> |
splice(int startIndex,
int count)
Remove count elements from startIndex.
|
Array<T> |
splice(int startIndex,
int count,
Object insert1)
Remove count elements from startIndex, and insert the given elements at
this position.
|
Array<T> |
splice(int startIndex,
int count,
Object insert1,
Object insert2)
Remove count elements from startIndex, and insert the given elements at
this position.
|
Array<T> |
splice(int startIndex,
int count,
Object insert1,
Object insert2,
Object insert3)
Remove count elements from startIndex, and insert the given elements at
this position.
|
Array<T> |
splice(int startIndex,
int count,
Object insert1,
Object insert2,
Object insert3,
Object insert4)
Remove count elements from startIndex, and insert the given elements at
this position.
|
Array<T> |
splice(int startIndex,
int count,
Object insert1,
Object insert2,
Object insert3,
Object insert4,
Object insert5)
Remove count elements from startIndex, and insert the given elements at
this position.
|
int |
unshift(boolean value)
Shifts a boolean onto the beginning of the array.
|
int |
unshift(double value)
Shifts a double onto the beginning of the array.
|
int |
unshift(com.google.gwt.core.client.JavaScriptObject value)
Shifts a
JavaScriptObject onto the beginning of the array. |
int |
unshift(String value)
Shifts a String onto the beginning of the array.
|
public static <T> Array<T> fromIterable(Iterable<T> iterable)
iterable
- the iterablepublic static <R> Array<R> create()
public static final Array<Integer> fromInts(int... args)
args
- the valuespublic static final Array<Byte> fromBytes(byte... args)
args
- the valuespublic static Array<Character> fromChars(char... args)
args
- the valuespublic static final Array<Double> fromDoubles(double... args)
args
- the valuespublic static final Array<Float> fromFloats(float... args)
args
- the valuespublic static final Array<Long> fromLongs(long... args)
args
- the valuespublic static final Array<Short> fromShorts(short... args)
args
- the valuespublic static final <R> Array<R> fromObjects(R... args)
args
- the valuespublic static final Array<Object> fromJavaArray(Object[] args)
args
- the valuespublic final T get(int index)
index
- the index of the objectpublic final Value getValue(int i)
Value
object.i
- the indexpublic final T getObject(int i)
i
- the index of the itempublic final boolean getBoolean(int i)
i
- the index of the itempublic final String getString(int i)
i
- the index of the itempublic final double getNumber(int index)
i
- the index of the itempublic final int getInt(int index)
i
- the index of the itempublic final T pop()
public final boolean popBoolean()
public final String popString()
public final double popNumber()
public final <R extends com.google.gwt.core.client.JavaScriptObject> R popObject()
public final <R> int indexOf(R item)
The search will start at the index 0, and end the search at the end of
the array.
item
- the item to search for.public final <R> int indexOf(R item, int startIndex)
The search will start at the specified position, and end the search at
the end of the array.
Negative values will start at the given position counting from the end,
and search to the end.
item
- the item to search for.startIndex
- the start of the searchpublic final <R> int lastIndexOf(R item)
The search will start at the end of the array, and end the search at the
beginning of the array.
item
- the item to search for.public final <R> int lastIndexOf(R item, int startIndex)
The search will start at the specified position, and end the search at
the beginning of the array.
Negative values will start at the given position counting from the end,
and search to the beginning.
item
- the item to search for.startIndex
- the start of the searchpublic final Array<?> concat(Array<?> array1)
array1
- public final Array<?> concat(Array<?> array1, Array<?> array2)
array1
- array2
- public final Array<?> concat(Array<?> array1, Array<?> array2, Array<?> array3)
array1
- array2
- array3
- public final Array<?> concat(Array<?> array1, Array<?> array2, Array<?> array3, Array<?> array4)
array1
- array2
- array3
- array4
- public final Array<?> concat(Array<?> array1, Array<?> array2, Array<?> array3, Array<?> array4, Array<?> array5)
array1
- array2
- array3
- array4
- array5
- public final void forEach(ForEachCallback<Void> callback)
callback
- public final void forEach(ForEachCallback<Void> callback, Object thisArg)
callback
- public final boolean every(ForEachCallback<Boolean> callback)
callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.
callback
- the callback to be called for each elementpublic final boolean every(ForEachCallback<Boolean> callback, Object thisArg)
callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.
callback
- the callback to be called for each elementthisArg
- an argument to be passed to each callback invocations.public final boolean some(ForEachCallback<Boolean> callback)
callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.
callback
- the callback to be called for each elementpublic final boolean some(ForEachCallback<Boolean> callback, Object thisArg)
callback is invoked only for indexes of the array which have assigned
values;
it is not invoked for indexes which have been deleted or which have never
been assigned values.
callback
- the callback to be called for each elementthisArg
- an argument to be passed to each callback invocations.public final Array<T> filter(ForEachCallback<Boolean> callback)
callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.
callback
- the callback to be called for each elementpublic final Array<T> filter(ForEachCallback<Boolean> callback, Object thisArg)
callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.
callback
- the callback to be called for each elementthisArg
- an argument to be passed to each callback invocations.public final <R> Array<R> map(ForEachCallback<R> callback)
callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.
callback
- the callback to be called for each elementpublic final <R> Array<R> map(com.google.gwt.core.client.JavaScriptObject callback)
map(ForEachCallback)
.
callback
- the callback to be called for each elementpublic final <R> Array<R> map(ForEachCallback<R> callback, Object thisArg)
callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.
callback
- the callback to be called for each elementthisArg
- an argument to be passed to each callback invocations.public final String join()
public final String join(String separator)
separator
- the separator to be used between each joined elementpublic final int length()
public final void setLength(int newLength)
newLength
- the new length of the arraypublic final int push(boolean value)
value
- the item to pushpublic final int push(double value)
value
- the item to pushpublic final int push(com.google.gwt.core.client.JavaScriptObject value)
JavaScriptObject
onto the end of the array.value
- the item to pushpublic final int push(T value)
value
- the item to pushpublic final void set(int index, boolean value)
index
- the index to be setvalue
- the boolean to be storedpublic final void set(int index, T value)
index
- the index to be setvalue
- the boolean to be storedpublic final void set(int index, double value)
index
- the index to be setvalue
- the double to be storedpublic final void set(int index, com.google.gwt.core.client.JavaScriptObject value)
index
- the index to be setvalue
- the JavaScriptObject
to be storedpublic final void set(int index, String value)
index
- the index to be setvalue
- the String to be storedpublic final boolean shiftBoolean()
public final double shiftNumber()
public final <R extends com.google.gwt.core.client.JavaScriptObject> R shiftObject()
JavaScriptObject
public final String shiftString()
public final int unshift(boolean value)
value
- the value to the storedpublic final int unshift(double value)
value
- the value to storepublic final int unshift(com.google.gwt.core.client.JavaScriptObject value)
JavaScriptObject
onto the beginning of the array.value
- the value to storepublic final int unshift(String value)
value
- the value to storepublic final Array<T> reverse()
public final Array<T> slice(int startIndex)
startIndex
- public final Array<T> slice(int startIndex, int endIndex)
startIndex
- endIndex
- public final Array<?> sortAlphaAsc()
public final Array<?> sortAlphaDesc()
public final Array<?> sortNumericAsc()
public final Array<?> sortNumericDesc()
public final Array<T> splice(int startIndex, int count)
startIndex
- the index of the first element to be removed; negative values
specify position from the end of the arraycount
- the number of elements to be removedpublic final Array<T> splice(int startIndex, int count, Object insert1)
startIndex
- the index of the first element to be removed; negative values
specify position from the end of the arraycount
- the number of elements to be removedinsert1
- element to insertpublic final Array<T> splice(int startIndex, int count, Object insert1, Object insert2)
startIndex
- the index of the first element to be removed; negative values
specify position from the end of the arraycount
- the number of elements to be removedinsert1
- element to insertinsert2
- element to insertpublic final Array<T> splice(int startIndex, int count, Object insert1, Object insert2, Object insert3)
startIndex
- the index of the first element to be removed; negative values
specify position from the end of the arraycount
- the number of elements to be removedinsert1
- element to insertinsert2
- element to insertinsert3
- element to insertpublic final Array<T> splice(int startIndex, int count, Object insert1, Object insert2, Object insert3, Object insert4)
startIndex
- the index of the first element to be removed; negative values
specify position from the end of the arraycount
- the number of elements to be removedinsert1
- element to insertinsert2
- element to insertinsert3
- element to insertinsert4
- element to insertpublic final Array<T> splice(int startIndex, int count, Object insert1, Object insert2, Object insert3, Object insert4, Object insert5)
startIndex
- the index of the first element to be removed; negative values
specify position from the end of the arraycount
- the number of elements to be removedinsert1
- element to insertinsert2
- element to insertinsert3
- element to insertinsert4
- element to insertinsert5
- element to insertCopyright © 2015 gwt-d3. All rights reserved.