Iterator.st
changeset 885 c31412b26306
parent 878 0bef2108e3a9
child 890 40421d1c3377
--- a/Iterator.st	Fri Feb 18 15:40:57 2000 +0100
+++ b/Iterator.st	Thu Mar 02 15:15:13 2000 +0100
@@ -1,3 +1,5 @@
+"{ Package: 'stx:goodies' }"
+
 "
  COPYRIGHT.
  The above file is a Manchester Goodie protected by copyright.
@@ -100,78 +102,78 @@
 examples
 "
  an iterator, simulating the collection of all classes in the system:
-                                                                        [exBegin]
+									[exBegin]
      |i b|
 
      b := [:whatToDo |
-               Smalltalk allClassesDo:[:cls | 
-                  whatToDo value:cls
-               ] 
-          ].
+	       Smalltalk allClassesDo:[:cls | 
+		  whatToDo value:cls
+	       ] 
+	  ].
 
      i := Iterator on:b.
      i do:[:cls |
-        Transcript showCR:cls name
+	Transcript showCR:cls name
      ].
-                                                                        [exEnd]
+									[exEnd]
  much like above, one that simulates the collection of all methodNames starting with 'a':
-                                                                        [exBegin]
+									[exBegin]
      |i b|
 
      b := [:whatToDo |
-               Smalltalk allClassesDo:[:cls |
-                  cls methodDictionary keysAndValuesDo:[:nm :mthd |
-                    (nm startsWith:$a) ifTrue:[
-                       whatToDo value:nm
-                     ]
-                  ]
-               ] 
-          ].
+	       Smalltalk allClassesDo:[:cls |
+		  cls methodDictionary keysAndValuesDo:[:nm :mthd |
+		    (nm startsWith:$a) ifTrue:[
+		       whatToDo value:nm
+		     ]
+		  ]
+	       ] 
+	  ].
 
      i := Iterator on:b.
      i do:[:nm |
-        Transcript showCR:nm
+	Transcript showCR:nm
      ].
-                                                                        [exEnd]
+									[exEnd]
  an iterator, simulating a collection of 100 random values:
-                                                                        [exBegin]
+									[exBegin]
      |i b|
 
      b := [:whatToDo |
-               |rnd|
+	       |rnd|
 
-               rnd := Random new.
-               1 to:100 do:[:i | 
-                  whatToDo value:(rnd next)
-               ] 
-          ].
+	       rnd := Random new.
+	       1 to:100 do:[:i | 
+		  whatToDo value:(rnd next)
+	       ] 
+	  ].
 
      i := Iterator on:b.
      i do:[:j |
-        j printNL
+	j printNL
      ].
-                                                                        [exEnd]
+									[exEnd]
  an iterator, simulating a collection of the lines
  in a file:
-                                                                        [exBegin]
+									[exBegin]
      |i b|
 
      b := [:whatToDo |
-               |s line|
+	       |s line|
 
-               s := 'smalltalk.rc' asFilename readStream.
-               [s atEnd] whileFalse:[
-                  line := s nextLine.
-                  whatToDo value:line.
-               ].
-               s close
-          ].
+	       s := 'smalltalk.rc' asFilename readStream.
+	       [s atEnd] whileFalse:[
+		  line := s nextLine.
+		  whatToDo value:line.
+	       ].
+	       s close
+	  ].
 
      i := Iterator on:b.
      i do:[:j |
-        j printNL
+	j printNL
      ].
-                                                                        [exEnd]
+									[exEnd]
 "
 ! !
 
@@ -357,5 +359,5 @@
 !Iterator class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Iterator.st,v 1.7 2000-02-05 14:29:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Iterator.st,v 1.8 2000-03-02 14:14:24 cg Exp $'
 ! !