eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'VirtualArray':

Home

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

Class: VirtualArray


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--VirtualArray
            |
            +--VirtualArrayWithCache

Package:
stx:libbasic2
Category:
Collections-Arrayed
Version:
rev: 1.11 date: 2019/03/01 19:42:41
user: cg
file: VirtualArray.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


An Array which computes its values on demand and does NOT remember those values.
This does not use any memory for the elements - however, trading speed for size, this
takes longer to access elements, as they are computed on the fly (for every access).
Use this to present huge files/hex dumps to a text editor.


Related information:

    LazyArray

Class protocol:

instance creation
o  new: size
(comment from inherited method)
return an instance of myself with anInteger indexed variables


Instance protocol:

accessing
o  generator
the element value generator; a block which gets the index as argument

o  generator: aBlock
set the element value generator; a block which gets the index as argument

o  setSize: anInteger

o  size
the virtual size

collection protocol
o  at: index
(comment from inherited method)
return the indexed instance variable with index, anInteger;
this method can be redefined in subclasses.

o  at: index put: value
(comment from inherited method)
store the 2nd arg, anObject as indexed instvar with index, anInteger.
this method can be redefined in subclasses. Returns anObject (sigh)

o  grow: howBig
change the receiver's size

inspecting
o  displayOn: aGCOrStream
print a representation of the receiver on aGCOrStream for display in inspectors etc.

queries
o  species
return the type of collection to be returned by collect, select etc.


Examples:


    |squaresLines|

    squaresLines := VirtualArray new:100000.
    squaresLines generator:[:index | index squared printString].

    squaresLines inspect.
    (TextView openWith:#()) list:squaresLines expandTabs:false


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 29 Mar 2024 14:21:55 GMT