Add method #findFirstKey:
authorStefan Vogel <sv@exept.de>
Thu, 13 Jun 1996 00:07:54 +0200
changeset 1460 370226bb8fd7
parent 1459 debce52d633b
child 1461 dd25bb1e9973
Add method #findFirstKey:
Dict.st
Dictionary.st
--- a/Dict.st	Mon Jun 10 20:27:05 1996 +0200
+++ b/Dict.st	Thu Jun 13 00:07:54 1996 +0200
@@ -10,6 +10,8 @@
  hereby transferred.
 "
 
+'From Smalltalk/X, Version:2.10.9 on 11-jun-1996 at 16:33:26'                   !
+
 Set subclass:#Dictionary
 	instanceVariableNames:'valueArray'
 	classVariableNames:''
@@ -1249,6 +1251,20 @@
     ^ Array basicNew:n
 ! !
 
+!Dictionary methodsFor:'searching'!
+
+findFirstKey:aBlock
+    "find and return the first key, for which evaluation of the argument, aBlock
+     returns true; return nil if none detected."
+
+    self keysDo:[:key |
+        (aBlock value:key) ifTrue:[^ key].
+    ].
+    ^ nil
+
+    "Created: 5.6.1996 / 11:55:50 / stefan"
+! !
+
 !Dictionary methodsFor:'testing'!
 
 includes:anObject
@@ -1306,5 +1322,5 @@
 !Dictionary class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/Dict.st,v 1.42 1996-05-20 15:47:19 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/Dict.st,v 1.43 1996-06-12 22:07:54 stefan Exp $'
 ! !
--- a/Dictionary.st	Mon Jun 10 20:27:05 1996 +0200
+++ b/Dictionary.st	Thu Jun 13 00:07:54 1996 +0200
@@ -10,6 +10,8 @@
  hereby transferred.
 "
 
+'From Smalltalk/X, Version:2.10.9 on 11-jun-1996 at 16:33:26'                   !
+
 Set subclass:#Dictionary
 	instanceVariableNames:'valueArray'
 	classVariableNames:''
@@ -1249,6 +1251,20 @@
     ^ Array basicNew:n
 ! !
 
+!Dictionary methodsFor:'searching'!
+
+findFirstKey:aBlock
+    "find and return the first key, for which evaluation of the argument, aBlock
+     returns true; return nil if none detected."
+
+    self keysDo:[:key |
+        (aBlock value:key) ifTrue:[^ key].
+    ].
+    ^ nil
+
+    "Created: 5.6.1996 / 11:55:50 / stefan"
+! !
+
 !Dictionary methodsFor:'testing'!
 
 includes:anObject
@@ -1306,5 +1322,5 @@
 !Dictionary class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Dictionary.st,v 1.42 1996-05-20 15:47:19 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Dictionary.st,v 1.43 1996-06-12 22:07:54 stefan Exp $'
 ! !