Contents

Class ArrayedCollection


Inheritance:

Object  »
  Collection  »
    SequenceableCollection  »
      ArrayedCollection
        Array  »
        Bitmap
        ByteArray  »
        String  »
          Symbol  »
        Text  »

Class ArrayedCollection is the abstract superclass of various collections that use indices from 1 to an upper limit to access their elements. All subclasses with the exception of DirectoryEntry, RunArray and Text are variable subclasses.

Instances of subclasses are created at a fixed size and cannot grow.

Initial values for the elements of an arrayed collection are:

The notion 'size' has a special interpretation for arrayed collections, which differs from the interpretation of size that is valid for other collections:

Useful Instance Methods:

Examples:

This example demonstrates the different interpretation of size for an array and an ordered collection:

  | array oc |
 array := Array new: 10.
 oc := OrderedCollection new: 10.
 array size = 10
 & (oc size = 0)

This example verifies the initialization of the elements of an array.

  | array |
 array := Array new: 10.
 array collect: [:item | item isNil]
 #(true true true true true true true true true true)

The following example demonstrates the use of in-place sorting:

  | array |
array := Array new: 10.
#(54 23 12 58 22 78 91 11 31 41)
  withIndexDo:
   [:item :idx | array at: idx put: item].
 array sort: [:x :y | x <= y].
 array.
 #(11 12 22 23 31 41 54 58 78 91)

Contents