eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'PluggableSet':

Home

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

Class: PluggableSet


Inheritance:

   Object
   |
   +--Collection
      |
      +--Set
         |
         +--PluggableSet

Package:
stx:libbasic2
Category:
Collections-Unordered
Version:
rev: 1.5 date: 2019/03/05 11:30:21
user: stefan
file: PluggableSet.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


a set 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

converting
o  asIdentitySet
return the receiver as an IdentitySet

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

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  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.


Examples:


|s| s := PluggableSet hashWith:[:k | k size] compareWith:[:a :b | a notNil and:[b notNil and:[a asLowercase = b asLowercase]]]. s add:'hello'. s add:'world'. s add:'abc'. s add:'Hello'. s add:'heLLo'. s add:'ABC'. s add:'WORLD'. s size. s includes:'heLlo'. s includes:'wOrLd'. s includes:'wOrLds'.

ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 25 Apr 2024 03:58:20 GMT