#REFACTORING by stefan
class: Collection
changed:
#values
#withAll:
--- a/Collection.st Thu Jul 21 19:24:18 2016 +0200
+++ b/Collection.st Thu Jul 21 22:43:49 2016 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -251,11 +253,9 @@
"return a new Collection with all elements taken from the argument,
aCollection"
- |newCollection|
-
- newCollection := self new.
- newCollection addAll:aCollection.
- ^newCollection
+ ^ self new
+ addAll:aCollection;
+ yourself.
!
withSize:n
@@ -941,11 +941,15 @@
"return a collection containing all values of the receiver.
This is to make value access to an OrderedDictionary compatible with any-Collection"
- |aCollection|
-
- aCollection := OrderedCollection new.
- self do:[:value| aCollection add:value].
- ^ aCollection
+ ^ OrderedCollection new
+ addAll:self;
+ yourself.
+
+ "
+ #(1 2 3 4 5) values
+ #(1 2 3 4 5) asSet values
+ #(1 2 3 4 5) asOrderedSet values
+ "
! !
!Collection methodsFor:'adding & removing'!
@@ -4331,7 +4335,7 @@
aStream nextPut:$)
"
- #(1 2 3 'hello' $a $ü) printOn:Transcript
+ #(1 2 3 'hello' $a $ü) printOn:Transcript
(Array new:100000) printOn:Transcript
(Array new:100000) printOn:Stdout
(Array new:100000) printString size
@@ -5677,7 +5681,7 @@
includesAll:aCollection
"return true, if the receiver includes all elements of
the argument, aCollection; false if any is missing.
- Notice: this method has O² runtime behavior and may be
+ Notice: this method has O² runtime behavior and may be
slow for big receivers/args.
Think about using a Set, or Dictionary."
@@ -5697,7 +5701,7 @@
Return false if it includes none.
Uses #= (value compare)
Notice:
- this method has O² runtime behavior for some subclasses and may be slow for big receivers/args.
+ 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.
@@ -5767,7 +5771,7 @@
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.
+ 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."