Dictionary.st
branchjv
changeset 18043 03660093fe98
parent 18040 a11a12546f23
parent 15008 a474f18209d4
child 18063 4a8226cd76ab
--- a/Dictionary.st	Thu Mar 28 12:21:50 2013 +0000
+++ b/Dictionary.st	Mon Apr 01 13:42:45 2013 +0100
@@ -239,7 +239,7 @@
      by aKey -
      report an error, if no element is stored under aKey"
 
-    ^ Association key:aKey value:(self at:aKey)
+    ^ self associationAt:aKey ifAbsent:[self errorKeyNotFound:aKey]
 !
 
 associationAt:aKey ifAbsent:exceptionBlock
@@ -249,7 +249,14 @@
               the original ST80 implementation. The returned assoc is created on the fly,
               and not the one stored in the receiver (there are not assocs there)"
 
-    ^ Association key:aKey value:(self at:aKey ifAbsent:[^ exceptionBlock value])
+    |index|
+
+    "/ must return the real key in the assoc - not aKey, which might be equal but not identical
+    index := self find:aKey ifAbsent:0.
+    index ~~ 0 ifTrue:[
+        ^ Association key:(keyArray basicAt:index) value:(valueArray basicAt:index)
+    ].
+    ^ exceptionBlock value
 !
 
 associations
@@ -1134,6 +1141,12 @@
     ^ self
 !
 
+asNewDictionary
+    "return myself as an unique new dictionary"
+
+    ^ self copy
+!
+
 associationsOrderedBy:aCollectionOfKeys
     "return an OrderedCollection of my key-value pairs, ordered by the given key list"
 
@@ -2058,10 +2071,10 @@
 !Dictionary class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Dictionary.st,v 1.110 2013-03-26 17:04:43 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Dictionary.st,v 1.112 2013-03-31 02:36:38 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Dictionary.st,v 1.110 2013-03-26 17:04:43 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Dictionary.st,v 1.112 2013-03-31 02:36:38 cg Exp $'
 ! !