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
               |
               +--CacheDictionaryWithLimitedLifetime
               |
               +--Tools::MethodCategoryList::MethodInfoCacheDictionary

Package:
stx:libbasic2
Category:
Collections-Unordered
Version:
rev: 1.32 date: 2022/01/20 11:12:21
user: stefan
file: CacheDictionary.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

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)

    

copyright

COPYRIGHT (c) 1993 by Claus Gittinger 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.

Class protocol:

queries
o  goodSizeFrom: anInteger
return a good array size for the given argument.
Returns the next prime after arg, since prime sizes are good for hashing.
Since I never grow, I will be filled up to the last slot.
So do not allocate extra empty slots.


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  shrinkToZero
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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 27 Jul 2024 07:36:09 GMT