VirtualDictionary.st
author chzeiher
Tue, 27 Nov 2018 16:31:23 +0100
changeset 4770 ff398f221e71
parent 4549 a9d2d65fda08
child 5387 64a6ef96c06f
permissions -rw-r--r--
#BUGFIX by chzeiher class: Socket class changed: #getRandomAvailablePortOnHost: bandaid to have the method working remotely. By essentially picking a port at random :S

"{ Encoding: utf8 }"

"{ Package: 'stx:libbasic2' }"

"{ NameSpace: Smalltalk }"

Collection subclass:#VirtualDictionary
	instanceVariableNames:'fetchBlock'
	classVariableNames:''
	poolDictionaries:''
	category:'Collections-Unordered'
!

!VirtualDictionary class methodsFor:'documentation'!

documentation
"
    a collection which looks like a (read-only) dictionary to the outside,
    but invokes a pluggable fetchBlock to retrieve keys.

    [author:]
        cg

    [instance variables:]

    [class variables:]

    [see also:]

"
! !

!VirtualDictionary methodsFor:'accessing'!

at:aKey
    ^ self at:aKey ifAbsent:nil
!

at:aKey ifAbsent:exceptionValue
    |value|

    value := fetchBlock value:aKey.
    value isNil ifTrue:[
        ^ exceptionValue value
    ].
    ^ value
!

fetchBlock:something
    fetchBlock := something.
! !

!VirtualDictionary methodsFor:'queries'!

includesKey:aKey
    ^ (fetchBlock value:aKey) notNil
! !

!VirtualDictionary class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
! !