Returns a list whose elements are array itself, without copying it. Every change made through
the list — add, insert, removeAt, set, sort, clear, through its sub-lists, reversed
view and cursors — writes to the array, and changes made to the array directly show through the
list. A direct change of the array's length makes open iterators, cursors and sub-lists of the
list throw ConcurrentModificationError on their next move; same-length direct writes show
through but are not detected and do not change revision. The same holds for callbacks: a
comparator, forEach action, removeIf predicate or replaceAll function that changes the
array's length makes the call throw ConcurrentModificationError once it returns, and its writes
stay; same-length writes are not detected, and sort writes its result over them.
The list follows the list rules, not the array's: indexOf uses SameValueZero, equals
compares with any list by elements, and sort is stable and throws NullElementError for
null, undefined and holes in natural order (holes read as undefined). A frozen array refuses
every write, and a sealed or non-extensible one every change of length, with TypeError before
anything is written. Only those three states are checked: an element made non-writable or
non-configurable with Object.defineProperty on an extensible array, or a Proxy array, can
make a write fail part-way and leave elements shifted. Each call returns a new, independent list.
Time: O(1). get, set and size are O(1), add amortised O(1), insert and removeAt O(n).
Returns a list whose elements are
arrayitself, without copying it. Every change made through the list —add,insert,removeAt,set,sort,clear, through its sub-lists, reversed view and cursors — writes to the array, and changes made to the array directly show through the list. A direct change of the array's length makes open iterators, cursors and sub-lists of the list throwConcurrentModificationErroron their next move; same-length direct writes show through but are not detected and do not changerevision. The same holds for callbacks: a comparator,forEachaction,removeIfpredicate orreplaceAllfunction that changes the array's length makes the call throwConcurrentModificationErroronce it returns, and its writes stay; same-length writes are not detected, andsortwrites its result over them.The list follows the list rules, not the array's:
indexOfuses SameValueZero,equalscompares with any list by elements, andsortis stable and throwsNullElementErrorfornull,undefinedand holes in natural order (holes read asundefined). A frozen array refuses every write, and a sealed or non-extensible one every change of length, withTypeErrorbefore anything is written. Only those three states are checked: an element made non-writable or non-configurable withObject.definePropertyon an extensible array, or aProxyarray, can make a write fail part-way and leave elements shifted. Each call returns a new, independent list.Time: O(1).
get,setandsizeare O(1),addamortised O(1),insertandremoveAtO(n).