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.46 date: 2023/07/20 08:45:05
user: stefan
file: IdentityDictionary.st directory: libbasic
module: stx stc-classLibrary: libbasic

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.

copyright

COPYRIGHT (c) 1992 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Instance protocol:

comparing
o  = anIdentityDictionary
return true, if the argument is an IdentityDictionary containing the same
key-value pairs as I do

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.

Usage example(s):

     |d d2|

     d := IdentityDictionary new
            at:1 put:'1';
            at:2 put:'2';
            at:3 put:'3';
            at:4 put:'4';
            at:4.0 put:'4';
            at:5 put:'5';
            yourself.
     d2 := d copyWithout:(4->'4').
     d2   

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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 18:55:35 GMT