|
Class: LazyArray
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
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.
copyrightCOPYRIGHT (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.
initialization
-
initialize
-
self initialize
instance creation
-
new: size
-
(comment from inherited method)
return an instance of myself with anInteger indexed variables
accessing
-
at: index
-
(comment from inherited method)
return the indexed instance variable with index, anInteger;
this method can be redefined in subclasses.
-
valueGenerator: aBlock
-
UncomputedValue
|squares|
squares := LazyArray new:100.
squares valueGenerator:[:index | index squared].
squares at:50.
squares inspect.
|
|