Collections-Support

Association
I represent a pair of associated objects--a key and a value. My instances can serve as entries in a dictionary.
=
Compare the receiver with the argument and answer with true if the
receiver is equal to the argument. Otherwise answer false.
byteEncode:
isSelfEvaluating
isSpecialWriteBinding
Return true if this variable binding is write protected, e.g., should not be accessed primitively but rather by sending #value: messages
javascriptOn:
key:value:
Store the arguments as the variables of the receiver.
objectForDataStream:
I am about to be written on an object file. If I am a known global, write a proxy that will hook up with the same resource in the destination system.
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
propertyListOn:
serviceUpdate
storeOn:
Store in the format (key->value)
value
Answer the value of the receiver.
value:
Store the argument, anObject, as the value of the receiver.
CharacterSet
A set of characters. Lookups for inclusion are very fast.
=
Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.
add:
I automatically become a WideCharacterSet if you add a wide character to myself
allCharacters
byteArrayMap
return a ByteArray mapping each ascii value to a 1 if that ascii value is in the set, and a 0 if it isn't. Intended for use by primitives only
byteComplement
return a character set containing precisely the single byte characters the receiver does not
complement
return a character set containing precisely the characters the receiver does not
do:
evaluate aBlock with each character in the set
empty
hasWideCharacters
hash
Answer an integer hash value for the receiver such that,
-- the hash value of an unchanged object is constant over time, and
-- two equal objects have equal hash values
includes:
Answer whether anObject is one of the receiver's elements.
initialize
Subclasses should redefine this method to perform initializations on instance creation
newFrom:
nonSeparators
postCopy
self is a shallow copy, subclasses should copy fields as necessary to complete the full copy
remove:
Remove oldObject from the receiver's elements. Answer oldObject
unless no element is equal to oldObject, in which case, raise an error.
ArrayedCollections cannot respond to this message.
separators
size
Answer how many elements the receiver contains.
species
Answer the preferred class for reconstructing the receiver. For example,
collections create new collections whenever enumeration messages such as
collect: or select: are invoked. The new kind of collection is determined by
the species of the original collection. Species and class are not always the
same. For example, the species of Interval is Array.
wideCharacterMap
used for comparing with WideCharacterSet
CharacterSetComplement
CharacterSetComplement is a space efficient implementation of (CharacterSet complement) taking care of WideCharacter (code > 255)
However, it will maintain a byteArrayMap for character <= 255 in a cache keeping
instance variables:
absent <CharacterSet> contains character that are not in the set (i.e. my complement)
byteArrayMapCache <ByteArray | nil> cache this information because it has to be used in tight loops where efficiency matters
=
Implementation note: we do not test if equal to a WideCharacterSet,
because it is unlikely that WideCharacterSet is as complete as self
add:
a character is present if not absent, so adding a character is removing it from the absent
byteArrayMap
return a ByteArray mapping each ascii value to a 1 if that ascii value is in the set, and a 0 if it isn't. Intended for use by primitives only
complement
return a character set containing precisely the characters the receiver does not
complement:
initialize with the complement
do:
evaluate aBlock with each character in the set.
don't do it, there are too many...
hasWideCharacters
This is a guess that absent is not holding each and every possible wideCharacter...
hash
Answer an integer hash value for the receiver such that,
-- the hash value of an unchanged object is constant over time, and
-- two equal objects have equal hash values
includes:
Answer whether anObject is one of the receiver's elements.
of:
postCopy
self is a shallow copy, subclasses should copy fields as necessary to complete the full copy
printOn:
Print a description of the complement rather than self.
Rationale: self would be too long to print.
reject:
Implementation note: rejecting present is selecting absent
remove:
This means aCharacter is now absent from myself.
It must be added to my absent.
removeAll
Remove each element from the receiver and leave it empty.
ArrayedCollections cannot respond to this message.
There are two good reasons why a subclass should override this message:
1) the subclass does not support being modified while being iterated
2) the subclass provides a much faster way than iterating through each element
select:
Implementation note: selecting present is rejecting absent
size
Is this 2**32-absent size ?
storeOn:
Store a description of the elements of the complement rather than self.
An instance of me is a simple record of a pointer to another Link. I am an abstract class; my concrete subclasses, for example, Process, can be stored in a LinkedList structure.
nextLink
Answer the link to which the receiver points.
nextLink:
Store the argument, aLink, as the link to which the receiver refers.
Answer aLink.
LookupKey
I represent a key for looking up entries in a data structure. Subclasses of me, such as Association, typically represent dictionary entries.
<
Refer to the comment in Magnitude|<.
=
Compare the receiver with the argument and answer with true if the
receiver is equal to the argument. Otherwise answer false.
canAssign
hash
Hash is reimplemented because = is implemented.
isSpecialReadBinding
Return true if this variable binding is read protected, e.g., should not be accessed primitively but rather by sending #value messages
isVariableBinding
Return true if I represent a literal variable binding
key
Answer the lookup key of the receiver.
key:
Store the argument, anObject, as the lookup key of the receiver.
name
Answer a name for the receiver. This is used generically in the title of certain inspectors, such as the referred-to inspector, and specificially by various subsystems. By default, we let the object just print itself out..
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
writeOnFilterStream:
WeakKeyAssociation
I am an association holding only weakly on my key.
<
Refer to the comment in Magnitude|<.
=
Compare the receiver with the argument and answer with true if the
receiver is equal to the argument. Otherwise answer false.
hash
Hash is reimplemented because = is implemented.
key
Answer the lookup key of the receiver.
key:
Store the argument, anObject, as the lookup key of the receiver.
key:value:
Store the arguments as the variables of the receiver.
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
storeOn:
Store in the format (key->value)
WeakValueAssociation
I am a lookup key (acting like an association but) holding only weakly on my value.
key:value:
Store the arguments as the variables of the receiver.
new
value
value:
Store the argument, anObject, as the value of the receiver.
WideCharacterSet
WideCharacterSet is used to store a Set of WideCharacter with fast access and inclusion test.
Implementation should be efficient in memory if sets are sufficently sparse.
Wide Characters are at most 32bits.
We split them into 16 highBits and 16 lowBits.
map is a dictionary key: 16 highBits value: map of 16 lowBits.
Maps of lowBits are stored as arrays of bits in a WordArray.
If a bit is set to 1, this indicate that corresponding character is present.
Only 2048 entries are necessary in each lowmap.
And only lowmap corresponding to a present high value are stored.
=
Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.
add:
Include newObject as one of the receiver's elements. Answer newObject.
ArrayedCollections cannot respond to this message.
bitmap:at:
access a single bit in aMap.
shortInteger should be between: 0 and: 16rFFFF
bitmap:do:
Execute a block with each value (0 based) corresponding to set bits
byteArrayMap
return a ByteArray mapping each ascii value to a 1 if that ascii value is in the set, and a 0 if it isn't.
Intended for use by primitives only. (and comparison)
This version will answer a subset with only byte characters
clearBitmap:at:
clear a single bit in aMap.
shortInteger should be between: 0 and: 16rFFFF
complement
return a character set containing precisely the characters the receiver does not
do:
Evaluate aBlock with each of the receiver's elements as the argument.
hasWideCharacters
Answer true if i contain any wide character
hash
Answer a hash code aimed at storing and retrieving the receiver in a Set or Dictionary.
Two equal objects should have equal hash.
Note: as the receiver can be equal to an ordinary CharacterSet,
the hash code must reflect this
includes:
Answer whether anObject is one of the receiver's elements.
initialize
Subclasses should redefine this method to perform initializations on instance creation
newFrom:
postCopy
self is a shallow copy, subclasses should copy fields as necessary to complete the full copy
remove:
Remove oldObject from the receiver's elements. Answer oldObject
unless no element is equal to oldObject, in which case, raise an error.
ArrayedCollections cannot respond to this message.
removeAll
Remove each element from the receiver and leave it empty.
ArrayedCollections cannot respond to this message.
There are two good reasons why a subclass should override this message:
1) the subclass does not support being modified while being iterated
2) the subclass provides a much faster way than iterating through each element
setBitmap:at:
set a single bit in aMap.
shortInteger should be between: 0 and: 16rFFFF
size
Answer how many elements the receiver contains.
species
Answer the preferred class for reconstructing the receiver. For example,
collections create new collections whenever enumeration messages such as
collect: or select: are invoked. The new kind of collection is determined by
the species of the original collection. Species and class are not always the
same. For example, the species of Interval is Array.
wideCharacterMap