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.7 date: 2021/01/20 14:02:42
user: cg
file: LazyArray.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

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.

copyright

COPYRIGHT (c) 2003 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

initialization
o  initialize
self initialize

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


Instance protocol:

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

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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 23 Nov 2024 12:41:07 GMT