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.4 date: 2016/10/12 17:08:30
user: cg
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:

Compatibility-Squeak
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

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

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.1.0.0; WebServer 1.663 at exept.de:8081; Mon, 24 Sep 2018 22:02:33 GMT