eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'CacheDictionary':

Home

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

Class: CacheDictionary


Inheritance:

   Object
   |
   +--Collection
      |
      +--Set
         |
         +--Dictionary
            |
            +--CacheDictionary
               |
               +--CacheDictionaryWithFactory

Package:
stx:libbasic2
Category:
Collections-Unordered
Version:
rev: 1.30 date: 2019/03/15 14:28:18
user: stefan
file: CacheDictionary.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


a CacheDictionary is a Dictionary which will not grow beyond a given max. size
- i.e. keep only a limited number of elements.
It can be used as a cache, for keeping recently used objects alive.
Must be created with an initial (=maximal) size. 
I.e. (CacheDictionary new:100)

    


Related information:

    Dictionary
    OrderedCollection
    OrderedDictionary

Instance protocol:

private
o  findKeyOrNil: key
Look for the key in the receiver. If it is found, return
the index of the association containing the key, otherwise
return the index of the first unused slot. If no empty slot
is available, make one empty (but never grow).

o  findKeyOrNilOrDeletedEntry: key
Look for the key in the receiver. If it is found, return
the index of the association containing the key, otherwise
return the index of the first unused slot. If no empty slot
is available, make one empty (but never grow).

o  possiblyGrow
redefined - never grow

o  possiblyShrink
redefined - never shrink

o  possiblyShrinkToZero
here, we keep the old containers


Examples:


    |d|

    d := CacheDictionary new:16.
    1 to:20 do:[:i |
        d at:i printString put:i.
    ].
    21 to:40 do:[:i |
        d at:i printString put:i.
    ].
    d inspect


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Sat, 20 Apr 2024 01:46:55 GMT