2906
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2012 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
2714
|
12 |
"{ Package: 'stx:libbasic2' }"
|
|
13 |
|
|
14 |
SequenceableCollection subclass:#VirtualArray
|
|
15 |
instanceVariableNames:'generator size'
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
|
18 |
category:'Collections-Arrayed'
|
|
19 |
!
|
|
20 |
|
|
21 |
!VirtualArray class methodsFor:'documentation'!
|
|
22 |
|
2906
|
23 |
copyright
|
|
24 |
"
|
|
25 |
COPYRIGHT (c) 2012 by Claus Gittinger
|
|
26 |
All Rights Reserved
|
|
27 |
|
|
28 |
This software is furnished under a license and may be used
|
|
29 |
only in accordance with the terms of that license and with the
|
|
30 |
inclusion of the above copyright notice. This software may not
|
|
31 |
be provided or otherwise made available to, or used by, any
|
|
32 |
other person. No title to or ownership of the software is
|
|
33 |
hereby transferred.
|
|
34 |
"
|
|
35 |
!
|
|
36 |
|
2714
|
37 |
documentation
|
|
38 |
"
|
|
39 |
An Array which computes its values on demand and does NOT remember those values.
|
|
40 |
Use this to present huge files/hex dumps to a text editor.
|
|
41 |
|
|
42 |
[author:]
|
|
43 |
Claus Gittinger
|
|
44 |
|
|
45 |
[see also:]
|
|
46 |
LazyArray
|
|
47 |
"
|
|
48 |
!
|
|
49 |
|
|
50 |
examples
|
|
51 |
"
|
|
52 |
[exBegin]
|
|
53 |
|squaresLines|
|
|
54 |
|
|
55 |
squaresLines := VirtualArray new.
|
|
56 |
squaresLines generator:[:index | index squared printString].
|
|
57 |
squaresLines setSize:100000.
|
|
58 |
|
|
59 |
squaresLines inspect.
|
|
60 |
TextView openWith:squaresLines
|
|
61 |
[exEnd]
|
|
62 |
"
|
|
63 |
! !
|
|
64 |
|
|
65 |
!VirtualArray methodsFor:'accessing'!
|
|
66 |
|
|
67 |
generator
|
|
68 |
^ generator
|
|
69 |
!
|
|
70 |
|
|
71 |
generator:something
|
|
72 |
generator := something.
|
|
73 |
!
|
|
74 |
|
|
75 |
setSize:something
|
|
76 |
size := something.
|
|
77 |
!
|
|
78 |
|
|
79 |
size
|
|
80 |
^ size
|
|
81 |
! !
|
|
82 |
|
|
83 |
!VirtualArray methodsFor:'collection protocol'!
|
|
84 |
|
|
85 |
at:index
|
|
86 |
^ generator value:index
|
|
87 |
|
|
88 |
"Created: / 27-02-2012 / 20:40:03 / cg"
|
|
89 |
!
|
|
90 |
|
|
91 |
at:index put:value
|
|
92 |
self noModificationError.
|
|
93 |
|
|
94 |
"Created: / 27-02-2012 / 20:40:33 / cg"
|
|
95 |
! !
|
|
96 |
|
3119
|
97 |
!VirtualArray methodsFor:'inspecting'!
|
|
98 |
|
|
99 |
displayOn:aGCOrStream
|
|
100 |
"print a representation of the receiver on aGCOrStream for display in inspectors etc."
|
|
101 |
|
|
102 |
"/ what a kludge - Dolphin and Squeak mean: printOn: a stream;
|
|
103 |
"/ ST/X (and some old ST80's) mean: draw-yourself on a GC.
|
3324
|
104 |
(aGCOrStream isStream) ifFalse:[
|
3119
|
105 |
^ super displayOn:aGCOrStream
|
|
106 |
].
|
|
107 |
|
|
108 |
aGCOrStream nextPutAll:('VirtualArray(size=%1, generator=%2)'
|
|
109 |
bindWith:size with:generator printString).
|
|
110 |
! !
|
|
111 |
|
2714
|
112 |
!VirtualArray class methodsFor:'documentation'!
|
|
113 |
|
|
114 |
version
|
3324
|
115 |
^ '$Header: /cvs/stx/stx/libbasic2/VirtualArray.st,v 1.4 2014-07-10 12:24:25 cg Exp $'
|
2714
|
116 |
!
|
|
117 |
|
|
118 |
version_CVS
|
3324
|
119 |
^ '$Header: /cvs/stx/stx/libbasic2/VirtualArray.st,v 1.4 2014-07-10 12:24:25 cg Exp $'
|
2714
|
120 |
! !
|
2906
|
121 |
|