|
Class: CacheDictionary
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
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)
copyrightCOPYRIGHT (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.
queries
-
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.
private
-
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).
-
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).
-
possiblyGrow
-
redefined - never grow
-
possiblyShrink
-
redefined - never shrink
-
shrinkToZero
-
here, we keep the old containers
|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
|
|