|
Class: CacheDictionary
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
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)
Dictionary
OrderedCollection
OrderedDictionary
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
-
possiblyShrinkToZero
-
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
|
|