eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'VirtualDictionaryWithCache':

Home

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

Class: VirtualDictionaryWithCache


Inheritance:

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

Package:
stx:libbasic2
Category:
Collections-Unordered
Version:
rev: 1.1 date: 2023/05/10 13:19:58
user: cg
file: VirtualDictionaryWithCache.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


similar to my superclass,
but I remember already encountered and computed values.
Useful if the computation is expensive.

For example,
    VirtualDictionaryWithCache new 
        fetchBlock:[:key | 
            Transcript showCR: e'computing value for {key}...'.
            key squared
        ]
will respond to:
    at:4
with 16.        

when asked again, the remembered value (as per key) will be returned.

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

copyright

COPYRIGHT (c) 2023 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 ifAbsent: exceptionValue
retrieve a value from this (virtual) dictionary.



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 06:55:57 GMT