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.39 date: 2019/03/05 11:52:46
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:

copying
o  copyWithout: anAssociation
Return a copy of the dictionary that is 1 smaller than the receiver and
does not include the argument, anAssociation
No error is reported, if elementToSkip is not in the collection.

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.

queries
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.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 29 Mar 2024 13:59:50 GMT