Array.st
changeset 10796 08a9ee8cf317
parent 10089 833fffc641ef
child 11167 883813e7d746
--- a/Array.st	Wed Nov 21 11:10:09 2007 +0100
+++ b/Array.st	Wed Nov 21 11:10:11 2007 +0100
@@ -278,6 +278,7 @@
     "Modified: 23.4.1996 / 15:55:06 / cg"
 ! !
 
+
 !Array methodsFor:'accessing'!
 
 at:index
@@ -507,6 +508,28 @@
 
 !Array methodsFor:'enumerating'!
 
+addAllNonNilElementsTo:aCollection
+    "add all nonNil elements of the receiver to aCollection.
+     Return aCollection.
+     Redefined here for slightly more speed."
+
+    |stop "{ Class: SmallInteger }"|
+
+    stop := self size.
+    1 to:stop do:[:idx |
+        |each|
+        each := self at:idx.
+        each notNil ifTrue:[
+            aCollection add:each.
+        ].
+    ].
+    ^ aCollection
+
+    "
+     #(1 2 3 4 5 1 2 3 symbol 'string' nil) addAllNonNilElementsTo:Set new
+    "
+!
+
 addAllTo:aCollection
     "add all elements of the receiver to aCollection.
      Return aCollection.
@@ -2496,5 +2519,5 @@
 !Array class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.142 2006-10-13 11:01:35 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.143 2007-11-21 10:10:11 stefan Exp $'
 ! !