class: OrderedCollection
authorStefan Vogel <sv@exept.de>
Fri, 29 Mar 2013 00:21:40 +0100
changeset 14999 e6ad9751587b
parent 14998 6bea48d14676
child 15000 4d10fba9aed4
class: OrderedCollection added: #asNewOrderedCollection
OrderedCollection.st
--- a/OrderedCollection.st	Fri Mar 29 00:19:39 2013 +0100
+++ b/OrderedCollection.st	Fri Mar 29 00:21:40 2013 +0100
@@ -1051,6 +1051,24 @@
     "Modified: 13.4.1996 / 12:10:56 / cg"
 !
 
+asNewOrderedCollection 
+    "return the receiver as an ordered collection.
+     Make sure to return a unique new OrderedCollection"
+
+    "could be an instance of a subclass..."
+    self class == OrderedCollection ifTrue:[
+        ^ self copy
+    ].
+    ^ super asOrderedCollection
+
+    " 
+        |s|
+        s := #(1 2 3 4) asOrderedCollection.
+        self assert:(s ~~ s asNewOrderedCollection).
+        self assert:(s = s asNewOrderedCollection).
+     "
+!
+
 asOrderedCollection 
     "return the receiver as an ordered collection"
 
@@ -1392,6 +1410,7 @@
 ! !
 
 
+
 !OrderedCollection methodsFor:'private'!
 
 initContents:size
@@ -1940,6 +1959,6 @@
 !OrderedCollection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/OrderedCollection.st,v 1.103 2013-03-20 11:47:41 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/OrderedCollection.st,v 1.104 2013-03-28 23:21:40 stefan Exp $'
 ! !