Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
Lindsey Kuper edited this page Feb 12, 2015 · 5 revisions

Description

get is an operation for indexing into a ParallelArray and retrieving elements.

Synopsis

myParallelArray.get(index, ...)
myParallelArray.get(indices)

Arguments

  • index, ...: When called with one index argument, get returns the value found at that index. If the ParallelArray on which get is invoked is a multi-dimensional array, then get may be called with more index arguments, 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.

Returns

The value found at the specified index, or undefined if no such value exists.

Throws

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.

Examples

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);