chapel-lang/chapel — pull request #346 by daviditen (2014-09-08 22:58:43+00:00)
Title: Add list/vector style methods to 1D arrays that are 1:1 with their domains

Add list/vector style methods to 1D arrays that are 1:1 with their domains

Add the following methods to the _array type:
proc isEmpty(): bool;
proc head(): this._value.eltType;
proc tail(): this._value.eltType;
proc push_back(val: this._value.eltType) where chpl__isDense1DArray();
proc pop_back() where chpl__isDense1DArray();
proc push_front(val: this._value.eltType) where chpl__isDense1DArray();
proc pop_front() where chpl__isDense1DArray();
proc insert(pos: this._value.idxType, val: this._value.eltType)
where chpl__isDense1DArray();
proc remove(pos: this._value.idxType) where chpl__isDense1DArray();
proc remove(pos: range(this._value.idxType, stridable=false))
where chpl__isDense1DArray();
proc remove(pos: idxType, count: idxType) where chpl__isDense1DArray();
proc clear() where chpl__isDense1DArray();
proc find(val: this._value.eltType): (bool, this._value.idxType);
proc count(val: this._value.eltType): int;

All methods that modify the array's domain make sure the array is a 1D dense
rectangular array and that it has a 1:1 correspondence with its domain.

This incorporates feedback from @bradcray and @tmacd9.

Tested on full suite with standard linux64.