#DOCUMENTATION by mawalch
authormawalch
Wed, 10 Aug 2016 16:21:08 +0200
changeset 20228 54e93c9d0126
parent 20227 4090cde0c345
child 20229 b5cdb27022c8
child 20230 47a4de3366cf
#DOCUMENTATION by mawalch class: Dictionary
Dictionary.st
--- a/Dictionary.st	Wed Aug 10 16:10:31 2016 +0200
+++ b/Dictionary.st	Wed Aug 10 16:21:08 2016 +0200
@@ -41,7 +41,7 @@
     a Dictionary is (conceptionally) a set of Associations storing key-value pairs.
     (The implementation uses two arrays to store the keys and values separately.)
     Searching for an element is done using a hash into the key array.
-    Another way of looking at a dictionary is as a array which uses
+    Another way of looking at a dictionary is as an array that uses
     arbitrary access keys (i.e. not just integers as arrays do).
 
     Since the keys are unordered, no internal element order is defined
@@ -131,7 +131,7 @@
     d2 := Dictionary newFrom:d1.
     d2.
                                                                         [exEnd]
-                                                                            
+
 "
 ! !
 
@@ -216,7 +216,7 @@
     ^ d
 
     "
-     Dictionary withKeys:#(10 20 30 40 50 60 70 80 90) valueBlock:[:e| e asString] 
+     Dictionary withKeys:#(10 20 30 40 50 60 70 80 90) valueBlock:[:e| e asString]
     "
 !
 
@@ -251,7 +251,7 @@
     ^ d
 
     "
-     Dictionary withValues:#(10 20 30 40 50 60 70 80 90) keyBlock:[:e| e asString] 
+     Dictionary withValues:#(10 20 30 40 50 60 70 80 90) keyBlock:[:e| e asString]
     "
 ! !
 
@@ -269,7 +269,7 @@
     "
      Dictionary newFrom:{#foo -> #Foo. #bar -> #Bar}
 
-     Dictionary 
+     Dictionary
         newFrom:(Dictionary withKeysAndValues:#('one' 1 'two' 2 'three' 3 'four' 4))
     "
 ! !
@@ -296,7 +296,6 @@
 ! !
 
 
-
 !Dictionary methodsFor:'accessing'!
 
 associationAt:aKey
@@ -371,8 +370,8 @@
     ^ exceptionBlock value.
 !
 
-at:aKey ifAbsent:default update:aBlock 
-    "update the element stored under aKey with the result from 
+at:aKey ifAbsent:default update:aBlock
+    "update the element stored under aKey with the result from
      evaluating aBlock with the previous stored value as argument, or with default,
      if there was no such key initially.
      I.e. this is the same as self at:aKey put:(aBlock value:(self at:aKey ifAbsent:default)).
@@ -482,7 +481,7 @@
      |d|
      d := Dictionary new.
      d at:#foo put:'yes this is foo'.
-     
+
      d at:#foo ifPresent:[:val | Transcript showCR:'the value of foo is: ',val].
      d at:#bar ifPresent:[:val | Transcript showCR:'the value of bar is: ',val].
     "
@@ -533,7 +532,7 @@
     index := self findKeyOrNil:k.
     (keyArray basicAt:index) notNil ifTrue:[
         "/ key already present
-        ^ aBlock value:(valueArray basicAt:index). 
+        ^ aBlock value:(valueArray basicAt:index).
     ].
     "/ a new key
     keyArray basicAt:index put:k.
@@ -552,8 +551,8 @@
     "
 !
 
-at:aKey update:aBlock 
-    "update the element stored under aKey with the result from 
+at:aKey update:aBlock
+    "update the element stored under aKey with the result from
      evaluating aBlock with the previous stored value as argument.
      Report an error if there was no such key initially.
      I.e. this is the same as self at:aKey put:(aBlock value:(self at:aKey)).
@@ -958,7 +957,7 @@
     "Modified: 1.3.1996 / 21:21:11 / cg"
 !
 
-removeIdentityValue:aValue ifAbsent:aBlock 
+removeIdentityValue:aValue ifAbsent:aBlock
     "remove (first) the association to aValue from the collection,
      return the key under which it was stored previously.
      If it was not in the collection return result from evaluating aBlock.
@@ -973,8 +972,8 @@
     |next   "{ Class:SmallInteger }"
      oldKey|
 
-    keyArray 
-        keysAndValuesDo:[:index :aKey | 
+    keyArray
+        keysAndValuesDo:[:index :aKey |
             |idx "{Class:SmallInteger}"|
 
             (aKey notNil and:[ aKey ~~ DeletedEntry ]) ifTrue:[
@@ -2176,7 +2175,7 @@
 !Dictionary methodsFor:'searching'!
 
 findFirst:aBlock ifNone:exceptionValue
-    "find the index of the first element, for which evaluation of the argument, aBlock returns true; 
+    "find the index of the first element, for which evaluation of the argument, aBlock returns true;
      return its index or the value from exceptionValue if none detected.
      This is much like #detect:ifNone:, however, here an INDEX is returned,
      while #detect:ifNone: returns the element.