OrderedCollection
Last updated at 4:32 pm UTC on 13 January 2022
OrderedCollection is a subclass of SequenceableCollection
An ordered collection is much like a generalised Smalltalk Arrays, with can grow and shrink as needed. The elements are kept in the order they are stored in and thus the ordered collection may also be seen and used as a stack.
a:= OrderedCollection new.
a add:5.
a add:7.
a.->an OrderedCollection(5 7)
a size.->2
a at:1 put:4.
a.->an OrderedCollection(4 7)
a first.
a last.
a addFirst:8.
a addLast:10.
a.->an OrderedCollection(8 4 7 10)
a removeFirst.
a removeLast.
a allButFirst do: [:elem | Transcript show: elem; cr].
Subclass is:
Object withAllSubclasses class
OrderedCollection
Object withAllSubclasses
select: [:cls | (cls methodDictionary keys
select: [:keySymbol | keySymbol asString beginsWith: 'pdicCode']) size > 0]
In Java the similar class to OrderedCollection is called "ArrayList".
See also
Dictionary