initial checkin
authorClaus Gittinger <cg@exept.de>
Thu, 11 Jun 2015 21:13:44 +0200
changeset 3561 c48bf6b4e364
parent 3559 fa3443d808a1
child 3562 eb7846228011
initial checkin
AutoResizingOrderedCollection.st
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AutoResizingOrderedCollection.st	Thu Jun 11 21:13:44 2015 +0200
@@ -0,0 +1,54 @@
+"{ Encoding: utf8 }"
+
+"{ Package: 'stx:libbasic2' }"
+
+"{ NameSpace: Smalltalk }"
+
+OrderedCollection subclass:#AutoResizingOrderedCollection
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Collections-Sequenceable'
+!
+
+!AutoResizingOrderedCollection class methodsFor:'documentation'!
+
+documentation
+"
+    I am an ordered collection whoch automatically resizes if elements
+    are added beyond the size. 
+    I.e. if at:put: is sent for indexes > the current size, the receiver grows to
+    the required index and missing fields are implicitly filled with nils.
+"
+!
+
+examples
+"
+    |coll|
+    
+    coll := AutoResizingOrderedCollection new.
+    coll at:4 put:'four'.
+    coll at:8 put:'eight'.
+    coll
+"
+! !
+
+!AutoResizingOrderedCollection methodsFor:'accessing'!
+
+at:index put:anObject
+    index > self size ifTrue:[
+        self grow:index.
+    ].
+    super at:index put:anObject
+! !
+
+!AutoResizingOrderedCollection class methodsFor:'documentation'!
+
+version
+    ^ '$Header$'
+!
+
+version_CVS
+    ^ '$Header$'
+! !
+