Mutability
Some collections can be modified after they have been created; others cannot. To allow methods to distinguish between mutable and immutable collections, the <mutable-collection> and <stretchy-collection> mixin classes are provided:
<mutable-collection> [Abstract Class]
This abstract subclass of <collection> is used to indicate collections that can be modified. Every mutable collection is required to allow modification by implementing element-setter.
<stretchy-collection> [Abstract Class]
This abstract subclass of <collection> is used to indicate collections that may grow or shrink to accomodate adding or removing elements.
element-setter new-value mutable-collection key [Generic Function] => new-value
This function alters mutable-collection so that the value associated with key will subsequently be new-value.An error is signaled if a program calls element-setter with a key that is not already a key to collection, unless the collection supports the dynamic addition of keys and adds the key and new-value. Stretchy collections allow element-setter to be called with a key that is not present in the collection, expanding the collection as necessary to add a new element in that case. Each concrete subclass of <stretchy-collection> must provide or inherit a method for element-setter that behaves as follows when there is not already an element present for the indicated key:
<mutable-collection> is mixed in with <sequence> and <explicit-key-collection>, respectively, to form the classes <mutable-sequence> and <mutable-explicit-key-collection>:
- If the class is a subclass of <explicit-key-collection>, adds a new element to the collection with the indicated key.
- If the class is a subclass of <sequence>, first calls size-setter on the key + 1 and the collection to expand the sequence. The key must be a non-negative integer.
<mutable-sequence> [Abstract Class]
This class inherits from <sequence> and from <mutable-collection>.
<mutable-explicit-key-collection> [Abstract Class]
This class inherits from <explicit-key-collection> and <mutable-collection>.Next section: Collection Alignment