eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'PluggableDictionary':

Home

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

Class: PluggableDictionary


Inheritance:

   Object
   |
   +--Collection
      |
      +--Set
         |
         +--Dictionary
            |
            +--PluggableDictionary
               |
               +--Dolphin::PluggableLookupTable

Package:
stx:libbasic2
Category:
Collections-Unordered
Version:
rev: 1.5 date: 2019/02/10 13:44:10
user: cg
file: PluggableDictionary.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


a dictionary where the hash- and compare functions can be provided externally.


Class protocol:

instance creation
o  hashWith: hashFunctionArg compareWith: compareFunctionArg


Instance protocol:

accessing
o  hashWith: hashFunctionArg compareWith: compareFunctionArg

private
o  compareSame: element1 with: element2
compare two elements for being the same.
Here, return the value from compareFunction

o  find: key ifAbsent: aBlock
Look for the key in the receiver. If it is found, return
the index of the association containing the key, otherwise
return the value of evaluating aBlock.
Redefined - since we inherit this code from Set-Dictionary
(one of the seldom cases, where I could make use of multiple inheritance
and inherit from IdentitySet ... sigh)

o  findKeyOrNil: key
Look for the key in the receiver.
If it is found, return return the index of the first unused slot.
Grow the receiver, if key was not found, and no unused slots were present

o  findKeyOrNilOrDeletedEntry: key
Look for the key in the receiver.
If it is found, return return the index of the first unused slot.
Grow the receiver, if key was not found, and no unused slots were present

o  hashFor: aKey
return an initial index given a key.

queries
o  occurrencesOf: anObject
count & return how often anObject is stored in the dictionary.
This counts values - not keys.
Redefined to use #== (identity compare), NOT equality compare.


Examples:


|s| s := PluggableDictionary hashWith:[:k | k asLowercase hash] compareWith:[:a :b | a notNil and:[b notNil and:[a asLowercase = b asLowercase]]]. s at:'hello' put:123. s at:'world' put:222. s at:'abc' put:333. s at:'Hello'. s at:'heLLo'. s at:'ABC'. s at:'WORLD'. s size. s includesKey:'heLlo'. s includesKey:'wOrLd'. s includesKey:'wOrLds'.

ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Tue, 19 Mar 2024 05:14:38 GMT