4549
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
4541
|
3 |
"{ Package: 'stx:libbasic2' }"
|
|
4 |
|
|
5 |
"{ NameSpace: Smalltalk }"
|
|
6 |
|
|
7 |
Collection subclass:#VirtualDictionary
|
|
8 |
instanceVariableNames:'fetchBlock'
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
|
11 |
category:'Collections-Unordered'
|
|
12 |
!
|
|
13 |
|
|
14 |
!VirtualDictionary class methodsFor:'documentation'!
|
|
15 |
|
|
16 |
documentation
|
|
17 |
"
|
|
18 |
a collection which looks like a (read-only) dictionary to the outside,
|
|
19 |
but invokes a pluggable fetchBlock to retrieve keys.
|
|
20 |
|
|
21 |
[author:]
|
|
22 |
cg
|
|
23 |
|
|
24 |
[instance variables:]
|
|
25 |
|
|
26 |
[class variables:]
|
|
27 |
|
|
28 |
[see also:]
|
|
29 |
|
|
30 |
"
|
|
31 |
! !
|
|
32 |
|
|
33 |
!VirtualDictionary methodsFor:'accessing'!
|
|
34 |
|
4549
|
35 |
at:aKey
|
|
36 |
^ self at:aKey ifAbsent:nil
|
|
37 |
!
|
|
38 |
|
4541
|
39 |
at:aKey ifAbsent:exceptionValue
|
|
40 |
|value|
|
|
41 |
|
|
42 |
value := fetchBlock value:aKey.
|
|
43 |
value isNil ifTrue:[
|
|
44 |
^ exceptionValue value
|
|
45 |
].
|
|
46 |
^ value
|
|
47 |
!
|
|
48 |
|
|
49 |
fetchBlock:something
|
|
50 |
fetchBlock := something.
|
|
51 |
! !
|
|
52 |
|
4549
|
53 |
!VirtualDictionary methodsFor:'queries'!
|
|
54 |
|
|
55 |
includesKey:aKey
|
|
56 |
^ (fetchBlock value:aKey) notNil
|
|
57 |
! !
|
|
58 |
|
4541
|
59 |
!VirtualDictionary class methodsFor:'documentation'!
|
|
60 |
|
|
61 |
version
|
|
62 |
^ '$Header$'
|
|
63 |
!
|
|
64 |
|
|
65 |
version_CVS
|
|
66 |
^ '$Header$'
|
|
67 |
! !
|
|
68 |
|