Collections
- Vectors. Fixed-size, ordered collections.
- Unordered collections, e.g., sets and dictionaries.
- Growable, ordered collections, such as lists and sequences
|
Vectors
Vectors are the most primitive kind of collection, and are directly supported by the
Virtual Machine.
A vector is a fixed-size collection; it can contain references to any kind of object.
Typically, a vector is created by sending copySize:FillingWith: to the prototype. size
returns the size of the vector.
Elements are accessed by sending at: with an integer index, and modified by
sending at:Put: with an integer index and new element.
Smalltalk programmers: N.B.: Indexes are 0-based in Self!
Useful shorthands: firstKey returns the first index (0), lastKey the last index (size -
1), first and last the first and last elements, and first: and last: can be used to change
the first and last elements.
Special kinds of vector
byteVectors are restricted to contained byte-size integers (0 to 255).
|