|
|
Class: KeyedCollection
Object
|
+--Collection
|
+--KeyedCollection
|
+--MethodDictionary
|
+--RBSmallDictionary
- Package:
- stx:libbasic
- Category:
- Collections-Abstract
- Version:
- rev:
1.7
date: 2010/01/29 16:42:18
- user: cg
- file: KeyedCollection.st directory: libbasic
- module: stx stc-classLibrary: libbasic
- Author:
- Claus Gittinger
Abstract superclass for collections which have a key->value mapping.
This abstract class provides functionality common to those collections,
without knowing how the concrete class implements things. Thus, all
methods found here depend on some basic mechanisms to be defined in the
concrete class.
These basic methods are usually defined as #subclassResponsibility here.
Some methods are also redefined for better performance.
Subclasses should at least implement:
at:ifAbsent: - accessing elements
removeKey:ifAbsent - removing
keysAndValuesDo: - enumerating
queries
-
isAbstract
-
Return if this class is an abstract class.
True is returned for KeyedCollection here; false for subclasses.
Abstract subclasses must redefine again.
accessing
-
at: key
-
return the value stored under akey.
Raise an error if not found
-
at: key ifAbsent: exceptionBlock
-
return the value stored under akey.
Return the value from evaluating exceptionBlock if not found
** This method raises an error - it must be redefined in concrete classes **
-
keyAtValue: value
-
return the key under which value is stored.
Raise an error if not found
-
keyAtValue: value ifAbsent: exceptionBlock
-
return the key under which value is stored.
If not found, return the value from evaluating exceptionBlock
-
keys
-
return a collection containing the keys of the receiver
enumerating
-
do: aBlock
-
evaluate aBlock for each value
-
findFirstKey: aBlock
-
find and return the first key, for which evaluation of the argument, aBlock
returns true; return nil if none is detected.
-
keysAndValuesDo: aBlock
-
evaluate aBlock for each key and value
** This method raises an error - it must be redefined in concrete classes **
-
keysDo: aBlock
-
evaluate aBlock for each key
removing
-
removeKey: aKey
-
remove key (and the value stored under that key) from the
receiver; raise an error if no such element is contained
-
removeKey: aKey ifAbsent: exceptionBlock
-
remove key (and the value stored under that key) from the
receiver; if no such element is contained, return the value
from evaluating exceptionBlock
** This method raises an error - it must be redefined in concrete classes **
testing
-
includesIdenticalKey: aKey
-
return true, if the argument, aKey is a key in the receiver
-
includesKey: aKey
-
return true, if the argument, aKey is a key in the receiver
|