![]()
|
dictnary Specification SheetPortable Object Compiler (c) 1997,98. All Rights Reserved.
DictionaryInherits from: Object
Class DescriptionDictionaries (instances of the Dictionary class) are key-value tables : to each key object, a value object is associated. The key can then be used to access the corresponding value. There are a few special provisions for tables with String instances as keys.
Method typesCreationInterrogationComparingIndexed AccessAdding and RemovingBlocksPrintingMethodsnew+newReturns a new empty dictionary.
copy-copyReturns a new copy of the dictionary.
deepCopy-deepCopyReturns a new copy of the dictionary. The members in the new dictionary are deep copies of the members in the original dictionary.
emptyYourself-emptyYourselfRemoves all the keys and values of the dictionary (without freeing them). Returns the receiver.
freeContents-freeContentsThis method is, in the case of the Dictionary class, equivalent to emptyYourself. Note that for the sake of Stepstone ICpak101 compatibility, this method does not free keys and values. Use freeAll for that.
freeAll-freeAllThis method frees all the keys and values in the dictionary, without freeing the dictionary itself. Returns the dictionary. Note: This method is ObjectPak specific.
free-freeFrees the dictionary, but not its contents. Returns nil. Do :
if you want to free the dictionary and its contents.aDic = [[aDic freeAll] free];
size- (unsigned)sizeReturns the number of key-value associations in the dictionary.
isEmpty- (BOOL)isEmptyWhether the number of associations in the dictionary is equal to zero.
includesKey:- (BOOL)includesKey:aKeyReturns YES if there is an association with key matching aKey.
hash- (unsigned)hashReturns a hash value based on the receiver's address and the results of sending the hash message to the contents.
isEqual:- (BOOL)isEqual:aDicReturns YES if aDic is a dictionary, and if its keys and values respond affirmatively to the message isEqual: when compared to the corresponding objects of the receiver's contents.
atKey:-atKey:aKeyReturns the value of the association matching aKey. Returns nil if the association is not found.
atKey:ifAbsent:-atKey:aKeyifAbsent:exceptionBlockReturns the value of the association matching aKey. Evaluates exceptionBlock and returns its return value, if the association is not found.
atKeySTR:-atKeySTR:(STR)strKeyReturns the value of the association matching strKey. Returns nil if the association is not found.
atKey:put:-atKey:aKeyput:anObjectAssociates aKey to anObject. Adds the objects to the dictionary. If aKey was already in the dictionary, makes anObject the value for this key and returns the old value. Otherwise returns nil.
atKeySTR:put:-atKeySTR:(STR)strKeyput:anObjectAssociates strKey to anObject. Adds the objects to the dictionary. If strKey was already in the dictionary, makes anObject the value for this key and returns the old value. Otherwise returns nil.
eachKey-eachKeyReturns a sequence of the key objects in the dictionary.
See also: eachValuekeys = [aDic eachKey]; while ((aKey = [aSeq next])) { /* do something */ } keys = [keys free];
eachValue-eachValueReturns a sequence of the value objects in the dictionary.
See also: eachKeykeys = [aDic eachKey]; values = [aDic eachValue]; while ((aKey = [aSeq next])) { aValue = [values next]; /* do something */ } keys = [keys free]; values = [values free];
removeKey:-removeKey:keyRemove key from the receiver and return value for given key. If key is not in the receiver, notify an error.
removeKey:ifAbsent:-removeKey:keyifAbsent:aBlockRemove key (and its associated value) from the receiver. If key is not in the receiver, answers the result of evaluating aBlock. Otherwise, answers the value externally named by key.
keysDo:-keysDo:aBlockThe keysDo: message iterates through all the Dictionary elements, running a one-argument block of code specified by the aBlock argument with the argument set to the key of each assocation.
printOn:-printOn:(IOD)aFilePrints a comma separated list of the key-value pairs by sending each individual object a printOn: message. Returns the receiver.
|