Collection.st
changeset 9410 4baf189ccf3d
parent 9404 f0416ce9d6a2
child 9842 7deebdffbced
--- a/Collection.st	Mon Jul 03 16:50:54 2006 +0200
+++ b/Collection.st	Mon Jul 03 18:08:43 2006 +0200
@@ -1353,6 +1353,31 @@
     "
 !
 
+literalArrayEncoding
+    "encode myself as an array literal, from which a copy of the receiver
+     can be reconstructed with #decodeAsLiteralArray."
+
+    |encoding idx|
+
+    encoding := Array new:self size + 1.
+    encoding at:1 put:self class name.
+    idx := 2.
+    self do:[:element|
+	encoding at:idx put:element literalArrayEncoding.
+	idx := idx + 1.
+    ].
+    ^ encoding
+
+
+    "
+     (Array with:(Color red:50 green:50 blue:50)
+	    with:(1 @ 2)
+     ) literalArrayEncoding decodeAsLiteralArray
+    "
+
+    "Modified: 22.4.1996 / 13:00:56 / cg"
+!
+
 readStream
     "return a stream for reading from the receiver"
 
@@ -2962,7 +2987,7 @@
 !Collection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.192 2006-06-30 07:57:58 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.193 2006-07-03 16:08:43 stefan Exp $'
 ! !
 
 Collection initialize!