|
Class: VirtualArray
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
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.
LazyArray
instance creation
-
new: size
-
(comment from inherited method)
return an instance of myself with anInteger indexed variables
accessing
-
generator
-
the element value generator; a block which gets the index as argument
-
generator: aBlock
-
set the element value generator; a block which gets the index as argument
-
setSize: anInteger
-
-
size
-
the virtual size
collection protocol
-
at: index
-
(comment from inherited method)
return the indexed instance variable with index, anInteger;
this method can be redefined in subclasses.
-
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)
-
grow: howBig
-
change the receiver's size
inspecting
-
displayOn: aGCOrStream
-
print a representation of the receiver on aGCOrStream for display in inspectors etc.
queries
-
species
-
return the type of collection to be returned by collect, select etc.
|squaresLines|
squaresLines := VirtualArray new:100000.
squaresLines generator:[:index | index squared printString].
squaresLines inspect.
(TextView openWith:#()) list:squaresLines expandTabs:false
|
|