much better #asArray
authorClaus Gittinger <cg@exept.de>
Sat, 08 May 1999 14:52:11 +0200
changeset 4153 3481f2a3429c
parent 4152 0c1780ae527f
child 4154 6938d9274ee4
much better #asArray
OrdColl.st
OrderedCollection.st
--- a/OrdColl.st	Thu May 06 21:14:18 1999 +0200
+++ b/OrdColl.st	Sat May 08 14:52:11 1999 +0200
@@ -989,12 +989,20 @@
 asArray 
     "return the receiver as an array."
 
-    |newArray sz|
+    ^ contentsArray copyFrom:firstIndex to:lastIndex
 
-    sz := self size.
-    newArray := Array new:sz.
-    newArray replaceFrom:1 to:sz with:contentsArray startingAt:firstIndex.
-    ^ newArray
+"/    |newArray sz|
+"/
+"/    sz := self size.
+"/    newArray := Array new:sz.
+"/    newArray replaceFrom:1 to:sz with:contentsArray startingAt:firstIndex.
+"/    ^ newArray
+
+    "
+     OrderedCollection new asArray
+     OrderedCollection new add:1;add:2;asArray 
+     OrderedCollection new add:1;removeFirst;asArray 
+    "
 
     "
      |o rnd|
@@ -1625,10 +1633,18 @@
 !OrderedCollection methodsFor:'private accessing'!
 
 contentsArray
+    "return the orderedCollections underlying contentsArray.
+     The actual elements are found here starting at firstIndex,
+     and ending at lastIndex."
+
     ^ contentsArray
 !
 
 firstIndex
+    "return the index of my first element in my underlying contentsArray.
+     The actual elements are found starting this index,
+     and ending at lastIndex."
+
     ^ firstIndex
 ! !
 
@@ -1775,5 +1791,5 @@
 !OrderedCollection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/OrdColl.st,v 1.70 1999-03-19 20:47:30 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/OrdColl.st,v 1.71 1999-05-08 12:52:11 cg Exp $'
 ! !
--- a/OrderedCollection.st	Thu May 06 21:14:18 1999 +0200
+++ b/OrderedCollection.st	Sat May 08 14:52:11 1999 +0200
@@ -989,12 +989,20 @@
 asArray 
     "return the receiver as an array."
 
-    |newArray sz|
+    ^ contentsArray copyFrom:firstIndex to:lastIndex
 
-    sz := self size.
-    newArray := Array new:sz.
-    newArray replaceFrom:1 to:sz with:contentsArray startingAt:firstIndex.
-    ^ newArray
+"/    |newArray sz|
+"/
+"/    sz := self size.
+"/    newArray := Array new:sz.
+"/    newArray replaceFrom:1 to:sz with:contentsArray startingAt:firstIndex.
+"/    ^ newArray
+
+    "
+     OrderedCollection new asArray
+     OrderedCollection new add:1;add:2;asArray 
+     OrderedCollection new add:1;removeFirst;asArray 
+    "
 
     "
      |o rnd|
@@ -1625,10 +1633,18 @@
 !OrderedCollection methodsFor:'private accessing'!
 
 contentsArray
+    "return the orderedCollections underlying contentsArray.
+     The actual elements are found here starting at firstIndex,
+     and ending at lastIndex."
+
     ^ contentsArray
 !
 
 firstIndex
+    "return the index of my first element in my underlying contentsArray.
+     The actual elements are found starting this index,
+     and ending at lastIndex."
+
     ^ firstIndex
 ! !
 
@@ -1775,5 +1791,5 @@
 !OrderedCollection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/OrderedCollection.st,v 1.70 1999-03-19 20:47:30 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/OrderedCollection.st,v 1.71 1999-05-08 12:52:11 cg Exp $'
 ! !