eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'AutoResizingOrderedCollectionWithDefault':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: AutoResizingOrderedCollectionWithDefault


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--OrderedCollection
            |
            +--AutoResizingOrderedCollection
               |
               +--AutoResizingOrderedCollectionWithDefault

Package:
stx:libbasic2
Category:
Collections-Sequenceable
Version:
rev: 1.4 date: 2017/02/15 21:15:41
user: cg
file: AutoResizingOrderedCollectionWithDefault.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


I am an ordered collection which 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 a default value.
Queries for non-existing elements are anwered with the default value.


Related information:

    OrderedCollection
    Array
    SparseArray

Instance protocol:

accessing
o  at: index
fetch an object at index.
If index is beyond the actual size, return the default value
(i.e. this is an alias for at:index ifAbsent:[default value])

o  at: index put: anObject
store an object at index.
If required, grow the receiver to ensure that index is valid

initialization
o  setDefaultValue: v


Examples:


|coll| coll := AutoResizingOrderedCollectionWithDefault newWithDefaultValue:99. coll at:4 put:'four'. coll at:8 put:'eight'. coll at:9

ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 28 Mar 2024 19:15:49 GMT