|
Class: PluggableSet
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
a set where the hash- and compare functions can be provided externally.
instance creation
-
hashWith: hashFunctionArg compareWith: compareFunctionArg
-
accessing
-
hashWith: hashFunctionArg compareWith: compareFunctionArg
-
converting
-
asIdentitySet
-
return the receiver as an IdentitySet
-
asNewIdentitySet
-
make sure to return myself as a unique new IdentitySet
copying
-
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
-
collisionsFor: key
-
Return the number of searches - 1 required for key
-
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
-
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
-
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
-
hashFor: aKey
-
return an initial index given a key.
|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'.
|