EList

EList is the abstract supertype of ConstList, FlexList, and ReadOnlyList.

All indexing is zero-based. All ranges are specified as beginning index, inclusive, to ending index, exclusive (not inclusive end or location and size).

Protocol
? def abcd := (["a", "b", "c", "d"]); null ? def ConstList := List

Concatenates (snapshots of) this list and other.

--Kevin Reid 17:38, 25 March 2009 (CDT)

? abcd.add(abcd.run(1, 3)) :Really[ConstList]
 * 1) value: ["a", "b", "c", "d", "b", "c"]

XXX type error check, other cases, which one is first

Returns a ConstMap whose keys are the elements of this EList and values are null, with the first occurrence of duplicates kept.

? abcd.asKeys ? def abcbd := abcd(0, 3) + abcd(1, 2) + abcd(3, 4) ? abcbd.asKeys
 * 1) value: ["a" => null, "b" => null, "c" => null, "d" => null]
 * 1) value: ["a", "b", "c", "b", "d"]
 * 1) value: ["a" => null, "b" => null, "c" => null, "d" => null]

Returns a ConstMap whose keys are the indexes and values are the values of this EList, in the same order as this EList.

? abcd.asMap
 * 1) value: [0 => "a", 1 => "b", 2 => "c", 3 => "d"]

Return the element at index.

? abcd[0] ? abcd[2] ? abcd[-1] ? abcd[4]
 * 1) value: "a"
 * 1) value: "c"
 * 1) problem: 
 * 1) problem: 

Return an EList which is a read-only view of this list. If this list is immutable the result may be the same as this list.



Return a ConstList containing the subsequence of elements in this list starting with element index start and ending with the element before index end.

? abcd.run(1, 3) :Really[ConstList] ? abcd.run(0, abcd.size) :Really[ConstList] ? ESpec.requireWrongArgsFail(abcd, "run", [0..!(abcd.size), 0..!(abcd.size)])
 * 1) value: ["b", "c"]
 * 1) value: ["a", "b", "c", "d"]

? abcd.run(1) :Really[ConstList] ? abcd.run(0) :Really[ConstList]
 * 1) value: ["b", "c", "d"]
 * 1) value: ["a", "b", "c", "d"]

Return the current number of elements of this list.

? abcd.size :Really[int]
 * 1) value: 4

Return a ConstList with the current elements of this list.

? abcd.snapshot :Really[ConstList]
 * 1) value: ["a", "b", "c", "d"]

Return a ConstList with the current elements of this list, followed by the one additional element value.

? abcd.with("e") :Really[ConstList] ? ([]).with(1) :Really[ConstList]
 * 1) value: ["a", "b", "c", "d", "e"]
 * 1) value: [1]

Return a ConstList with the current elements of this list except that the element at index is value. Or, by cases:


 * If index is less than the, then that element is replaced in the result list.
 * If index is equal to, then value is an additional element and the size is one greater. (This is equivalent to .)
 * Otherwise, the index is out of bounds.