1 CLASS::IdentityDictionary
2 summary::associative collection mapping keys to values
3 related::Classes/Environment, Classes/Event
4 categories::Collections>Unordered
7 An IdentityDictionary is an associative collection mapping keys to values.
8 Keys match only if they are strong::identical objects::. (i.e. === returns true.)
10 (In Dictionary, keys match if they are equal valued. This makes IdentityDictionary faster than link::Classes/Dictionary::)
12 The contents of a Dictionary are strong::unordered::. You must not depend on the order of items in a Dictionary.
14 Often, the subclass Event is used as an IdentityDictionary, because there is a syntactical shortcut:
16 a = (); // return a new Event.
24 The link::#-parent:: and link::#-proto:: instance variables allow additional IdentityDictionary's to provide default values. The precedence order for determining the value of a key is the IdentityDictionary, its prototype, its parent.
26 When the instance variable link::#-know:: is link::Classes/True::, the IdentityDictionary responds to unknown messages by looking up the selector and evaluating the result with the dictionary as an argument. For example:
28 a = IdentityDictionary(know: true);
29 a.put(\foo, { | x | ("the argument is:" + x).postln });
36 Sets key to newValue, returns the previous value of key.
38 subsection::Accessing Instance Variables
40 method::proto, parent, know
42 subsection::IdentityDictionary reimplements the following methods of Dictionary
44 method::at, put, includesKey, findKeyForValue, scanFor
46 subsection::The following three methods provide support for Quant
48 method::nextTimeOnGrid, asQuant, timingOffset
53 IdentityDictionary is often used to assign names to instances of a particular class. For example, the proxy classes ( link::Classes/Pdef::, link::Classes/Pdefn::, link::Classes/Tdef::, link::Classes/Ndef:: ), and link::Classes/NodeWatcher:: all have class variables named all implemented as IdentityDictionaries.