55 lines
967 B
Text
55 lines
967 B
Text
CLASS::Order
|
|
summary::an order of elements with a numerical index
|
|
related::Classes/SparseArray
|
|
categories:: Collections>Ordered
|
|
|
|
DESCRIPTION::
|
|
Keeps elements in an order and allows to put them at arbitrary slots
|
|
without having to allocate a large array.
|
|
|
|
note::
|
|
link::#-put:: and link::#-at:: are slower than in link::Classes/IdentityDictionary:: / link::Classes/PriorityQueue::, link::#-do:: is faster.
|
|
::
|
|
|
|
CLASSMETHODS::
|
|
|
|
method::new
|
|
Create a new order.
|
|
code::
|
|
g = Order.new;
|
|
g.put(7, 100); // put a value (100) at index 7
|
|
g.clear; // empty
|
|
::
|
|
|
|
method::newFromIndices
|
|
Create a new order from given items and indices.
|
|
|
|
INSTANCEMETHODS::
|
|
|
|
private::resetIndices, nextSlotFor, slotFor, prPutSlot
|
|
|
|
method::doRange
|
|
Iterate over a range of the order's items.
|
|
|
|
method::pos
|
|
Return the current write position.
|
|
|
|
EXAMPLES::
|
|
|
|
code::
|
|
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;
|
|
::
|