Classes | Collections > Ordered

Order : SequenceableCollection : Collection : Object

an order of elements with a numerical index
Subclasses: SparseArray

Description

Keeps elements in an order and allows to put them at arbitrary slots without having to allocate a large array.

NOTE: -put and -at are slower than in IdentityDictionary / PriorityQueue, -do is faster.

Class Methods

Order.new(size: 8)

Create a new order.

g = Order.new;
g.put(7, 100); // put a value (100) at index 7
g.clear; // empty

Order.newFromIndices(array, indices)

Create a new order from given items and indices.

Inherited class methods

Instance Methods

.doRange(function, from: 0, to)

Iterate over a range of the order's items.

.pos

Return the current write position.

Inherited instance methods

Undocumented instance methods

.add(obj)

.array

.array = value

.asArray

.at(index)

.choose

.clear(size)

.collect(function)

.copy

.do(function)

.indices

.indices = value

.indicesDo(function)

.keysValuesDo(function)

.lastIndex

.makeEmpty

.pop

.put(index, obj)

.reject(function)

.rejectInPlace(function)

.removeAllSuchThat(function)

.removeAt(index, obj)

.removeAtSlot(slot)

.select(function)

.selectInPlace(function)

.size

.species

Examples

a = Order.new;

a[0] = \z;
a[0] = \y;
a[5] = \five;
a[4] = \four;

a[0] = \z;
a[5] = \five;
a[4] = \four;

a.indices;

a[9] = 100;
a.indices;