eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'LazyArray':

Home

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

Class: LazyArray


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--ArrayedCollection
            |
            +--LazyArray

Package:
stx:libbasic2
Category:
Collections-Arrayed
Version:
rev: 1.6 date: 2017/02/15 21:07:18
user: cg
file: LazyArray.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger (cg@alan)

Description:


An Array which computes its values lazily (on demand) and remembers them.
Useful if it is relatively expensive to compute an element, 
and it may be needed again later.


Related information:

    Lazy

Class protocol:

initialization
o  initialize
self initialize

instance creation
o  new: size


Instance protocol:

accessing
o  at: index

o  valueGenerator: aBlock


Private classes:

    UncomputedValue

Examples:


    |squares|

    squares := LazyArray new:100.
    squares valueGenerator:[:index | index squared].

    squares at:50.   
    squares inspect.


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Tue, 19 Mar 2024 04:08:43 GMT