|
Smalltalk/X WebserverDocumentation of class 'ReindexedCollection': |
|
|
Class: ReindexedCollectionInheritance:Object | +--Collection | +--SequenceableCollection | +--ReindexedCollection
Description:
ReindexedCollection is a wrapper around a sequenceable collection that remaps the indices
with in linear algorithm.
The elements in the ReindexedCollection are the elements of the original collection
at 'some start' to 'some stop' (optionally 'by some step').
ReindexedCollection allows for efficient use of first/rest-like algorithms (i.e. aka Lisp)
applied to Sequenceable collections, as they avoid element-copying.
For example,
coll1 := #(1 2 3 4 5 6 7 8 9 10).
coll2 := coll1 from:8.
gives us a collection in coll2, which 'contains' 3 elements, 8, 9, 10
with indices 1,2,3.
I.e. a slice from the other array.
The reindexed collection is 'read-only'. I.e. it does not allow for elements to be changed.
See class side examples.
[Instance Variables:]
sequence <SequenceableCollection> the sequence that will be reindexed.
interval <Interval> the object that describes indicies of interest in the sequence.
[Origin:]
Part of the Engineering Math Goodies package from Travis.
Class protocol:instance creation
Instance protocol:accessing
Examples:|coll| coll := #(1 2 3 4 5 6 7 8 9 10) from:8. Transcript show:'from 8: '; showCR:coll. Transcript show:'size: '; showCR:(coll size). Transcript show:'at 1: '; showCR:(coll at:1). Transcript show:'first: '; showCR:(coll first). Transcript show:'last: '; showCR:(coll last). coll do:[:each | Transcript show:'do: '; showCR:each]. coll reverseDo:[:each | Transcript show:'reverseDo: '; showCR:each]. |coll| coll := (1 to:10) asOrderedCollection from:3 to:8. coll. coll size. coll at:1. coll do:[:each | Transcript showCR:each]. |coll| coll := (1 to:10) asOrderedCollection to:4. coll. coll size. coll at:1. coll last. coll do:[:each | Transcript showCR:each]. |
|
|
ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Wed, 17 Dec 2025 12:05:38 GMT
|