element-setter

Sets the collection element associated with a particular key.

Alters mutable-collection so that the value associated with key will subsequently be new-value.  If mutable-collection is stretchy, element-setter may also change its size (for example, by adding new keys with values).

An error is signaled if a program calls element-setter with a key that is not already a key to the collection, unless the collection is stretchy.

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:

  • 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.

Exported from

Modifiers

open

Arguments

new-valueAn instance of <object>.
mutable-collectionAn instance of <mutable-collection>.
keyAn instance of <object>.

Values

new-valueAn instance of <object>.
Summary
Sets the collection element associated with a particular key.
The class <table> provides an implementation of element-setter for use by its subclasses.

Functions

element-setter

The class <table> provides an implementation of element-setter for use by its subclasses.  If no element with the given key exists, element-setter will add the key and new-value to the table.

The class of tables (also known as hash tables).
Sets the collection element associated with a particular key.
The class of collections that may grow or shrinking to accommodate adding or removing elements.
The class of all collections that are not sequences.
The class of collections whose keys are consecutive integers starting from zero.
Sets the size of an object.
The common-dylan module.
Whenever possible, we have tried to keep the Dylan module pristine and unextended, preferring to add our extensions to separate modules or libraries.
The class of all Dylan objects.
The class of collections that may be modified.