Next: , Previous: , Up: Associative Maps   [Contents][Index]


11.8.4 Amap mutators

procedure: amap-set! amap [key value] …

Repeatedly mutates amap, creating new associations in it by processing the arguments from left to right. The args alternate between keys and values. Whenever there is a previous association for a key, it is deleted. It is an error if a key does not satisfy the type check procedure of the comparator of amap. Likewise, it is an error if a key is not a valid argument to the equality predicate of amap. Returns an unspecified value.

procedure: amap-delete! amap key …

Deletes any association to each key in amap and returns the number of keys that had associations.

procedure: amap-intern! amap key fail

Effectively invokes amap-ref with the given arguments and returns what it returns. If key was not found in amap, its value is set to the result of calling fail.

procedure: amap-update! amap key updater [fail [succeed]]

Semantically equivalent to, but may be more efficient than, the following code:

(amap-set! amap key (updater (amap-ref amap key fail succeed)))
procedure: amap-update!/default amap key updater default

Semantically equivalent to, but may be more efficient than, the following code:

(amap-set! amap key (updater (amap-ref/default amap key default)))
procedure: amap-pop! amap

Chooses an arbitrary association from amap and removes it, returning the key and value as two values. Signals an error if amap is empty.

procedure: amap-clear! amap

Delete all the associations from amap.

procedure: amap-clean! amap

If amap has weak or ephemeral associations, cleans up any storage for associations whose key and/or value has been reclaimed by the garbage collector. Otherwise does nothing.

This procedure does not have any visible effect, since the associations it cleans up are ignored by all other parts of the interface. Additionally, most implementations clean up their storage incrementally as they are used. But this procedure provides for edge cases where the reclaimed storage might matter.


Next: Amap mapping and folding, Previous: Amap accessors, Up: Associative Maps   [Contents][Index]