|
Unordered collections: sets and dictionariesSets and dictionaries are unordered collections of objects. A set contains objects in no particular order. No matter how many times an object is added to a set, it can be removed only once.A dictionary is a mapping from objects to objects. The keys of the dictionary form a set (i.e., no two keys are equal). Both sets and dictionaries are implemented using hash tables. The elements of a set and the keys of a dictionary must be comparable using = and able to return an integer hash value when sent hash (this value must not vary while the object is in the collection). In defaultBehavior is a method, identityHash, which uses a primitive hashing function supplied by the Virtual Machine. Objects are added to sets using add:, and removed using remove: or remove:IfAbsent: (which takes a block as second argument). Set membership can be tested with includes:. Dictionaries can be accessed using at: (which takes a key and returns the corresponding mapped object), or at:IfAbsent: (which sends value: to the second argument if the key is not in the dictionary), and updated using at:Put:. Membership can be tested with includes: and includesKey:.
|