Collection.st
branchjv
changeset 20229 b5cdb27022c8
parent 20220 874c664d2cbd
parent 20226 53626d2fd697
child 20343 0719a15ae26d
--- a/Collection.st	Wed Aug 10 07:04:17 2016 +0200
+++ b/Collection.st	Thu Aug 11 06:44:08 2016 +0200
@@ -819,7 +819,7 @@
 
 lastIfEmpty:exceptionValue
     "return the last element of the collection.
-     If its empty, return the exceptionValue.
+     If it is empty, return the exceptionValue.
      (i.e. don't trigger an error as done in #last)"
 
     self isEmpty ifTrue:[^ exceptionValue value].
@@ -5255,7 +5255,7 @@
 !Collection methodsFor:'set operations'!
 
 \ aCollection
-    "return a new set containing all elements of the receiver, 
+    "return a new set containing all elements of the receiver,
      which are NOT also contained in the aCollection
      For large collections you better use a Set for aCollection"
 
@@ -5271,14 +5271,14 @@
     ^ newCollection
 
     "
-     #(0 1 2 3 4 5 6 7 8 9) \ #(1 2 3) asSet  
+     #(0 1 2 3 4 5 6 7 8 9) \ #(1 2 3) asSet
      #(0 1 2 3 4 5 6 7 8 9) \ #(1 2 3)
     ('hello' \ 'l') asString
     "
 !
 
 intersect:aCollection
-    "return a new set containing all elements of the receiver, 
+    "return a new set containing all elements of the receiver,
      which are also contained in the argument collection.
      For large collections you better use a Set for self"
 
@@ -5293,13 +5293,13 @@
     ^ newCollection
 
     "
-     #(0 1 2 3 4 5 6 7 8 9) asSet intersect:#(1 2 3 11)   
-     #(0 1 2 3 4 5 6 7 8 9) intersect:#(1 2 3 11)   
+     #(0 1 2 3 4 5 6 7 8 9) asSet intersect:#(1 2 3 11)
+     #(0 1 2 3 4 5 6 7 8 9) intersect:#(1 2 3 11)
     "
 !
 
 union:aCollection
-    "return a new set containing all elements of the receiver 
+    "return a new set containing all elements of the receiver
      plus those of the aCollection"
 
     |newCollection|
@@ -5310,8 +5310,8 @@
     ^ newCollection
 
     "
-     #(0 2 4 6 8) union:#(1 3 5 7)   
-     #(0 2 4 6 8) union:#(0 1 3 5 7)   
+     #(0 2 4 6 8) union:#(1 3 5 7)
+     #(0 2 4 6 8) union:#(0 1 3 5 7)
     "
 !
 
@@ -5409,11 +5409,11 @@
 
     graph := sortStable ifTrue:[ OrderedDictionary new ] ifFalse:[ Dictionary new ].
 
-    self do:[:eachTuple| 
+    self do:[:eachTuple|
         |node1|
         node1 := eachTuple first.
         graph at:node1 ifAbsentPut:[OrderedCollection with:0].
-        2 to:(eachTuple size) do:[:i| 
+        2 to:(eachTuple size) do:[:i|
             |node2 n2|
 
             node2 := eachTuple at:i.
@@ -5425,7 +5425,7 @@
             n2 at:1 put:(n2 first + 1).
             node1 := node2.
         ].
-    ]. 
+    ].
 
     "now find the root nodes (having zero incoming arcs)"
     roots := OrderedCollection new.
@@ -5439,7 +5439,7 @@
      This may cause referenced nodes to be moved to the root"
 
     sorted := OrderedCollection new:graph size.
-    [roots notEmpty] whileTrue:[  
+    [roots notEmpty] whileTrue:[
         |root eachEntry|
 
         root := roots removeFirst.
@@ -5495,11 +5495,11 @@
      #((1 2) (2 3) (3 4) (4 1)) topologicalSort
      #((1 1) (1 2) (1 3) (3 2) (4)) topologicalSort
 
-     (Smalltalk allClasses collect:[:eachClass| 
+     (Smalltalk allClasses collect:[:eachClass|
         Array with:eachClass superclass with:eachClass
      ]) topologicalSort.
 
-     ((Smalltalk allClasses asSortedCollection:[:a :b| a name < b name])collect:[:eachClass| 
+     ((Smalltalk allClasses asSortedCollection:[:a :b| a name < b name])collect:[:eachClass|
         Array with:eachClass superclass with:eachClass
      ]) topologicalSort
     "
@@ -5711,7 +5711,7 @@
     "
 
     |mySize searchedSize|
-    
+
     mySize := self size.
     searchedSize := searchedElementsCollection size.
     "/ avoid this only for big receivers, due to caching effects
@@ -5736,7 +5736,7 @@
      coll := (1 to:10000) asOrderedCollection.
      Time millisecondsToRun:[
         1000000 timesRepeat:[ coll includesAny:#(500 600) ]
-     ]. 
+     ].
 
      |coll|
      coll := (1 to:10000) asOrderedCollection.
@@ -5751,13 +5751,13 @@
      coll at:500 put:$b.
      Time millisecondsToRun:[
         100000 timesRepeat:[ coll includesAny:'bc' ]
-     ].       
+     ].
 
      |coll|
      coll := String new:10000 withAll:$a.
      Time millisecondsToRun:[
         100000 timesRepeat:[ coll includesAny:'bc' ]
-     ].   
+     ].
 
     "
 
@@ -5765,12 +5765,12 @@
 !
 
 includesAnyIdentical:searchedElementsCollection
-    "return true, if the receiver includes any from the argument, aCollection. 
+    "return true, if the receiver includes any from the argument, aCollection.
      Return false if it includes none.
      Use identity compare for comparing.
-     Notice: 
-        this method has OČ runtime behavior for some subclasses and may be slow for big receivers/args. 
-        Think about using a Set or Dictionary. 
+     Notice:
+        this method has OČ runtime behavior for some subclasses and may be slow for big receivers/args.
+        Think about using a Set or Dictionary.
         Some speedup is also possible, by arranging highly
         probable elements towards the beginning of aCollection, to avoid useless searches."