|
|
Class: MethodDictionary
Object
|
+--Collection
|
+--KeyedCollection
|
+--MethodDictionary
- Package:
- stx:libbasic
- Category:
- Kernel-Methods
- Version:
- rev:
1.27
date: 2006/09/18 19:49:04
- user: cg
- file: MethodDictionary.st directory: libbasic
- module: stx stc-classLibrary: libbasic
- Author:
- Stefan Vogel
Instances of MethodDictionary store selector/method associations
in classes. Conceptionally, they behave like IdentityDictionaries, but are
implemented using a single array (instead of Dictionary, which uses
two arrays to store keys and values separately).
Also, they do not use hashing, since due to caching in the VM, hashing
does not make too much of a difference in speed, but complicates the
VM implementation.
Dictionary
IdentityDictionary
Behavior
Class
Method
Symbol
binary storage
-
binaryFullDefinitionFrom: stream manager: manager
-
instance creation
-
new: sz
-
create and return a new methodDictionary holding sz
key->value associations
-
withAll: aDictionary
-
create a MethodDictionary from another Dictionary
-
withKeys: keys andValues: values
-
create a MethodDictionary from a key (selector) array and value (method) array
queries
-
isBuiltInClass
-
this class is known by the run-time-system
accessing
-
associationAt: key
-
return an association consisting of aKey and the element indexed
by aKey -
report an error, if no element is stored under aKey.
-
at: key ifAbsent: exceptionBlock
-
return the element indexed by aKey -
return result of exceptionBlock if no element is stored under aKey
-
at: key put: value
-
set the value for a given key, which is supposed to be a symbol.
In contrast to dictionaries, we allow adding elements only, if there is an
empty slot (nil key) present.
-
at: key putOrAppend: value
-
set the value for a given key, which is supposed to be a symbol.
In contrast to dictionaries, we allow adding elements only, if there is an
empty slot (nil key) present.
Otherwise a new MethodDictionary is created & returned
-
keyAtValue: value ifAbsent: exceptionBlock
-
return the first key with value -
return result of exceptionBlock if no key can be found
binary storage
-
storeFullBinaryDefinitionOn: stream manager: manager
-
store the complete description (i.e. including methods)
enumerating
-
collect: aBlock
-
for each element in the receiver, evaluate the argument, aBlock
and return a Bag with the results.
-
keysAndValuesDo: aBlock
-
evaluate the 2 arg block aBlock for each key (i.e. each selector)
and each value (i.e. each method)
inspecting
-
inspectorClass
-
redefined to use DictionaryInspector
(instead of the default Inspector).
private
-
compressed
-
compress - return either the myself or a new, compressed MethodDictionary
queries
-
size
-
return the number of elements (associations) in the receiver
removing
-
removeKey: key ifAbsent: failBlock
-
remove key from dictionary.
We actually do not remove it, but set it to nil.
-
removeKeyAndCompress: key
-
remove key from dictionary.
A new, compressed MethodDictionary will be returned,
or nil, if key is not present.
|