Squeak Class Documentation category index | class index  
 
Dictionary
  category: Collections-Unordered
  superclass: Set
  subclasses: IdentityDictionary HtmlAttributes WeakKeyDictionary WeakValueDictionary PluggableDictionary LiteralDictionary MethodDictionary

I represent a set of elements that can be viewed from one of two perspectives: a set of associations, or a set of values that are externally named where the name can be any object that responds to =. The external name is referred to as the key.

instance methods
  accessing
  associationAt:
associationAt:ifAbsent:
associationDeclareAt:
at:
at:ifAbsent:
at:ifAbsentPut:
at:ifPresent:
at:ifPresentAndInMemory:
at:put:
keyAtIdentityValue:
keyAtIdentityValue:ifAbsent:
keyAtValue:
keyAtValue:ifAbsent:
keys
keysSortedSafely
values

  adding
  add:
declare:from:

  enumerating
  associationsDo:
collect:
do:
keysAndValuesDo:
keysDo:
select:
valuesDo:

  printing
  flattenOnStream:
printElementsOn:
storeOn:

  private
  copy
errorKeyNotFound
errorValueNotFound
keyAt:
noCheckAdd:
rehash
scanFor:
valueAtNewKey:put:atIndex:declareFrom:

  removing
  keysAndValuesRemove:
remove:
remove:ifAbsent:
removeKey:
removeKey:ifAbsent:
removeUnreferencedKeys
unreferencedKeys

  testing
  =
hasContentsInExplorer
includes:
includesIdentity:
includesKey:
keyForIdentity:
occurrencesOf:

  user interface
  inspect
inspectFormsWithLabel:
inspectWithLabel:

class methods
  instance creation
  newFrom:

instance methods
  accessing top  
 

associationAt:


 

associationAt:ifAbsent:

Answer the association with the given key.
If key is not found, return the result of evaluating aBlock.


 

associationDeclareAt:

Return an existing association, or create and return a new one. Needed as a single message by ImageSegment.prepareToBeSaved.


 

at:

Answer the value associated with the key.


 

at:ifAbsent:

Answer the value associated with the key or, if key isn't found,
answer the result of evaluating aBlock.


 

at:ifAbsentPut:

Return the value at the given key.
If key is not included in the receiver store the result
of evaluating aBlock as new value.


 

at:ifPresent:

Lookup the given key in the receiver. If it is present, answer the value of evaluating the given block with the value associated with the key. Otherwise, answer nil.


 

at:ifPresentAndInMemory:

Lookup the given key in the receiver. If it is present, answer the value of evaluating the given block with the value associated with the key. Otherwise, answer nil.


 

at:put:

Set the value at key to be anObject. If key is not found, create a
new entry for key and set is value to anObject. Answer anObject.


 

keyAtIdentityValue:

Answer the key that is the external name for the argument, value. If
there is none, answer nil.
Note: There can be multiple keys with the same value. Only one is returned.


 

keyAtIdentityValue:ifAbsent:

Answer the key that is the external name for the argument, value. If
there is none, answer the result of evaluating exceptionBlock.
Note: There can be multiple keys with the same value. Only one is returned.


 

keyAtValue:

Answer the key that is the external name for the argument, value. If
there is none, answer nil.


 

keyAtValue:ifAbsent:

Answer the key that is the external name for the argument, value. If
there is none, answer the result of evaluating exceptionBlock.
: Use =, not ==, so stings like 'this' can be found. Note that MethodDictionary continues to use == so it will be fast.


 

keys

Answer a Set containing the receiver's keys.


 

keysSortedSafely

Answer a SortedCollection containing the receiver's keys.


 

values

Answer a Collection containing the receiver's values.


  adding top  
 

add:

Include newObject as one of the receiver's elements, but only if
not already present. Answer newObject.


 

declare:from:

Add key to the receiver. If key already exists, do nothing. If aDictionary
includes key, then remove it from aDictionary and use its association as
the element of the receiver.


  enumerating top  
 

associationsDo:

Evaluate aBlock for each of the receiver's elements (key/value
associations).


 

collect:

Evaluate aBlock with each of my values as the argument. Collect the
resulting values into a collection that is like me. Answer with the new
collection.


 

do:

Evaluate aBlock with each of the receiver's elements as the argument.


 

keysAndValuesDo:


 

keysDo:

Evaluate aBlock for each of the receiver's keys.


 

select:

Evaluate aBlock with each of my values as the argument. Collect into a
new dictionary, only those associations for which aBlock evaluates to
true.


 

valuesDo:

Evaluate aBlock for each of the receiver's keys.


  printing top  
 

flattenOnStream:


 

printElementsOn:


 

storeOn:

Refer to the comment in Object|storeOn:.


  private top  
 

copy

Must copy the associations, or later store will effect both the
original and the copy


 

errorKeyNotFound


 

errorValueNotFound


 

keyAt:

May be overridden by subclasses so that fixCollisions will work


 

noCheckAdd:

Must be defined separately for Dictionary because (self findElementOrNil:) expects a key, not an association. 9/7/96 tk


 

rehash

Smalltalk rehash.


 

scanFor:

Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or zero if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements.


 

valueAtNewKey:put:atIndex:declareFrom:

Support for coordinating class variable and global declarations
with variables that have been put in Undeclared so as to
redirect all references to the undeclared variable.


  removing top  
 

keysAndValuesRemove:

Removes all entries for which keyValueBlock returns true.


 

remove:

Remove oldObject from the receiver's elements. Answer oldObject
unless no element is equal to oldObject, in which case, raise an error.
ArrayedCollections cannot respond to this message.


 

remove:ifAbsent:

Remove oldObject from the receiver's elements. If several of the
elements are equal to oldObject, only one is removed. If no element is
equal to oldObject, answer the result of evaluating anExceptionBlock.
Otherwise, answer the argument, oldObject. ArrayedCollections cannot
respond to this message.


 

removeKey:

Remove key from the receiver.
If key is not in the receiver, notify an error.


 

removeKey:ifAbsent:

Remove key (and its associated value) from the receiver. If key is not in
the receiver, answer the result of evaluating aBlock. Otherwise, answer
the value externally named by key.


 

removeUnreferencedKeys

Undeclared removeUnreferencedKeys


 

unreferencedKeys

TextConstants unreferencedKeys


  testing top  
 

=

Equal if it has my keys, is same size, and has the same corresponding value associated with each key.


 

hasContentsInExplorer


 

includes:

Answer whether anObject is one of the receiver's elements.


 

includesIdentity:

Answer whether anObject is one of the values of the receiver. Contrast #includes: in which there is only an equality check, here there is an identity check


 

includesKey:

Answer whether the receiver has a key equal to the argument, key.


 

keyForIdentity:

If anObject is one of the values of the receive, return its key, else return nil. Contrast #keyAtValue: in which there is only an equality check, here there is an identity check


 

occurrencesOf:

Answer how many of the receiver's elements are equal to anObject.


  user interface top  
 

inspect

Open a DictionaryInspector on the receiver. Use basicInspect to get a normal (less useful) type of inspector.


 

inspectFormsWithLabel:

Open a Form Dictionary inspector on the receiver, with the given label.


 

inspectWithLabel:

Open a DictionaryInspector on the receiver. Use basicInspect to get a normal (less useful) type of inspector.


class methods
  instance creation top  
 

newFrom:

Answer an instance of me containing the same associations as aDict.
Error if any key appears twice.