eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'PluggableDictionary':

Home

everywhere
www.exept.de
for:
[back]

Class: PluggableDictionary


Inheritance:

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

Package:
stx:libbasic2
Category:
Collections-Unordered
Version:
rev: 1.4 date: 2016/08/11 13:24:03
user: stefan
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.

testing
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.1.0.0; WebServer 1.653 at exept.de:8081; Sun, 21 Jan 2018 14:15:39 GMT