This repository was archived by the owner on Nov 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
get
Lindsey Kuper edited this page Feb 12, 2015
·
5 revisions
get is an operation for indexing into a ParallelArray and retrieving elements.
myParallelArray.get(index, ...)
myParallelArray.get(indices)-
index, ...: When called with oneindexargument,getreturns the value found at that index. If theParallelArrayon whichgetis invoked is a multi-dimensional array, thengetmay be called with moreindexarguments, up to the number of dimensions that the array has. The first index references the outermost dimension, the second the next dimension, and so forth. -
indices: an array of number values.
The value found at the specified index, or undefined if no such value exists.
If index is not a number, or if indices is not an array-like object or the length of indices is greater than the number of dimensions in the source array.
var pa = new ParallelArray([0,1,2,3,4], [10,11,12,13,14], [20,21,22,23,24]);
// index into a 2D ParallelArray with `get` and, from the array at
// index 1, retrieve the element at index 1, which is 11
pa.get([1,1]);
// attempt an out-of-bounds index into a 2D ParallelArray; result is
// undefined
pa.get([1,5]);
// two equivalent ways to index into a 2D ParallelArray and retrieve
// the element at index 0, which is itself a ParallelArray
pa.get([0]);
pa.get(0);
// four equivalent ways to index into a 2D ParallelArray and retrieve
// the ParallelArray at index 2, then index into that ParallelArray
// and retrieve the element at index 4, which is 24
pa.get([2, 4]);
pa.get([2]).get([4]);
pa.get(2, 4);
pa.get(2).get(4);
// throws a "too many indices in get call" exception, since we are
// attempting to index into a 2D ParallelArray using three indices
pa.get(2, 4, 1);