eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'IdentitySet':

Home

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

Class: IdentitySet


Inheritance:

   Object
   |
   +--Collection
      |
      +--Set
         |
         +--IdentitySet
            |
            +--SemaphoreSet
            |
            +--SignalSet
            |
            +--WeakIdentitySet

Package:
stx:libbasic
Category:
Collections-Unordered
Version:
rev: 1.47 date: 2023/12/21 15:05:26
user: stefan
file: IdentitySet.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


same as a Set but compares elements using == 
(i.e. they must be identical - not just equal in structure).
Since compare is on identity (using ==), hashing is also done via
#identityHash instead of #hash.

copyright

COPYRIGHT (c) 1993 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:

adding & removing
o  removeIdentical: oldObject ifAbsent: exceptionBlock
remove oldObject from the collection and return it.
If it was not in the collection return the value of exceptionBlock.
Uses identity compare (==) to search for an occurrence.

WARNING: do not remove elements while iterating over the receiver.

o  safeRemoveIdentical: oldObject ifAbsent: exceptionBlock
remove oldObject from the collection and return it.
If it was not in the collection return the value of exceptionBlock.
Uses identity compare (==) to search for an occurrence.

converting
o  asIdentitySet
return the receiver as an IdentitySet

o  asNewIdentitySet
make sure to return myself as a unique new IdentitySet

Usage example(s):

        |s|
        s := #(1 2 3 4) asIdentitySet.
        self assert:(s ~~ s asNewIdentitySet).
        self assert:(s = s asNewIdentitySet).

copying
o  copyWithout: anElement
return a new collection consisting of a copy of the receiver, with
ALL elements equal to elementToSkip are left out.
No error is reported, if elementToSkip is not in the collection.

Usage example(s):

     #(1 2 3 4 5 6 7) asSet copyWithout:5

private
o  collisionsFor: key
Return the number of searches - 1 required for key

o  find: key ifAbsent: aBlock
Look for the key in the receiver. If it is found, return
the index of the slot containing the key, otherwise
return the value of evaluating aBlock.
Redefined to compare for identity instead of equality

o  findIdentical: key ifAbsent: aBlock
IdentitySet does identity compare anyway...

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

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 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  includesIdentical: anObject
for identitySet, the #includes: test already tests for identity

set operations
o  \ aCollection
return a new set containing all elements of the receiver,
which are NOT also contained in the aCollection
For large collections you better use a Set for aCollection.
Redefined here to do identity comparison.

Usage example(s):

     #(0 1 2 3 4 5 6 7 8 9) asIdentitySet \ #(1 2 3) asSet  
     #(0 1 2 3 4 5 6 7 8 9) asIdentitySet \ #(1 2 3)
     (SortedSet withAll:#(99 0 1 2 3 4 5 6 7 8 9)) \ #(1 2 3)



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sun, 22 Dec 2024 03:22:44 GMT