#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Tue, 24 Jan 2017 15:58:04 +0100
changeset 21280 df927d1ac910
parent 21279 1a289f0af818
child 21281 80ad9244079f
#FEATURE by cg class: OrderedDictionary added: #firstKey #lastKey
OrderedDictionary.st
--- a/OrderedDictionary.st	Tue Jan 24 12:22:23 2017 +0100
+++ b/OrderedDictionary.st	Tue Jan 24 15:58:04 2017 +0100
@@ -313,6 +313,28 @@
     "
 !
 
+firstKey
+    "Return the first key of the receiver.  
+     Raises an error if the receiver contains no elements."
+
+    ^ order first
+
+    "
+     OrderedDictionary new first
+     OrderedDictionary new firstKey
+
+     OrderedDictionary new
+        at:'foo' put:'Foo';
+        at:'bar' put:'Bar';
+        first
+
+     OrderedDictionary new
+        at:'foo' put:'Foo';
+        at:'bar' put:'Bar';
+        firstKey
+    "
+!
+
 keyAt:index
     "get the key at the given index"
 
@@ -354,6 +376,28 @@
     "
 !
 
+lastKey
+    "Return the last key of the receiver.  
+     Raises an error if the receiver contains no elements."
+
+    ^ order last
+
+    "
+     OrderedDictionary new last
+     OrderedDictionary new lastKey
+
+     OrderedDictionary new
+        at:'foo' put:'Foo';
+        at:'bar' put:'Bar';
+        last
+
+     OrderedDictionary new
+        at:'foo' put:'Foo';
+        at:'bar' put:'Bar';
+        lastKey
+    "
+!
+
 order
     "returns the keys in the order of their appearance"