eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'VirtualDictionary':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: VirtualDictionary


Inheritance:

   Object
   |
   +--Collection
      |
      +--VirtualDictionary
         |
         +--VirtualDictionaryWithCache

Package:
stx:libbasic2
Category:
Collections-Unordered
Version:
rev: 1.12 date: 2023/11/15 07:22:18
user: cg
file: VirtualDictionary.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


a collection which looks like a (usually read-only) dictionary to the outside,
but invokes a pluggable fetchBlock to retrieve keys and optional storeBlock
to change values.
The fetchBlock is called for at:ifAbsent: and is supposed to
return an object for the given argument(key) or nil if there is no such value.
For example,
    VirtualDictionary new fetchBlock:[:key | key squared]
will respond to:
    at:4
with 16.        

VirtualDictionary does not remember previously computed values,
whereas VirtualDictionaryWithCache does.

Caveat:
    a virtual dictionary does not support:
        size
        do:     (and all other enumeration messages)
    actually it does not behave at all like a dictionary.


[instance variables:]

[class variables:]

copyright

COPYRIGHT (c) 2018 by eXept Software AG 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.

Instance protocol:

accessing
o  at: aKey
retrieve a value from this (virtual) dictionary.

o  at: aKey ifAbsent: exceptionValue
retrieve a value from this (virtual) dictionary.

o  at: aKey put: aValue
store a value in this (virtual) dictionary.
May raise an error, if storing is not allowed or if the key is wrong

o  do: aBlock
enumerate the elements (if possible); raise an error if not.

o  includesKey: aKey
return true if aKey is in this (virtual) dictionary.

o  size
return the size (if known); raise an error if not known.

initializing
o  checkKeyBlock: aOneArgBlock
define the checkKeyblock; this is invoked with the key to check for presence

o  doBlock: aOneArgBlock
define the doblock; this is invoked to enumerate the virtual elements

o  fetchBlock: aOneArgBlock
define the fetchblock; this is invoked with the key to fetch

o  sizeBlock: aBlock
define the sizeblock; this is invoked to ask for the virtual size

o  storeBlock: aTwoArgBlock
define the storeblock; this is invoked with the key and value to store

testing
o  isVirtualCollection
(comment from inherited method)
true if this is a collection which generates elements via
some algorithm (such as reading a file).
Some care should be taken then, as not all operations are possible then.

o  isVirtualDictionary



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 04:37:07 GMT