#REFACTORING by cg
authorClaus Gittinger <cg@exept.de>
Mon, 17 Jul 2017 17:24:50 +0200
changeset 22048 0f68f6c65142
parent 22047 e606eb029294
child 22049 0ab597f24699
#REFACTORING by cg class: OrderedDictionary added: #firstAssociation #lastAssociation removed: #firstValue #lastValue changed: #first #last first and last are protocol compatible to Dictionary!
OrderedDictionary.st
--- a/OrderedDictionary.st	Mon Jul 17 17:24:13 2017 +0200
+++ b/OrderedDictionary.st	Mon Jul 17 17:24:50 2017 +0200
@@ -303,10 +303,10 @@
 !
 
 first
-    "Return the first association of the receiver.  
+    "Return the first value of the receiver.  
      Provide an error notification if the receiver contains no elements."
 
-    ^ self associationAt: (order first)
+    ^ (self associationAt: (order first)) value
 
     "
      OrderedDictionary new first
@@ -314,9 +314,28 @@
      (OrderedDictionary new at:'one' put:1; yourself) first
      (OrderedDictionary new at:'one' put:1; yourself) firstKey
      (OrderedDictionary new at:'one' put:1; yourself) firstValue
+     (OrderedDictionary new at:'one' put:1; yourself) firstAssociation
     "
 
-    "Modified (comment): / 17-07-2017 / 17:01:33 / cg"
+    "Modified (comment): / 17-07-2017 / 17:21:54 / cg"
+!
+
+firstAssociation
+    "Return the first association of the receiver.  
+     Provide an error notification if the receiver contains no elements."
+
+    ^ self associationAt: (order first)
+
+    "
+     OrderedDictionary new firstAssociation
+     OrderedDictionary new first
+
+     (OrderedDictionary new at:'one' put:1; yourself) first
+     (OrderedDictionary new at:'one' put:1; yourself) firstKey
+     (OrderedDictionary new at:'one' put:1; yourself) firstValue
+    "
+
+    "Created: / 17-07-2017 / 17:21:06 / cg"
 !
 
 firstKey
@@ -348,22 +367,6 @@
     "Modified (comment): / 17-07-2017 / 17:01:17 / cg"
 !
 
-firstValue
-    "Return the first value of the receiver.  
-     Provide an error notification if the receiver contains no elements."
-
-    ^ (self associationAt: (order first)) value
-
-    "
-     OrderedDictionary new first
-     (OrderedDictionary new at:'one' put:1; yourself) first
-     (OrderedDictionary new at:'one' put:1; yourself) firstKey
-     (OrderedDictionary new at:'one' put:1; yourself) firstValue
-    "
-
-    "Created: / 17-07-2017 / 17:00:33 / cg"
-!
-
 keyAt:index
     "get the key at the given index"
 
@@ -395,10 +398,10 @@
 !
 
 last
-    "Return the last association of the receiver. 
+    "Return the last value of the receiver. 
      Provide an error notification if the receiver contains no elements."
 
-    ^ self associationAt: (order last)
+    ^ self associationAt: (order last) value
 
     "
      OrderedDictionary new last
@@ -408,7 +411,26 @@
      (OrderedDictionary new at:'one' put:1; yourself) lastValue
     "
 
-    "Modified (comment): / 17-07-2017 / 17:01:49 / cg"
+    "Modified (comment): / 17-07-2017 / 17:23:03 / cg"
+!
+
+lastAssociation
+    "Return the last association of the receiver. 
+     Provide an error notification if the receiver contains no elements."
+
+    ^ self associationAt: (order last)
+
+    "
+     OrderedDictionary new lastAssociation
+     OrderedDictionary new last
+
+     (OrderedDictionary new at:'one' put:1; at:'two' put:2;  at:'one' put:111; yourself) lastAssociation
+     (OrderedDictionary new at:'one' put:1; at:'two' put:2;  at:'one' put:111; yourself) last
+     (OrderedDictionary new at:'one' put:1; at:'two' put:2;  at:'one' put:111; yourself) lastKey
+     (OrderedDictionary new at:'one' put:1; at:'two' put:2;  at:'one' put:111; yourself) lastValue
+    "
+
+    "Created: / 17-07-2017 / 17:22:40 / cg"
 !
 
 lastKey
@@ -433,30 +455,6 @@
     "
 !
 
-lastValue
-    "Return the last value of the receiver. 
-     Provide an error notification if the receiver contains no elements."
-
-    ^ (self associationAt: (order last)) value
-
-    "
-     OrderedDictionary new last
-     OrderedDictionary new lastValue
-
-     OrderedDictionary new
-        at:'foo' put:'Foo';
-        at:'bar' put:'Bar';
-        lastValue
-
-     OrderedDictionary new
-        at:'foo' put:'Foo';
-        at:'bar' put:'Bar';
-        lastValue
-    "
-
-    "Created: / 17-07-2017 / 17:00:18 / cg"
-!
-
 order
     "returns the keys in the order of their appearance"