rsc3/doc-schelp/HelpSource/Classes/Order.schelp

56 lines
967 B
Text
Raw Normal View History

2022-08-24 13:53:18 +00:00
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;
::