eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'IdentityDictionary':

Home

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

Class: IdentityDictionary


Inheritance:

   Object
   |
   +--Collection
      |
      +--Set
         |
         +--Dictionary
            |
            +--IdentityDictionary
               |
               +--ColorPreferencesCollection
               |
               +--ExceptionHandlerSet
               |
               +--JavaScriptObject
               |
               +--KeyboardMap
               |
               +--PropertyListDictionary
               |
               +--UISpecification::UIBindingsIdentityDictionary
               |
               +--UserPreferences
               |
               +--WeakIdentityDictionary
               |
               +--WeakValueIdentityDictionary

Package:
stx:libbasic
Category:
Collections-Unordered
Version:
rev: 1.37 date: 2016/08/11 13:25:36
user: stefan
file: IdentityDictionary.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Claus Gittinger

Description:


Same as a Dictionary, but key must be identical - not just equal.
Since compare is on identical keys (using ==), hashing is also done via
#identityHash instead of #hash.
IdentityDictionaries are especially useful when symbols are used as keys.


Instance protocol:

private
o  compareSame: element1 with: element2
compare two elements for being the same. Here, return true if the
elements are identical (i.e. using #==).

o  emptyCollectionForKeys
return an empty collection used for keys.
Here, an IdentitySet is returned.
Made a separate method to allow redefinition for different kind of
containers in subclasses.

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  findIdentical: key ifAbsent: aBlock
IdentityDictionary does identity compare anyway...

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

Warning: an empty slot MUST be filled by the sender - it is only to be sent
by at:put: / add: - like methods.

o  findKeyOrNilOrDeletedEntry: key
Look for the key in the receiver.
If it is found, 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  includesValue: aValue
return true, if the argument, aValue is stored in the dictionary,
Redefined to use identity compare, NOT equality compare

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.



ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Sun, 23 Sep 2018 09:52:52 GMT