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.29 date: 2018/05/17 21:30:55
user: cg
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.1.0.0; WebServer 1.663 at exept.de:8081; Fri, 20 Jul 2018 06:54:27 GMT