Collections

Array
I present an ArrayedCollection whose elements are objects.
+*
Premultiply aCollection by self. aCollection should be an Array or Matrix.
The name of this method is APL's +.x squished into Smalltalk syntax.
asArray
Answer with the receiver itself.
atWrap:
Optimized to go through the primitive if possible
atWrap:put:
Optimized to go through the primitive if possible
braceStream:
braceWith:
braceWith:with:
braceWith:with:with:
braceWith:with:with:with:
braceWithNone
byteEncode:
copyWithDependent:
Answer a new collection with newElement added (as last
element if sequenceable).
elementsExchangeIdentityWith:
This primitive performs a bulk mutation, causing all pointers to the elements of this array to be replaced by pointers to the corresponding elements of otherArray. At the same time, all pointers to the elements of otherArray are replaced by pointers to the corresponding elements of this array. The identityHashes remain with the pointers rather than with the objects so that objects in hashed structures should still be properly indexed after the mutation.
elementsForwardIdentityTo:
This primitive performs a bulk mutation, causing all pointers to the elements of this array to be replaced by pointers to the corresponding elements of otherArray. The identityHashes remain with the pointers rather than with the objects so that the objects in this array should still be properly indexed in any existing hashed structures after the mutation.
elementsForwardIdentityTo:copyHash:
This primitive performs a bulk mutation, causing all pointers to the elements of this array to be replaced by pointers to the corresponding elements of otherArray. The identityHashes remain with the pointers rather than with the objects so that the objects in this array should still be properly indexed in any existing hashed structures after the mutation.
evalStrings
Allows you to construct literal arrays.
#(true false nil '5@6' 'Set new' '''text string''') evalStrings
gives an array with true, false, nil, a Point, a Set, and a String
instead of just a bunch of Symbols
hasLiteral:
Answer true if literal is identical to any literal in this array, even
if imbedded in further array structure. This method is only intended
for private use by CompiledMethod hasLiteralSymbol:
hasLiteralSuchThat:
Answer true if testBlock returns true for any literal in this array, even if imbedded in further Arrays or CompiledMethods. This method is only intended for private use by CompiledMethod hasLiteralSuchThat:
isArray
isLiteral
Answer whether the receiver has a literal text form recognized by the
compiler.
isSelfEvaluating
literalEqual:
new:
objectForDataStream:
I am about to be written on an object file. If I am one of two shared global arrays, write a proxy instead.
preMultiplyByArray:
Answer a+*self where a is an Array. Arrays are always understood as column vectors,
so an n element Array is an n*1 Array. This multiplication is legal iff self size = 1.
preMultiplyByMatrix:
Answer m+*self where m is a Matrix.
printAsLiteralFormOn:
printAsSelfEvaluatingFormOn:
printOn:
Append a sequence of characters that identify the receiver to aStream.
refersToLiteral:
Answer true if literal is identical to any literal in this array, even if imbedded in further array structures or closure methods
replaceFrom:to:with:startingAt:
Primitive. This destructively replaces elements from start to stop in the receiver starting at index, repStart, in the collection, replacement. Answer the receiver. Range checks are performed in the primitive only. Optional. See Object documentation whatIsAPrimitive.
storeOn:
Use the literal form if possible.
storeOnStream:
ArrayedCollection
I am an abstract collection of elements with a fixed range of integers (from 1 to n>=0) as external keys.
add:
Include newObject as one of the receiver's elements. Answer newObject.
ArrayedCollections cannot respond to this message.
asSortedArray
Return a copy of the receiver in sorted order, as an Array. 6/10/96 sw
byteSize
bytesPerBasicElement
Answer the number of bytes that each of my basic elements requires.
In other words:
self basicSize * self bytesPerBasicElement
should equal the space required on disk by my variable sized representation.
bytesPerElement
defaultElement
flattenOnStream:
isSorted
Return true if the receiver is sorted by the given criterion.
Optimization for isSortedBy: [:a :b | a <= b].
isSortedBy:
Return true if the receiver is sorted by the given criterion.
mergeFirst:middle:last:into:by:
Private. Merge the sorted ranges [first..middle] and [middle+1..last]
of the receiver into the range [first..last] of dst.
mergeSortFrom:to:by:
Sort the given range of indices using the mergesort algorithm.
Mergesort is a worst-case O(N log N) sorting algorithm that usually
does only half as many comparisons as heapsort or quicksort.
mergeSortFrom:to:src:dst:by:
Private. Split the range to be sorted in half, sort each half, and
merge the two half-ranges into dst.
new
new:withAll:
newFrom:
newFromStream:
restoreEndianness
This word object was just read in from a stream. It was stored in Big Endian (Mac) format. Reverse the byte order if the current machine is Little Endian.
We only intend this for non-pointer arrays. Do nothing if I contain pointers.
size
Answer how many elements the receiver contains.
sort
Sort this array into ascending order using the '<=' operator.
sort:
Sort this array using aSortBlock. The block should take two arguments
and return true if the first element should preceed the second one.
storeElementsFrom:to:on:
storeOn:
Refer to the comment in Object|storeOn:.
swapHalves
A normal switch in endianness (byte order in words) reverses the order of 4 bytes. That is not correct for SoundBuffers, which use 2-bytes units. If a normal switch has be done, this method corrects it further by swapping the two halves of the long word.
This method is only used for 16-bit quanities in SoundBuffer, ShortIntegerArray, etc.
with:
with:with:
with:with:with:
with:with:with:with:
with:with:with:with:with:
with:with:with:with:with:with:
withAll:
writeOn:
Store the array of bits onto the argument, aStream. (leading byte ~= 16r80) identifies this as raw bits (uncompressed). Always store in Big Endian (Mac) byte order. Do the writing at BitBlt speeds. We only intend this for non-pointer arrays. Do nothing if I contain pointers.
writeOnGZIPByteStream:
We only intend this for non-pointer arrays. Do nothing if I contain pointers.
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.
Bag
I represent an unordered collection of possibly duplicate elements.

I store these elements in a dictionary, tallying up occurrences of equal objects. Because I store an occurrence only once, my clients should beware that objects they store will not necessarily be retrieved such that == is true. If the client cares, a subclass of me should be created.
=
Two bags are equal if
(a) they are the same 'kind' of thing.
(b) they have the same size.
(c) each element occurs the same number of times in both of them
add:
Include newObject as one of the receiver's elements. Answer newObject.
add:withOccurrences:
Add newObject anInteger times to the receiver. Answer newObject.
asBag
Answer a Bag whose elements are the elements of the receiver.
asSet
Answer a set with the elements of the receiver.
at:
Primitive. Assumes receiver is indexable. Answer the value of an
indexable element in the receiver. Fail if the argument index is not an
Integer or is out of bounds. Essential. See Object documentation
whatIsAPrimitive.
at:put:
Primitive. Assumes receiver is indexable. Store the argument value in
the indexable element of the receiver indicated by index. Fail if the
index is not an Integer or is out of bounds. Or fail if the value is not of
the right type for this kind of collection. Answer the value that was
stored. Essential. See Object documentation whatIsAPrimitive.
contentsClass
copy
Answer another instance just like the receiver. Subclasses typically override postCopy; they typically do not override shallowCopy.
cumulativeCounts
Answer with a collection of cumulative percents covered by elements so far.
do:
Refer to the comment in Collection|do:.
includes:
Refer to the comment in Collection|includes:.
new
new:
newFrom:
occurrencesOf:
Refer to the comment in Collection|occurrencesOf:.
remove:ifAbsent:
Refer to the comment in Collection|remove:ifAbsent:.
removeAll
Implementation Note: as contents will be overwritten, a shallowCopy of self would be modified.
An alternative implementation preserving capacity would be to create a new contents:
self setContents: (self class contentsClass new: contents size).
setContents:
size
Answer how many elements the receiver contains.
snapshotCopy
sortedCounts
Answer with a collection of counts with elements, sorted by decreasing
count.
sortedElements
Answer with a collection of elements with counts, sorted by element.
valuesAndCounts
ByteArray
I represent an ArrayedCollection whose elements are integers between 0 and 255.
asByteArray
Answer a ByteArray whose elements are the elements of the receiver.
asByteArrayOfSize:
'34523' asByteArray asByteArrayOfSize: 100.
(((
| repeats bytes |
repeats := 1000000.
bytes := '123456789123456789123456789123456789123456789123456789' asByteArray.
[repeats timesRepeat: (bytes asByteArrayOfSize: 1024) ] timeToRun.
)))
asByteArrayPointer
Return a ByteArray describing a pointer to the contents of the receiver.
asIpString
asMIMEDocument
asMIMEDocumentType:
asSocketAddress
asString
Convert to a String with Characters for each byte.
Fast code uses primitive that avoids character conversion
asWideString
atAllPut:
Fill the receiver with the given value
bitXor:
byteAt:
byteAt:put:
byteSize
bytesPerElement
Number of bytes in each item. This multiplied by (self size)*8 gives the number of bits stored.
defaultElement
destroy
doubleAt:bigEndian:
Return a 64 bit float starting from the given byte index
doubleAt:put:bigEndian:
Store a 64 bit float starting from the given byte index
floatAt:bigEndian:
hash
#hash is implemented, because #= is implemented
hashBytes:startingWith:
hex
isLiteral
so that #(1 #[1 2 3] 5) prints itself
lastIndexOfPKSignature:
Answer the last index in me where aSignature (4 bytes long) occurs, or 0 if not found
longAt:bigEndian:
Return a 32bit integer quantity starting from the given byte index
longAt:put:bigEndian:
Return a 32bit integer quantity starting from the given byte index
nsReadStreamClass
nsWriteStreamClass
printOn:
Append a sequence of characters that identify the receiver to aStream.
renderOn:
Override this method to customize how objects (not components) are rendered when passed as an argument to #render:. The default is the return value of #displayString.
Just remember that you can not use #callback:, #on:of:, or #call:
replaceFrom:to:with:startingAt:
Primitive. This destructively replaces elements from start to stop in the receiver starting at index, repStart, in the collection, replacement. Answer the receiver. Range checks are performed in the primitive only. Optional. See Object documentation whatIsAPrimitive.
shortAt:bigEndian:
Return a 16 bit integer quantity starting from the given byte index
shortAt:put:bigEndian:
Store a 16 bit integer quantity starting from the given byte index
storeOn:
Refer to the comment in Object|storeOn:.
unsignedLongAt:bigEndian:
Return a 32bit unsigned integer quantity starting from the given byte index
unsignedLongAt:put:bigEndian:
Store a 32bit unsigned integer quantity starting from the given byte index
unsignedShortAt:bigEndian:
Return a 16 bit unsigned integer quantity starting from the given byte index
unsignedShortAt:put:bigEndian:
Store a 16 bit unsigned integer quantity starting from the given byte index
ByteString
This class represents the array of 8 bit wide characters.
applyLanguageInfomation:
asByteArray
Convert to a ByteArray with the ascii values of the string.
asOctetString
Convert the receiver into an octet string
at:
Primitive. Answer the Character stored in the field of the receiver
indexed by the argument. Fail if the index argument is not an Integer or
is out of bounds. Essential. See Object documentation whatIsAPrimitive.
at:put:
Primitive. Store the Character in the field of the receiver indicated by
the index. Fail if the index is not an Integer or is out of bounds, or if
the argument is not a Character. Essential. See Object documentation
whatIsAPrimitive.
beginsWith:
Answer whether the receiver begins with the given prefix string.
The comparison is case-sensitive.
byteAt:
byteAt:put:
byteSize
compare:with:collated:
convertFromCompoundText
convertFromSystemString
findFirstInString:inSet:startingAt:
findSubstring:in:startingAt:matchTable:
Answer the index in the string body at which the substring key first occurs, at or beyond start. The match is determined using matchTable, which can be used to effect, eg, case-insensitive matches. If no match is found, zero will be returned.
findSubstringViaPrimitive:in:startingAt:matchTable:
Answer the index in the string body at which the substring key first occurs, at or beyond start. The match is determined using matchTable, which can be used to effect, eg, case-insensitive matches. If no match is found, zero will be returned.
The algorithm below is not optimum -- it is intended to be translated to C which will go so fast that it wont matter.
hasWideCharacterFrom:to:
Only WideStrings contain these characters
indexOfAscii:inString:startingAt:
isByteString
Answer whether the receiver is a ByteString
isOctetString
Answer whether the receiver can be represented as a byte string.
This is different from asking whether the receiver *is* a ByteString
(i.e., #isByteString)
replaceFrom:to:with:startingAt:
Primitive. This destructively replaces elements from start to stop in the receiver starting at index, repStart, in the collection, replacement. Answer the receiver. Range checks are performed in the primitive only. Optional. See Object documentation whatIsAPrimitive.
stringHash:initialHash:
translate:from:to:table:
ByteSymbol
This class represents the symbols containing 8bit characters.
asByteArray
Convert to a ByteArray with the ascii values of the string.
asOctetString
Convert the receiver into an octet string
at:
Primitive. Answer the Character stored in the field of the receiver
indexed by the argument. Fail if the index argument is not an Integer or
is out of bounds. Essential. See Object documentation whatIsAPrimitive.
beginsWith:
Answer whether the receiver begins with the given prefix string.
The comparison is case-sensitive.
byteAt:
byteAt:put:
You cannot modify the receiver.
byteSize
findFirstInString:inSet:startingAt:
findSubstring:in:startingAt:matchTable:
Answer the index in the string body at which the substring key first occurs, at or beyond start. The match is determined using matchTable, which can be used to effect, eg, case-insensitive matches. If no match is found, zero will be returned.
hasWideCharacterFrom:to:
Always false because I only contains byte characters
indexOfAscii:inString:startingAt:
isByteString
Answer whether the receiver is a ByteString
isOctetString
Answer whether the receiver can be represented as a byte string.
This is different from asking whether the receiver *is* a ByteString
(i.e., #isByteString)
pvtAt:put:
Primitive. Store the Character in the field of the receiver indicated by
the index. Fail if the index is not an Integer or is out of bounds, or if
the argument is not a Character. Essential. See Object documentation
whatIsAPrimitive.
species
Answer the preferred class for reconstructing the receiver.
string:
stringHash:initialHash:
translate:from:to:table:
Character
I represent a character by storing its associated Unicode. The first 256 characters are created uniquely, so that all instances of latin1 characters ($R, for example) are identical.
The code point is based on Unicode. Since Unicode is 21-bit wide character set, we have several bits available for other information. As the Unicode Standard states, a Unicode code point doesn't carry the language information. This is going to be a problem with the languages so called CJK (Chinese, Japanese, Korean. Or often CJKV including Vietnamese). Since the characters of those languages are unified and given the same code point, it is impossible to display a bare Unicode code point in an inspector or such tools. To utilize the extra available bits, we use them for identifying the languages. Since the old implementation uses the bits to identify the character encoding, the bits are sometimes called "encoding tag" or neutrally "leading char", but the bits rigidly denotes the concept of languages.
The other languages can have the language tag if you like. This will help to break the large default font (font set) into separately loadable chunk of fonts. However, it is open to the each native speakers and writers to decide how to define the character equality, since the same Unicode code point may have different language tag thus simple #= comparison may return false.
I represent a character by storing its associated ASCII code (extended to 256 codes). My instances are created uniquely, so that all instances of a character ($R, for example) are identical.
<
Answer true if the receiver's value < aCharacter's value.
=
Primitive. Answer true if the receiver and the argument are the same
object (have the same object pointer) and false otherwise. Optional. See
Object documentation whatIsAPrimitive.
>
Answer true if the receiver's value > aCharacter's value.
allByteCharacters
allCharacters
alphabet
arrowDown
arrowLeft
arrowRight
arrowUp
asCharacter
Answer the receiver itself.
asIRCLowercase
convert to lowercase, using IRC's rules
asInteger
Answer the value of the receiver.
asLowercase
If the receiver is uppercase, answer its matching lowercase Character.
asString
Answer a string that represents the receiver.
asSymbol
Answer a Symbol consisting of the receiver as the only element.
asText
asUnicode
asUnicodeChar
Answer a copy of the receiver with Unicode as the leadingChar
asUppercase
If the receiver is lowercase, answer its matching uppercase Character.
asciiValue
Answer the value of the receiver that represents its ascii encoding.
backspace
basicSqueakToIso
canBeGlobalVarInitial
canBeNonGlobalVarInitial
charCode
characterTable
clone
Answer with the receiver, because Characters are unique.
codePoint
codePoint:
comeFullyUpOnReload:
Use existing an Character. Don't use the new copy.
constantNameFor:
constantNames
copy
Answer with the receiver because Characters are unique.
cr
deepCopy
Answer with the receiver because Characters are unique.
delete
digitValue
Answer 0-9 if the receiver is $0-$9, 10-35 if it is $A-$Z, and < 0
otherwise. This is used to parse literal numbers of radix 2-36.
digitValue:
end
enter
escape
escapeEntities
euro
hash
Hash is reimplemented because = is implemented.
hex
home
initialize
Subclasses should redefine this method to perform initializations on instance creation
initializeClassificationTable
insert
isAlphaNumeric
Answer whether the receiver is a letter or a digit.
isCharacter
isDigit
isLetter
isLiteral
Answer whether the receiver has a literal text form recognized by the
compiler.
isLowercase
isOctetCharacter
isSafeForHTTP
whether a character is 'safe', or needs to be escaped when used, eg, in a URL
isSeparator
Answer whether the receiver is one of the separator characters--space,
cr, tab, line feed, or form feed.
isSpecial
Answer whether the receiver is one of the special characters
isTraditionalDomestic
Yoshiki's note about #isUnicode says:
[This method] is for the backward compatibility when we had domestic
traditional encodings for CJK languages. To support loading the
projects in traditional domestic encodings (From Nihongo4), and load
some changesets. Once we decided to get rid of classes like JISX0208
from the EncodedCharSet table, the need for isUnicode will not be
necessary.
I (Andreas) decided to change the name from isUnicode to #isTraditionalDomestic
since I found isUnicode to be horribly confusing (how could the character *not*
be Unicode after all?). But still, we should remove this method in due time.
isUppercase
isVowel
Answer whether the receiver is one of the vowels, AEIOU, in upper or
lower case.
javascriptOn:
join:
leadingChar
leadingChar:code:
lf
linefeed
macRomanToUnicode
Convert the receiver from MacRoman Unicode.
nbsp
new
newPage
objectForDataStream:
I am being collected for inclusion in a segment. Do not include Characters! Let them be in outPointers.
pageDown
pageUp
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
printOnStream:
sameAs:
Answer whether the receiver is equal to aCharacter, ignoring case
separators
setValue:
space
storeBinaryOn:
Store the receiver on a binary (file) stream
storeOn:
Common character literals are preceded by '$', however special need to be encoded differently: for some this might be done by using one of the shortcut constructor methods for the rest we have to create them by ascii-value.
tab
to:
Answer with a collection in ascii order -- $a to: $z
tokenish
Answer whether the receiver is a valid token-character--letter, digit, or
colon.
unicodeToMacRoman
Convert the receiver from Unicode to MacRoman encoding.
value:
veryDeepCopyWith:
Return self. I can't be copied.
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.
Collection
I am the abstract superclass of all classes that represent a group of elements.
*
+
,
-
/
//
\\
abs
Absolute value of all elements in the collection
adaptToCollection:andSend:
If I am involved in arithmetic with another Collection, return a Collection of
the results of each element combined with the scalar in that expression.
adaptToComplex:andSend:
If I am involved in arithmetic with a scalar, return a Collection of
the results of each element combined with the scalar in that expression.
adaptToNumber:andSend:
If I am involved in arithmetic with a scalar, return a Collection of
the results of each element combined with the scalar in that expression.
adaptToPoint:andSend:
If I am involved in arithmetic with a scalar, return a Collection of
the results of each element combined with the scalar in that expression.
adaptToString:andSend:
If I am involved in arithmetic with a String, convert it to a Number.
add:
Include newObject as one of the receiver's elements. Answer newObject.
ArrayedCollections cannot respond to this message.
add:withOccurrences:
Add newObject anInteger times to the receiver. Answer newObject.
addAll:
Include all the elements of aCollection as the receiver's elements. Answer
aCollection. Actually, any object responding to #do: can be used as argument.
addIfNotPresent:
Include anObject as one of the receiver's elements, but only if there
is no such element already. Anwser anObject.
addToMetacelloPackages:
addToMetacelloRepositories:
allSatisfy:
Evaluate aBlock with the elements of the receiver.
If aBlock returns false for any element return false.
Otherwise return true.
anyOne
Answer a representative sample of the receiver. This method can
be helpful when needing to preinfer the nature of the contents of
semi-homogeneous collections.
anySatisfy:
Evaluate aBlock with the elements of the receiver.
If aBlock returns true for any element return true.
Otherwise return false.
arcCos
arcSin
arcTan
asArray
Answer an Array whose elements are the elements of the receiver.
Implementation note: Cannot use ''Array withAll: self'' as that only
works for SequenceableCollections which support the replacement
primitive.
asBag
Answer a Bag whose elements are the elements of the receiver.
asByteArray
Answer a ByteArray whose elements are the elements of the receiver.
Implementation note: Cannot use ''ByteArray withAll: self'' as that only
works for SequenceableCollections which support the replacement
primitive.
asCharacterSet
Answer a CharacterSet whose elements are the unique elements of the receiver.
The reciever should only contain characters.
asCommaString
Return collection printed as 'a, b, c'
asCommaStringAnd
Return collection printed as 'a, b and c'
asIdentitySet
asIpByteArray
asKnownNameMenu
Return a menu to select an element of the collection.
Menu uses the knownName or class name as only description of
element.
asOrderedCollection
Answer an OrderedCollection whose elements are the elements of the
receiver. The order in which elements are added depends on the order
in which the receiver enumerates its elements. In the case of unordered
collections, the ordering is not necessarily the same for multiple
requests for the conversion.
asSet
Answer a Set whose elements are the unique elements of the receiver.
asSkipList:
Answer a SkipList whose elements are the elements of the
receiver. The sort order is defined by the argument, aSortBlock.
asSortedArray
Return a copy of the receiver in sorted order, as an Array. 6/10/96 sw
asSortedCollection
Answer a SortedCollection whose elements are the elements of the
receiver. The sort order is the default less than or equal.
asSortedCollection:
Answer a SortedCollection whose elements are the elements of the
receiver. The sort order is defined by the argument, aSortBlock.
asStringOn:delimiter:
Print elements on a stream separated
with a delimiter String like: 'a, b, c'
Uses #asString instead of #print:.
asStringOn:delimiter:last:
Print elements on a stream separated
with a delimiter between all the elements and with
a special one before the last like: 'a, b and c'.
Uses #asString instead of #print:
Note: Feel free to improve the code to detect the last element.
associationsDo:
Evaluate aBlock for each of the receiver's elements (key/value
associations). If any non-association is within, the error is not caught now,
but later, when a key or value message is sent to it.
atRandom
Answer a random element of the receiver. Uses a shared random
number generator owned by class Collection. If you use this a lot,
define your own instance of Random and use #atRandom:. Causes
an error if self has no elements.
atRandom:
Answer a random element of the receiver. Uses aGenerator which
    should be kept by the user in a variable and used every time. Use
    this instead of #atRandom for better uniformity of random numbers because
only you use the generator. Causes an error if self has no elements.
average
browserIcon
capacity
Answer the current capacity of the receiver.
ceiling
chooseOne:
pops up a menu asking for one of the elements in the collection.
If none is chosen, raises a ServiceCancelled notification
collect:
Evaluate aBlock with each of the receiver's elements as the argument.
Collect the resulting values into a collection like the receiver. Answer
the new collection.
collect:displayingProgress:
Evaluate aBlock with each of the receiver's elements as the argument.
Collect the resulting values into a collection like the receiver. Answer
the new collection.
collect:thenDo:
Utility method to improve readability.
collect:thenSelect:
Utility method to improve readability.
collectNINodes
contains:
VW compatibility
contents
copyWith:
Answer a new collection with newElement added (as last
element if sequenceable).
copyWithDependent:
Answer a new collection with newElement added (as last
element if sequenceable).
copyWithout:
Answer a copy of the receiver that does not contain any
elements equal to oldElement.
copyWithoutAll:
Answer a copy of the receiver that does not contain any elements
equal to those in aCollection.
cos
count:
Evaluate aBlock with each of the receiver's elements as the argument.
Answer the number of elements that answered true.
degreeCos
degreeSin
detect:
Evaluate aBlock with each of the receiver's elements as the argument.
Answer the first element for which aBlock evaluates to true.
detect:ifNone:
Evaluate aBlock with each of the receiver's elements as the argument.
Answer the first element for which aBlock evaluates to true. If none
evaluate to true, then evaluate the argument, exceptionBlock.
detectMax:
Evaluate aBlock with each of the receiver's elements as the argument.
Answer the element for which aBlock evaluates to the highest magnitude.
If collection empty, return nil. This method might also be called elect:.
detectMin:
Evaluate aBlock with each of the receiver's elements as the argument.
Answer the element for which aBlock evaluates to the lowest number.
If collection empty, return nil.
detectSum:
Evaluate aBlock with each of the receiver's elements as the argument.
Return the sum of the answers.
difference:
Answer the set theoretic difference of two collections.
do:
Evaluate aBlock with each of the receiver's elements as the argument.
do:displayingProgress:
do:separatedBy:
Evaluate the elementBlock for all elements in the receiver,
and evaluate the separatorBlock between.
do:without:
Enumerate all elements in the receiver.
Execute aBlock for those elements that are not equal to the given item
emptyCheck
errorEmptyCollection
errorNoMatch
errorNotFound:
Actually, this should raise a special Exception not just an error.
errorNotKeyed
exp
explorerContents
explorerContentsWithIndexCollect:
flattenOnStream:
floor
fusionWith:
fusionWithCollection:
gather:
groupBy:having:
Like in SQL operation - Split the recievers contents into collections of
elements for which keyBlock returns the same results, and return those
collections allowed by selectBlock. keyBlock should return an Integer.
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
identityIncludes:
Answer whether anObject is one of the receiver's elements.
ifEmpty:
Evaluate the block if I'm empty
ifEmpty:ifNotEmpty:
Evaluate emptyBlock if I'm empty, notEmptyBlock otherwise
ifEmpty:ifNotEmptyDo:
Evaluate emptyBlock if I'm empty, notEmptyBlock otherwise
ifNotEmpty:
Evaluate the given block unless the receiver is empty.
If the block has an argument, eval with the receiver as its argument,
but it might be better to use ifNotEmptyDo: to make the code easier to
understand
ifNotEmpty:ifEmpty:
Evaluate emptyBlock if I'm empty, notEmptyBlock otherwise
If the notEmptyBlock has an argument, eval with the receiver as its argument
ifNotEmptyDo:
Evaluate the given block with the receiver as its argument.
ifNotEmptyDo:ifEmpty:
Evaluate emptyBlock if I'm empty, notEmptyBlock otherwise
Evaluate the notEmptyBlock with the receiver as its argument
includes:
Answer whether anObject is one of the receiver's elements.
includesAllOf:
Answer whether all the elements of aCollection are in the receiver.
includesAnyOf:
Answer whether any element of aCollection is one of the receiver's elements.
includesSubstringAnywhere:
Answer whether the receiver includes, anywhere in its nested structure, a string that has testString as a substring
initialize
Subclasses should redefine this method to perform initializations on instance creation
inject:into:
Accumulate a running value associated with evaluating the argument,
binaryBlock, with the current value of the argument, thisValue, and the
receiver as block arguments. For instance, to sum the numeric elements
of a collection, aCollection inject: 0 into: [:subTotal :next | subTotal +
next].
insertInto:from:to:
inspectorFields
intersection:
Answer the set theoretic intersection of two collections.
isCollection
Return true if the receiver is some sort of Collection and responds to basic collection messages such as #size and #do:
isEmpty
Answer whether the receiver contains any elements.
isEmptyOrNil
Answer whether the receiver contains any elements, or is nil. Useful in numerous situations where one wishes the same reaction to an empty collection or to nil
isSequenceable
isZero
Answer whether the receiver is zero
javascriptOn:
ln
loadRequiredForMetacelloMCVersion:
log
max
maxChildren
median
mergeIntoMetacelloPackages:
mergeIntoMetacelloRepositories:
min
mutexForPicking
negated
Negated value of all elements in the collection
niActionCategory
niChildrenBlockForIndexedFields
niConfiguration
niDescription
niLabel
niNodeBlockForIndexedFields
noneSatisfy:
Evaluate aBlock with the elements of the receiver.
If aBlock returns false for all elements return true.
Otherwise return false
notEmpty
Answer whether the receiver contains any elements.
occurrencesOf:
Answer how many of the receiver's elements are equal to anObject.
ofSize:
printElementsOn:
The original code used #skip:, but some streams do not support that,
and we don't really need it.
printNameOn:
printOn:
Append a sequence of characters that identify the receiver to aStream.
printOn:delimiter:
Print elements on a stream separated
with a delimiter String like: 'a, b, c'
printOn:delimiter:last:
Print elements on a stream separated
with a delimiter between all the elements and with
a special one before the last like: 'a, b and c'
Note: Feel free to improve the code to detect the last element.
raisedTo:
randomForPicking
range
reciprocal
Return the reciever full of reciprocated elements
reject:
Evaluate aBlock with each of the receiver's elements as the argument.
Collect into a new collection like the receiver only those elements for
which aBlock evaluates to false. Answer the new collection.
reject:thenDo:
Utility method to improve readability.
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.
remove:ifAbsent:
Remove oldObject from the receiver's elements. If several of the
elements are equal to oldObject, only one is removed. If no element is
equal to oldObject, answer the result of evaluating anExceptionBlock.
Otherwise, answer the argument, oldObject. 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
removeAll:
Remove each element of aCollection from the receiver. If successful for
each, answer aCollection. Otherwise create an error notification.
ArrayedCollections cannot respond to this message.
removeAllFoundIn:
Remove each element of aCollection which is present in the receiver
from the receiver. Answer aCollection. No error is raised if an element
isn't found. ArrayedCollections cannot respond to this message.
removeAllSuchThat:
Evaluate aBlock for each element and remove all that elements from
the receiver for that aBlock evaluates to true. Use a copy to enumerate
collections whose order changes when an element is removed (i.e. Sets).
removeFromMetacelloPackages:
removeFromMetacelloRepositories:
renderOn:
Override this method to customize how objects (not components) are rendered when passed as an argument to #render:. The default is the return value of #displayString.
Just remember that you can not use #callback:, #on:of:, or #call:
resolvePackageSpecsNamedForMetacelloMCVersion:visited:ifAbsent:
roundTo:
rounded
sameElements:
select:
Evaluate aBlock with each of the receiver's elements as the argument.
Collect into a new collection like the receiver, only those elements for
which aBlock evaluates to true. Answer the new collection.
select:thenCollect:
Utility method to improve readability.
select:thenDo:
Utility method to improve readability.
Do not create the intermediate collection.
setIncludesInMetacelloPackage:
setLoadsInMetacelloProject:
setRequiresInMetacelloPackage:
sign
sin
size
Answer how many elements the receiver contains.
sqrt
squared
storeOn:
Refer to the comment in Object|storeOn:.
sum
This is implemented using a variant of the normal inject:into: pattern.
The reason for this is that it is not known whether we're in the normal
number line, i.e. whether 0 is a good initial value for the sum.
Consider a collection of measurement objects, 0 would be the unitless
value and would not be appropriate to add with the unit-ed objects.
tan
toBraceStack:
Push receiver's elements onto the stack of thisContext sender. Error if receiver does
not have itsSize elements or if receiver is unordered.
Do not call directly: this is called by {a. b} := ... constructs.
truncated
union:
Answer the set theoretic union of two collections.
with:
with:with:
with:with:with:
with:with:with:with:
with:with:with:with:with:
with:with:with:with:with:with:
withAll:
write:
ColorArray
A ColorArray is xxxxxxxxx.
Instance Variables
asColorArray
at:
Primitive. Assumes receiver is indexable. Answer the value of an
indexable element in the receiver. Fail if the argument index is not an
Integer or is out of bounds. Essential. See Object documentation
whatIsAPrimitive.
at:put:
Primitive. Assumes receiver is indexable. Store the argument value in
the indexable element of the receiver indicated by index. Fail if the
index is not an Integer or is out of bounds. Or fail if the value is not of
the right type for this kind of collection. Answer the value that was
stored. Essential. See Object documentation whatIsAPrimitive.
bytesPerElement
Dictionary
I represent a set of elements that can be viewed from one of two perspectives: a set of associations, or a container of values that are externally named where the name can be any object that responds to =. The external name is referred to as the key. I inherit many operations from Set.
=
Two dictionaries are equal if
(a) they are the same 'kind' of thing.
(b) they have the same set of keys.
(c) for each (common) key, they have the same value
add:
Include newObject as one of the receiver's elements, but only if
not already present. Answer newObject.
addAll:
Include all the elements of aCollection as the receiver's elements. Answer
aCollection. Actually, any object responding to #do: can be used as argument.
associationAt:
associationAt:ifAbsent:
Answer the association with the given key.
If key is not found, return the result of evaluating aBlock.
associationDeclareAt:
Return an existing association, or create and return a new one. Needed as a single message by ImageSegment.prepareToBeSaved.
associations
Answer a Collection containing the receiver's associations.
associationsDo:
Evaluate aBlock for each of the receiver's elements (key/value
associations).
associationsSelect:
Evaluate aBlock with each of my associations as the argument. Collect
into a new dictionary, only those associations for which aBlock evaluates
to true.
at:
Answer the value associated with the key.
at:ifAbsent:
Answer the value associated with the key or, if key isn't found,
answer the result of evaluating aBlock.
at:ifAbsentPut:
Return the value at the given key.
If key is not included in the receiver store the result
of evaluating aBlock as new value.
at:ifPresent:
Lookup the given key in the receiver. If it is present, answer the value of evaluating the given block with the value associated with the key. Otherwise, answer nil.
at:ifPresentAndInMemory:
Lookup the given key in the receiver. If it is present, answer the value of evaluating the given block with the value associated with the key. Otherwise, answer nil.
at:put:
Set the value at key to be anObject. If key is not found, create a
new entry for key and set is value to anObject. Answer anObject.
bindingOf:
bindingsDo:
collect:
Evaluate aBlock with each of my values as the argument. Collect the
resulting values into a collection that is like me. Answer with the new
collection.
collect:displayingProgress:
Evaluate aBlock with each of my values as the argument. Collect the
resulting values into a collection that is like me. Answer with the new
collection.
copy
Must copy the associations, or later store will affect both the
original and the copy
customizeExplorerContents
declare:from:
Add key to the receiver. If key already exists, do nothing. If aDictionary
includes key, then remove it from aDictionary and use its association as
the element of the receiver.
do:
Evaluate aBlock with each of the receiver's elements as the argument.
errorKeyNotFound
errorValueNotFound
explorerContentsWithIndexCollect:
flattenOnStream:
hasBindingThatBeginsWith:
Answer true if the receiver has a key that begins with aString, false otherwise
includes:
Answer whether anObject is one of the receiver's elements.
includesAssociation:
includesIdentity:
Answer whether anObject is one of the values of the receiver. Contrast #includes: in which there is only an equality check, here there is an identity check
includesKey:
Answer whether the receiver has a key equal to the argument, key.
inspectorClass
Answer the class of the inspector to be used on the receiver. Called by inspect;
use basicInspect to get a normal (less useful) type of inspector.
inspectorFields
isDictionary
javascriptOn:
keyAt:
May be overridden by subclasses so that fixCollisions will work
keyAtIdentityValue:
Answer the key that is the external name for the argument, value. If
there is none, answer nil.
Note: There can be multiple keys with the same value. Only one is returned.
keyAtIdentityValue:ifAbsent:
Answer the key that is the external name for the argument, value. If
there is none, answer the result of evaluating exceptionBlock.
Note: There can be multiple keys with the same value. Only one is returned.
keyAtValue:
Answer the key that is the external name for the argument, value. If
there is none, signal an error.
keyAtValue:ifAbsent:
Answer the key that is the external name for the argument, value. If
there is none, answer the result of evaluating exceptionBlock.
: Use =, not ==, so stings like 'this' can be found. Note that MethodDictionary continues to use == so it will be fast.
keyForIdentity:
If anObject is one of the values of the receive, return its key, else return nil. Contrast #keyAtValue: in which there is only an equality check, here there is an identity check
keys
Answer a Set containing the receiver's keys.
keysAndValuesDo:
keysAndValuesRemove:
Removes all entries for which keyValueBlock returns true.
keysDo:
Evaluate aBlock for each of the receiver's keys.
keysSortedSafely
Answer a SortedCollection containing the receiver's keys.
newFrom:
newFromPairs:
niAddNewEntry
niChildrenBlockForIndexedFields
niConfiguration
niDescription
niNodeBlockForIndexedFields
noCheckAdd:
Must be defined separately for Dictionary because (self findElementOrNil:) expects a key, not an association. 9/7/96 tk
occurrencesOf:
Answer how many of the receiver's elements are equal to anObject.
printElementsOn:
The original code used #skip:, but some streams do not support that,
and we don't really need it.
rehash
Smalltalk rehash.
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.
remove:ifAbsent:
Remove oldObject from the receiver's elements. If several of the
elements are equal to oldObject, only one is removed. If no element is
equal to oldObject, answer the result of evaluating anExceptionBlock.
Otherwise, answer the argument, oldObject. ArrayedCollections cannot
respond to this message.
removeKey:
Remove key from the receiver.
If key is not in the receiver, notify an error.
removeKey:ifAbsent:
Remove key (and its associated value) from the receiver. If key is not in
the receiver, answer the result of evaluating aBlock. Otherwise, answer
the value externally named by key.
removeUnreferencedKeys
Undeclared removeUnreferencedKeys
scanFor:
Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or zero if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements.
select:
Evaluate aBlock with each of my values as the argument. Collect into a
new dictionary, only those associations for which aBlock evaluates to
true.
storeOn:
Refer to the comment in Object|storeOn:.
unreferencedKeys
TextConstants unreferencedKeys
valueAtNewKey:put:atIndex:declareFrom:
Support for coordinating class variable and global declarations
with variables that have been put in Undeclared so as to
redirect all references to the undeclared variable.
values
Answer a Collection containing the receiver's values.
valuesCollect:
valuesDo:
Evaluate aBlock for each of the receiver's values.
FloatArray
FloatArrays store 32bit IEEE floating point numbers.
*
*=
+
+=
-
-=
/
/=
=
Answer true if the receiver is equivalent to the otherCollection.
First test for identity, then rule out different species and sizes of
collections. As a last resort, examine each element of the receiver
and the otherCollection.
\\=
adaptToNumber:andSend:
If I am involved in arithmetic with a Number. If possible,
convert it to a float and perform the (more efficient) primitive operation.
asFloatArray
Answer a FloatArray whose elements are the elements of the receiver, in
the same order.
at:
Primitive. Assumes receiver is indexable. Answer the value of an
indexable element in the receiver. Fail if the argument index is not an
Integer or is out of bounds. Essential. See Object documentation
whatIsAPrimitive.
at:put:
Primitive. Assumes receiver is indexable. Store the argument value in
the indexable element of the receiver indicated by index. Fail if the
index is not an Integer or is out of bounds. Or fail if the value is not of
the right type for this kind of collection. Answer the value that was
stored. Essential. See Object documentation whatIsAPrimitive.
defaultElement
Return the default element of the receiver
dot:
Primitive. Return the dot product of the receiver and the argument.
Fail if the argument is not of the same size as the receiver.
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
inspectorClass
Answer the class of the inspector to be used on the receiver. Called by inspect;
use basicInspect to get a normal (less useful) type of inspector.
length
Return the length of the receiver
negated
Negated value of all elements in the collection
primAddArray:
primAddScalar:
primDivArray:
primDivScalar:
primMulArray:
primMulScalar:
primSubArray:
primSubScalar:
replaceFrom:to:with:startingAt:
Primitive. This destructively replaces elements from start to stop in the receiver starting at index, repStart, in the collection, replacement. Answer the receiver. Range checks are performed in the primitive only. Optional. See Object documentation whatIsAPrimitive.
squaredLength
Return the squared length of the receiver
sum
This is implemented using a variant of the normal inject:into: pattern.
The reason for this is that it is not known whether we're in the normal
number line, i.e. whether 0 is a good initial value for the sum.
Consider a collection of measurement objects, 0 would be the unitless
value and would not be appropriate to add with the unit-ed objects.
Heap
Class Heap implements a special data structure commonly referred to as 'heap'. Heaps are more efficient than SortedCollections if:
a) Elements are only removed at the beginning
b) Elements are added with arbitrary sort order.
The sort time for a heap is O(n log n) in all cases.
Instance variables:
array <Array> The data repository
tally <Integer> The number of elements in the heap
sortBlock <Block|nil> A two-argument block defining the sort order,
or nil in which case the default sort order is
[:element1 :element2| element1 <= element2]
indexUpdateBlock <Block|nil>
A two-argument block of the form [:data :index | ... ]
which allows an application object to keep track of its
index within the heap. Useful for quick heap update
when object's sort value changes (for example, when an
object in a priority queue has its priority increased
by an external event, you don't want to have to search
through the whole heap to find the index before fixing
the heap). No update occurs if nil.
=
Answer true if the receiver is equivalent to the otherCollection.
First test for identity, then rule out different species and sizes of
collections. As a last resort, examine each element of the receiver
and the otherCollection.
add:
Include newObject as one of the receiver's elements. Answer newObject.
array
at:
Return the element at the given position within the receiver
at:put:
Heaps are accessed with #add: not #at:put:
do:
Evaluate aBlock with each of the receiver's elements as the argument.
downHeap:
Check the heap downwards for correctness starting at anIndex.
Everything above (i.e. left of) anIndex is ok.
downHeapSingle:
This version is optimized for the case when only one element in the receiver can be at a wrong position. It avoids one comparison at each node when travelling down the heap and checks the heap upwards after the element is at a bottom position. Since the probability for being at the bottom of the heap is much larger than for being somewhere in the middle this version should be faster.
first
Return the first element in the receiver
grow
Become larger.
growSize
Return the size by which the receiver should grow if there are no empty slots left.
growTo:
Grow to the requested size.
indexUpdateBlock:
isEmpty
Answer whether the receiver contains any elements.
isHeap
new
new:
privateRemoveAt:
Remove the element at the given index and make sure the sorting order is okay
reSort
Resort the entire heap
remove:ifAbsent:
Remove oldObject as one of the receiver's elements. If several of the
elements are equal to oldObject, only one is removed. If no element is
equal to oldObject, answer the result of evaluating anExceptionBlock.
Otherwise, answer the argument, oldObject.
removeAt:
Remove the element at given position
removeFirst
Remove the first element from the receiver
setCollection:
setCollection:tally:
size
Answer how many elements the receiver contains.
sortBlock
sortBlock:
sorts:before:
Return true if element1 should be sorted before element2.
This method defines the sort order in the receiver
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.
trim
Remove any empty slots in the receiver.
upHeap:
Check the heap upwards for correctness starting at anIndex.
Everything below anIndex is ok.
updateObjectIndex:
If indexUpdateBlock is not nil, notify the object at index of its new position in the heap array.
withAll:
withAll:sortBlock:
IdentityBag
Like a Bag, except that items are compared with #== instead of #= .
See the comment of IdentitySet for more information.
contentsClass
IdentityDictionary
Like a Dictionary, except that keys are compared with #== instead of #= .
See the comment of IdentitySet for more information.
fasterKeys
This was taking some time in publishing and we didn't really need a Set
keyAtValue:ifAbsent:
Answer the key that is the external name for the argument, value. If
there is none, answer the result of evaluating exceptionBlock.
keys
Answer a Set containing the receiver's keys.
scanFor:
Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or zero if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements.
IdentitySet
The same as a Set, except that items are compared using #== instead of #=.
Almost any class named IdentityFoo is the same as Foo except for the way items are compared. In Foo, #= is used, while in IdentityFoo, #== is used. That is, identity collections will treat items as the same only if they have the same identity.
For example, note that copies of a string are equal:
('abc' copy) = ('abc' copy)
but they are not identitcal:
('abc' copy) == ('abc' copy)
A regular Set will only include equal objects once:
| aSet |
aSet := Set new.
aSet add: 'abc' copy.
aSet add: 'abc' copy.
aSet
An IdentitySet will include multiple equal objects if they are not identical:
| aSet |
aSet := IdentitySet new.
aSet add: 'abc' copy.
aSet add: 'abc' copy.
aSet
asIdentitySet
scanFor:
Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or zero if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements.
IntegerArray
IntegerArrays store 32bit signed Integer values.
Negative values are stored as 2's complement.
asIntegerArray
Answer an IntegerArray whose elements are the elements of the receiver, in
the same order.
at:
Primitive. Assumes receiver is indexable. Answer the value of an
indexable element in the receiver. Fail if the argument index is not an
Integer or is out of bounds. Essential. See Object documentation
whatIsAPrimitive.
at:put:
Primitive. Assumes receiver is indexable. Store the argument value in
the indexable element of the receiver indicated by index. Fail if the
index is not an Integer or is out of bounds. Or fail if the value is not of
the right type for this kind of collection. Answer the value that was
stored. Essential. See Object documentation whatIsAPrimitive.
atAllPut:
Put anObject at every one of the receiver's indices.
defaultElement
Return the default element of the receiver
primFill:
Fill the receiver, an indexable bytes or words object, with the given positive integer. The range of possible fill values is [0..255] for byte arrays and [0..(2^32 - 1)] for word arrays.
Interval
I represent a finite arithmetic progression.
+
-
=
Answer true if the receiver is equivalent to the otherCollection.
First test for identity, then rule out different species and sizes of
collections. As a last resort, examine each element of the receiver
and the otherCollection.
add:
Adding to an Interval is not allowed.
at:
Answer the anInteger'th element.
at:put:
Storing into an Interval is not allowed.
collect:
Evaluate aBlock with each of the receiver's elements as the argument.
Collect the resulting values into a collection like the receiver. Answer
the new collection.
collect:displayingProgress:
Evaluate aBlock with each of the receiver's elements as the argument.
Collect the resulting values into a collection like the receiver. Answer
the new collection.
copy
Return a copy of me. Override the superclass because my species is
Array and copy, as inherited from SequenceableCollection, uses
copyFrom:to:, which creates a new object of my species.
do:
Evaluate aBlock for each value of the interval.
Implementation note: instead of repeatedly incrementing the value
aValue := aValue + step.
until stop is reached,
We prefer to recompute value from start
aValue := aValue + (index * step).
This is better for floating points, while not degrading Integer and
Fraction case too much.
Moreover, this is consistent with methods #at: and #size
extent
Answer the max - min of the receiver interval.
first
Refer to the comment in SequenceableCollection|first.
from:to:
from:to:by:
hash
Hash is reimplemented because = is implemented.
increment
Answer the receiver's interval increment.
indexOf:startingAt:ifAbsent:
startIndex is an positive integer, the collection index where the search is started.
isInterval
isSelfEvaluating
javascriptOn:
last
Refer to the comment in SequenceableCollection|last.
new
newFrom:
permutationsDo:
Repeatly value aBlock with a single copy of the receiver. Reorder the copy
so that aBlock is presented all (self size factorial) possible permutations.
printOn:
Append a sequence of characters that identify the receiver to aStream.
rangeIncludes:
Return true if the number lies in the interval between start and stop.
remove:
Removing from an Interval is not allowed.
reverseDo:
Evaluate aBlock for each element of my interval, in reverse order.
Implementation notes: see do: for an explanation on loop detail
setFrom:to:by:
shallowCopy
Without this method, #copy would return an array instead of a new interval.
The whole problem is burried in the class hierarchy and every fix will worsen
the problem, so once the whole issue is resolved one should come back to this
method fix it.
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.
storeOn:
This is possible because we know numbers store and print the same.
KedamaFloatArray
A KedamaFloatArray is xxxxxxxxx.
Instance Variables
*
*=
+
+=
-
-=
/
/=
primAddArray:and:into:
^ KedamaPlugin doPrimitive: #primitiveAddArrays.
primAddScalar:and:into:
^ KedamaPlugin doPrimitive: #primitiveAddScalar.
primDivArray:and:into:
^ KedamaPlugin doPrimitive: #primitiveDivArrays.
primDivScalar:and:into:
^ KedamaPlugin doPrimitive: #primitiveDivScalar.
primMulArray:and:into:
^ KedamaPlugin doPrimitive: #primitiveMulArrays.
primMulScalar:and:into:
^ KedamaPlugin doPrimitive: #primitiveMulScalar.
primSubArray:and:into:
^ KedamaPlugin doPrimitive: #primitiveSubArrays.
primSubScalar:and:into:
^ KedamaPlugin doPrimitive: #primitiveSubScalar.
KeyedIdentitySet
A KeyedIdentitySet is xxxxxxxxx.
Instance Variables
scanFor:
Same as super except change = to ==, and hash to identityHash
KeyedSet
Like Set except a key of every element is used for hashing and searching instead of the element itself. keyBlock gets the key of an element.
add:
Include newObject as one of the receiver's elements, but only if
not already present. Answer newObject.
addAll:
Include all the elements of aCollection as the receiver's elements
at:
Answer the value associated with the key.
at:ifAbsent:
Answer the value associated with the key or, if key isn't found,
answer the result of evaluating aBlock.
at:ifAbsentPut:
Answer the value associated with the key or, if key isn't found,
add the result of evaluating aBlock to self
at:ifPresent:
Lookup the given key in the receiver. If it is present, answer the value of evaluating the given block with the value associated with the key. Otherwise, answer nil.
copyEmpty
Answer an empty copy of this collection
errorKeyNotFound
fixCollisionsFrom:
The element at index has been removed and replaced by nil.
This method moves forward from there, relocating any entries
that had been placed below due to collisions with this one
includes:
Answer whether anObject is one of the receiver's elements.
includesKey:
initialize:
Initialize array to an array size of n
keyBlock:
When evaluated return the key of the argument which will be an element of the set
keys
keysDo:
keysSorted
member:
Include newObject as one of the receiver's elements, if already exists just return it
noCheckAdd:
rehash
Do nothing. Here so sending this to a Set does not have to do a time consuming respondsTo:
remove:ifAbsent:
Remove oldObject from the receiver's elements. If several of the
elements are equal to oldObject, only one is removed. If no element is
equal to oldObject, answer the result of evaluating anExceptionBlock.
Otherwise, answer the argument, oldObject. ArrayedCollections cannot
respond to this message.
removeAll
See super.
removeKey:
removeKey:ifAbsent:
scanFor:
Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or zero if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements.
LimitedWriteStream
A LimitedWriteStream is a specialized WriteStream that has a maximum size of the collection it streams over. When this limit is reached a special limitBlock is executed. This can for example be used to "bail out" of lengthy streaming operations before they have finished. For a simple example take a look at the universal Object printString.
The message SequenceableCollection class streamContents:limitedTo: creates a LimitedWriteStream. In this case it prevents very large (or possibly recursive) object structures to "overdo" their textual representation.
nextPut:
Ensure that the limit is not exceeded
nextPutAll:
Append the elements of aCollection to the sequence of objects accessible
by the receiver. Answer aCollection.
pastEndPut:
Grow the collection by doubling the size, but keeping the growth between 20 and 1000000.
Then put <anObject> at the current write position.
setLimit:limitBlock:
Limit the numer of elements this stream will write...
LimitingLineStreamWrapper
I'm a wrapper for a stream optimized for line-by-line access using #nextLine. My instances can be nested.
I read one line ahead. Reading terminates when the stream ends, or if the limitingBlock evaluated with the line answers true. To skip the delimiting line for further reading use #skipThisLine.
Character-based reading (#next) is permitted, too. Send #updatePosition when switching from line-based reading.
See examples at the class side.
--bf 2/19/1999 12:52
atEnd
close
delimiter:
Set limitBlock to check for a delimiting string. Be unlimiting if nil
example1
example2
exampleStream
lastLineRead
Return line last read. At stream end, this is the boundary line or nil
limitingBlock:
The limitingBlock is evaluated with a line to check if this line terminates the stream
linesUpToEnd
next
Provide character-based access
nextLine
on:delimiter:
peekLine
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
setStream:delimiter:
skipThisLine
upToEnd
updatePosition
Call this before doing character-based access
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.
LinkedList
I represent a collection of links, which are containers for other objects. Using the message sequence addFirst:/removeLast causes the receiver to behave as a stack; using addLast:/removeFirst causes the receiver to behave as a queue.
add:
Add aLink to the end of the receiver's list. Answer aLink.
add:after:
Add otherLink after link in the list. Answer aLink.
add:before:
addFirst:
Add aLink to the beginning of the receiver's list. Answer aLink.
addLast:
Add aLink to the end of the receiver's list. Answer aLink.
at:
Primitive. Assumes receiver is indexable. Answer the value of an
indexable element in the receiver. Fail if the argument index is not an
Integer or is out of bounds. Essential. See Object documentation
whatIsAPrimitive.
do:
Refer to the comment in Collection|do:.
first
Answer the first link. Create an error notification if the receiver is
empty.
isEmpty
Answer whether the receiver contains any elements.
last
Answer the last link. Create an error notification if the receiver is
empty.
remove:ifAbsent:
Remove aLink from the receiver. If it is not there, answer the result of
evaluating aBlock.
removeAll
Implementation note: this has to be fast
removeFirst
Remove the first element and answer it. If the receiver is empty, create
an error notification.
removeLast
Remove the receiver's last element and answer it. If the receiver is
empty, create an error notification.
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.
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:
Matrix
I represent a two-dimensional array, rather like Array2D.
There are three main differences between me and Array2D:
(1) Array2D inherits from ArrayedCollection, but isn't one. A lot of things that should work
do not work in consequence of this.
(2) Array2D uses "at: column at: row" index order, which means that nothing you write using
it is likely to work either. I use the almost universal "at: row at: column" order, so it is
much easier to adapt code from other languages without going doolally.
(3) Array2D lets you specify the class of the underlying collection, I don't.
Structure:
nrows : a non-negative integer saying how many rows there are.
ncols : a non-negative integer saying how many columns there are.
contents : an Array holding the elements in row-major order. That is, for a 2x3 array
the contents are (11 12 13 21 22 23). Array2D uses column major order.
You can specify the class of 'contents' when you create a new Array2D,
but Matrix always gives you an Array.
There is a reason for this. In strongly typed languages like Haskell and Clean,
'unboxed arrays' save you both space AND time. But in Squeak, while
WordArray and FloatArray and so on do save space, it costs time to use them.
A LOT of time. I've measured aFloatArray sum running nearly twice as slow as
anArray sum. The reason is that whenever you fetch an element from an Array,
that's all that happens, but when you fetch an element from aFloatArray, a whole
new Float gets allocated to hold the value. This takes time and churns memory.
So the paradox is that if you want fast numerical stuff, DON'T use unboxed arrays!
Another reason for always insisting on an Array is that letting it be something
else would make things like #, and #,, rather more complicated. Always using Array
is the simplest thing that could possibly work, and it works rather well.
I was trying to patch Array2D to make more things work, but just couldn't get my head
around the subscript order. That's why I made Matrix.
Element-wise matrix arithmetic works; you can freely mix matrices and numbers but
don't try to mix matrices and arrays (yet).
Matrix multiplication, using the symbol +* (derived from APL's +.x), works between
(Matrix or Array) +* (Matrix or Array). Don't try to use a number as an argument of +*.
Matrix * Number and Number * Matrix work fine, so you don't need +* with numbers.
Still to come: oodles of stuff. Gaussian elimination maybe, other stuff probably not.
+*
Premultiply aCollection by self. aCollection should be an Array or Matrix.
The name of this method is APL's +.x squished into Smalltalk syntax.
,
Answer a new matrix having the same number of rows as the receiver and aMatrix,
its columns being the columns of the receiver followed by the columns of aMatrix.
,,
Answer a new matrix having the same number of columns as the receiver and aMatrix,
its rows being the rows of the receiver followed by the rows of aMatrix.
=
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.
anyOne
Answer a representative sample of the receiver. This method can
be helpful when needing to preinfer the nature of the contents of
semi-homogeneous collections.
asArray
Answer an Array whose elements are the elements of the receiver.
Implementation note: Cannot use ''Array withAll: self'' as that only
works for SequenceableCollections which support the replacement
primitive.
asBag
Answer a Bag whose elements are the elements of the receiver.
asByteArray
Answer a ByteArray whose elements are the elements of the receiver.
Implementation note: Cannot use ''ByteArray withAll: self'' as that only
works for SequenceableCollections which support the replacement
primitive.
asCharacterSet
Answer a CharacterSet whose elements are the unique elements of the receiver.
The reciever should only contain characters.
asFloatArray
asIdentitySet
asIntegerArray
asOrderedCollection
Answer an OrderedCollection whose elements are the elements of the
receiver. The order in which elements are added depends on the order
in which the receiver enumerates its elements. In the case of unordered
collections, the ordering is not necessarily the same for multiple
requests for the conversion.
asSet
Answer a Set whose elements are the unique elements of the receiver.
asSortedArray
Return a copy of the receiver in sorted order, as an Array. 6/10/96 sw
asSortedCollection
Answer a SortedCollection whose elements are the elements of the
receiver. The sort order is the default less than or equal.
asSortedCollection:
Answer a SortedCollection whose elements are the elements of the
receiver. The sort order is defined by the argument, aSortBlock.
asWordArray
at:at:
at:at:ifInvalid:
If r,c is a valid index for this matrix, answer the corresponding element.
Otherwise, answer v.
at:at:incrementBy:
Array2D>>at:at:add: was the origin of this method, but in Smalltalk add:
generally suggests adding an element to a collection, not doing a sum.
This method, and SequenceableCollection>>at:incrementBy: that supports
it, have been renamed to reveal their intention more clearly.
at:at:put:
atAllPut:
atColumn:
atColumn:put:
atRandom
Answer a random element of the receiver. Uses a shared random
number generator owned by class Collection. If you use this a lot,
define your own instance of Random and use #atRandom:. Causes
an error if self has no elements.
atRandom:
Answer a random element of the receiver. Uses aGenerator which
    should be kept by the user in a variable and used every time. Use
    this instead of #atRandom for better uniformity of random numbers because
only you use the generator. Causes an error if self has no elements.
atRow:
atRow:put:
atRows:columns:
Answer a Matrix obtained by slicing the receiver.
rs and cs should be sequenceable collections of positive integers.
atRows:to:columns:to:
Answer a submatrix [r1..r2][c1..c2] of the receiver.
atRows:to:columns:to:ifInvalid:
Answer a submatrix [r1..r2][c1..c2] of the receiver.
Portions of the result outside the bounds of the original matrix
are filled in with element.
atRows:to:columns:to:put:
Set the [r1..r2][c1..c2] submatrix of the receiver
from the [1..r2-r1+1][1..c2-c1+1] submatrix of aMatrix.
As long as aMatrix responds to at:at: and accepts arguments in the range shown,
we don't care if it is bigger or even if it is a Matrix at all.
collect:
Answer a new matrix with transformed elements; transformations should be independent.
column:
columnCount
copy
Answer another instance just like the receiver. Subclasses typically override postCopy; they typically do not override shallowCopy.
diagonal
Answer (1 to: (nrows min: ncols)) collect: [:i | self at: i at: i]
diagonal:
difference:
Union is in because the result is always a Set.
Difference and intersection are out because the result is like the receiver,
and with irregular seleection that cannot be.
do:
Pass elements to aBlock one at a time in row-major order.
hash
I'm really not sure what would be a good hash function here.
The essential thing is that it must be compatible with #=, and
this satisfies that requirement.
identity:
identityIncludes:
Answer whether anObject is one of the receiver's elements.
identityIndexOf:
identityIndexOf:ifAbsent:
includes:
Answer whether anObject is one of the receiver's elements.
includesAllOf:
Answer whether all the elements of aCollection are in the receiver.
includesAnyOf:
Answer whether any element of aCollection is one of the receiver's elements.
indexForRow:andColumn:
indexOf:
If there are integers r, c such that (self at: r at: c) = anElement,
answer some such r@c, otherwise answer 0@0. This kind of perverse
result is provided by analogy with SequenceableCollection>>indexOf:.
The order in which the receiver are searched is UNSPECIFIED except
that it is the same as the order used by #indexOf:ifAbsent: and #readStream.
indexOf:ifAbsent:
If there are integers r, c such that (self at: r at: c) = anElement,
answer some such r@c, otherwise answer the result of anExceptionBlock.
indicesCollect:
indicesDo:
indicesInject:into:
intersection:
Union is in because the result is always a Set.
Difference and intersection are out because the result is like the receiver,
and with irregular seleection that cannot be.
isSequenceable
LIE so that arithmetic on matrices will work.
What matters for arithmetic is not that there should be random indexing
but that the structure should be stable and independent of the values of
the elements. #isSequenceable is simply the wrong question to ask.
new:
new:element:
new:tabulate:
occurrencesOf:
Answer how many of the receiver's elements are equal to anObject.
ones:
preMultiplyByArray:
Answer a +* self where a is an Array.
preMultiplyByMatrix:
Answer m +* self where m is a Matrix.
privateContents
Only used in #, #,, and #= so far.
It used to be called #contents, but that clashes with Collection>>contents.
readStream
Answer a ReadStream that returns all the elements of the receiver
in some UNSPECIFIED order.
reject:
Evaluate aBlock with each of the receiver's elements as the argument.
Collect into a new collection like the receiver only those elements for
which aBlock evaluates to false. Answer the new collection.
remove:ifAbsent:
Remove oldObject from the receiver's elements. If several of the
elements are equal to oldObject, only one is removed. If no element is
equal to oldObject, answer the result of evaluating anExceptionBlock.
Otherwise, answer the argument, oldObject. ArrayedCollections cannot
respond to this message.
replaceAll:with:
row:
rowAndColumnForIndex:
rowCount
rows:columns:
rows:columns:contents:
rows:columns:element:
rows:columns:tabulate:
select:
Evaluate aBlock with each of the receiver's elements as the argument.
Collect into a new collection like the receiver, only those elements for
which aBlock evaluates to true. Answer the new collection.
shallowCopy
Answer a copy of the receiver which shares the receiver's instance variables.
shuffled
shuffledBy:
size
Answer how many elements the receiver contains.
storeOn:
Refer to the comment in Object|storeOn:.
swap:at:with:at:
swapColumn:withColumn:
swapRow:withRow:
transposed
with:collect:
aCollection must support #at:at: and be at least as large as the receiver.
with:do:
aCollection must support #at:at: and be at least as large as the receiver.
with:inject:into:
aCollection must support #at:at: and be at least as large as the receiver.
withIndicesCollect:
withIndicesDo:
withIndicesInject:into:
zeros:
OrderedCollection
I represent a collection of objects ordered by the collector.
add:
Include newObject as one of the receiver's elements. Answer newObject.
ArrayedCollections cannot respond to this message.
add:after:
Add the argument, newObject, as an element of the receiver. Put it in
the sequence just succeeding oldObject. Answer newObject.
add:afterIndex:
Add the argument, newObject, as an element of the receiver. Put it in
the sequence just after index. Answer newObject.
add:before:
Add the argument, newObject, as an element of the receiver. Put it in
the sequence just preceding oldObject. Answer newObject.
add:beforeIndex:
Add the argument, newObject, as an element of the receiver. Put it in
the sequence just before index. Answer newObject.
addAll:
Add each element of aCollection at my end. Answer aCollection.
addAllFirst:
Add each element of anOrderedCollection at the beginning of the
receiver. Answer anOrderedCollection.
addAllFirstUnlessAlreadyPresent:
Add each element of anOrderedCollection at the beginning of the receiver, preserving the order, but do not add any items that are already in the receiver. Answer anOrderedCollection.
addAllLast:
Add each element of anOrderedCollection at the end of the receiver.
Answer anOrderedCollection.
addFirst:
Add newObject to the beginning of the receiver. Answer newObject.
addLast:
Add newObject to the end of the receiver. Answer newObject.
asArray
Answer an Array whose elements are the elements of the receiver.
at:
Answer my element at index anInteger. at: is used by a knowledgeable
client to access an existing element
at:ifAbsentPut:
Return value at index, however, if value does not exist (nil or out of bounds) then add block's value at index (growing self if necessary)
at:put:
Put anObject at element index anInteger. at:put: cannot be used to
append, front or back, to an ordered collection; it is used by a
knowledgeable client to replace an element.
capacity
Answer the current capacity of the receiver.
collect:
Evaluate aBlock with each of my elements as the argument. Collect the
resulting values into a collection that is like me. Answer the new
collection. Override superclass in order to use addLast:, not at:put:.
collect:displayingProgress:
Evaluate aBlock with each of my elements as the argument. Collect the
resulting values into a collection that is like me. Answer the new
collection. Override superclass in order to use addLast:, not at:put:.
collect:from:to:
Override superclass in order to use addLast:, not at:put:.
collect:thenSelect:
Utility method to improve readability.
Do not create the intermediate collection.
collector
Private
copyEmpty
Answer a copy of the receiver that contains no elements.
copyFrom:to:
Answer a copy of the receiver that contains elements from position
startIndex to endIndex.
copyReplaceFrom:to:with:
Answer a copy of the receiver with replacementCollection's elements in
place of the receiver's start'th to stop'th elements. This does not expect
a 1-1 map from replacementCollection to the start to stop elements, so it
will do an insert or append.
copyWith:
Answer a copy of the receiver that is 1 bigger than the receiver and
includes the argument, newElement, at the end.
do:
Override the superclass for performance reasons.
errorConditionNotSatisfied
errorNoSuchElement
find:
This method answers an index in the range firstIndex .. lastIndex, which is meant for internal use only.
Never use this method in your code, the methods for public use are:
#indexOf:
#indexOf:ifAbsent:
grow
Become larger. Typically, a subclass has to override this if the subclass
adds instance variables.
growSize
hasContentsInExplorer
insert:before:
spot is an index in the range firstIndex .. lastIndex, such an index is not known from outside the collection.
Never use this method in your code, it is meant for private use by OrderedCollection only.
The methods for use are:
#add:before: to insert an object before another object
#add:beforeIndex: to insert an object before a given position.
inspectorClass
Answer the class of the inspector to be used on the receiver. Called by inspect;
use basicInspect to get a normal (less useful) type of inspector.
join:
NB: this implementation only works for Array, since WriteStreams only work for Arrays and Strings. (!)
Overridden in OrderedCollection and SortedCollection.
makeRoomAtFirst
makeRoomAtLast
makeRoomFor:
new
new:
new:withAll:
newFrom:
niActions
niAddLast
niChildrenBlockForIndexedFields
ofSize:
postCopyFrom:to:
finish copying the array in a certain range.
remove:ifAbsent:
SequencableCollections cannot implement removing.
removeAll
remove all the elements from this collection.
Keep same amount of storage
removeAllSuchThat:
Remove each element of the receiver for which aBlock evaluates to true.
The method in Collection is O(N^2), this is O(N).
removeAt:
removeFirst
Remove the first element of the receiver and answer it. If the receiver is
empty, create an error notification.
removeFirst:
Remove first n object into an array
removeIndex:
removedIndex is an index in the range firstIndex .. lastIndex, such an index is not known from outside the collection.
Never use this method in your code, it is meant for private use by OrderedCollection only.
The method for public use is:
#removeAt:
removeLast
Remove the last element of the receiver and answer it. If the receiver is
empty, create an error notification.
removeLast:
Remove last n object into an array with last in last position
replaceFrom:to:with:startingAt:
An ordered collection is growable, so a call to this can make the collection grow.
reset
resetTo:
restoreFromSnapshot:
reverseDo:
Override the superclass for performance reasons.
reversed
Answer a copy of the receiver with element order reversed.
select:
Evaluate aBlock with each of my elements as the argument. Collect into
a new collection like the receiver, only those elements for which aBlock
evaluates to true.
select:thenCollect:
Utility method to improve readability.
Do not create the intermediate collection.
setCollection:
setContents:
size
Answer how many elements the receiver contains.
unsafeRemoveFirst
Remove the first element of the receiver and answer it. If the receiver is
empty, create an error notification.
with:collect:
Collect and return the result of evaluating twoArgBlock with
corresponding elements from this collection and otherCollection.
withIndexCollect:
Just like with:collect: except that the iteration index supplies the second argument to the block. Override superclass in order to use addLast:, not at:put:.
withIndexCollect:displayingProgress:
Just like with:collect: except that the iteration index supplies the second argument to the block. Override superclass in order to use addLast:, not at:put:.
PluggableDictionary
Class PluggableDictionary allows the redefinition of hashing and equality by clients. This is in particular useful if the clients know about specific properties of the objects stored in the dictionary. See the class comment of PluggableSet for an example.
Instance variables:
hashBlock <BlockContext> A one argument block used for hashing the elements.
equalBlock <BlockContext> A two argument block used for comparing the elements.
copyEmpty
Answer an empty copy of this collection
equalBlock
Return the block used for comparing the elements in the receiver.
equalBlock:
Set a new equality block. The block must accept two arguments and return true if the argumets are considered to be equal, false otherwise
hashBlock
Return the block used for hashing the elements in the receiver.
hashBlock:
Set a new hash block. The block must accept one argument and must return the hash value of the given argument.
integerDictionary
keys
Answer a Set containing the receiver's keys.
scanFor:
Scan the key array for the first slot containing either a nil
(indicating
an empty slot) or an element that matches anObject. Answer the index

of that slot or zero if no slot is found. This method will be
overridden
in various subclasses that have different interpretations for matching

elements.
PluggableSet
PluggableSets allow the redefinition of hashing and equality by clients. This is in particular useful if the clients know about specific properties of the objects stored in the set which in turn can heavily improve the performance of sets and dictionaries.
Instance variables:
hashBlock <BlockContext> A one argument block used for hashing the elements.
equalBlock <BlockContext> A two argument block used for comparing the elements.
Example: Adding 1000 integer points in the range (0@0) to: (100@100) to a set.
| rnd set max pt |
set _ Set new: 1000.
rnd _ Random new.
max _ 100.
Time millisecondsToRun:[
1 to: 1000 do:[:i|
pt _ (rnd next * max) truncated @ (rnd next * max) truncated.
set add: pt.
].
].
The above is way slow since the default hashing function of points leads to an awful lot of collisions in the set. And now the same, with a somewhat different hash function:
| rnd set max pt |
set _ PluggableSet new: 1000.
set hashBlock:[:item| (item x bitShift: 16) + item y].
rnd _ Random new.
max _ 100.
Time millisecondsToRun:[
1 to: 1000 do:[:i|
pt _ (rnd next * max) truncated @ (rnd next * max) truncated.
set add: pt.
].
].
copyEmpty
Answer an empty copy of this collection
equalBlock
Return the block used for comparing the elements in the receiver.
equalBlock:
Set a new equality block. The block must accept two arguments and return true if the argumets are considered equal, false otherwise
hashBlock
Return the block used for hashing the elements in the receiver.
hashBlock:
Set a new hash block. The block must accept one argument and return the hash value of the given argument.
integerSet
scanFor:
Scan the key array for the first slot containing either a nil
(indicating
an empty slot) or an element that matches anObject. Answer the index

of that slot or zero if no slot is found. This method will be
overridden
in various subclasses that have different interpretations for matching

elements.
PluggableTextAttribute
An attribute which evaluates an arbitrary block when it is selected.
actOnClickFor:
Subclasses may override to provide, eg, hot-spot actions
evalBlock:
PositionableStream
I represent an accessor for a sequence of objects (a collection) that are externally named by indices so that the point of access can be repositioned. I am abstract in that I do not implement the messages next and nextPut: which are inherited from my superclass Stream.
asBinaryOrTextStream
Convert to a stream that can switch between bytes and characters
asMIMEDocument
asMIMEDocumentType:
asZLibReadStream
atEnd
Primitive. Answer whether the receiver can access any more objects.
Optional. See Object documentation whatIsAPrimitive.
back
Go back one element and return it.
backChunk
Answer the contents of the receiver back to the previous terminator character. Doubled terminators indicate an embedded terminator character.
backUpTo:
Back up the position to he subCollection. Position must be somewhere within the stream initially. Leave it just after it. Return true if succeeded. No wildcards, and case does matter.
basicNextChunk
Answer the contents of the receiver, up to the next terminator character. Doubled terminators indicate an embedded terminator character.
boolean
Answer the next boolean value from this (binary) stream.
boolean:
Store the given boolean value on this (binary) stream.
checkForPreamble:
contents
Answer with a copy of my collection from 1 to readLimit.
contentsOfEntireFile
For non-file streams
copyMethodChunkFrom:
Copy the next chunk from aStream (must be different from the receiver).
copyMethodChunkFrom:at:
Copy the next chunk from aStream (must be different from the receiver).
copyPreamble:from:at:
Look for a changeStamp for this method by peeking backward.
Write a method preamble, with that stamp if found.
decodeString:andRuns:
decodeStyle:version:
Decode the runs array from the ReferenceStream it is stored in.
fileIn
This is special for reading expressions from text that has been formatted
with exclamation delimitors. The expressions are read and passed to the
Compiler. Answer the result of compilation.
fileInAnnouncing:
This is special for reading expressions from text that has been formatted
with exclamation delimitors. The expressions are read and passed to the
Compiler. Answer the result of compilation. Put up a progress report with
the given announcement as the title.
fileInFor:announcing:
This is special for reading expressions from text that has been formatted
with exclamation delimitors. The expressions are read and passed to the
Compiler. Answer the result of compilation. Put up a progress report with
the given announcement as the title.
Does NOT handle preambles or postscripts specially.
fileInSilentlyAnnouncing:
This is special for reading expressions from text that has been formatted
with exclamation delimitors. The expressions are read and passed to the
Compiler. Answer the result of compilation. Put up a progress report with
the given announcement as the title.
header
If the stream requires a standard header, override this message. See HtmlFileStream
int16
Answer the next signed, 16-bit integer from this (binary) stream.
int16:
Store the given signed, 16-bit integer on this (binary) stream.
int32
Answer the next signed, 32-bit integer from this (binary) stream.
int32:
Store the given signed, 32-bit integer on this (binary) stream.
isBinary
Return true if the receiver is a binary byte stream
isEmpty
Answer whether the receiver's contents has no elements.
last
Return the final element in the receiver
match:
Set the access position of the receiver to be past the next occurrence of the subCollection. Answer whether subCollection is found. No wildcards, and case does matter.
next:
Answer the next anInteger elements of my collection. Must override
because default uses self contents species, which might involve a large
collection.
next:into:
Read n objects into the given collection.
Return aCollection or a partial copy if less than
n elements have been read.
next:into:startingAt:
Read n objects into the given collection.
Return aCollection or a partial copy if less than
n elements have been read.
next:putAll:
Store the next anInteger elements from the given collection.
next:putAll:startingAt:
Store the next anInteger elements from the given collection.
nextChunk
Answer the contents of the receiver, up to the next terminator character. Doubled terminators indicate an embedded terminator character.
nextChunkText
Deliver the next chunk as a Text. Decode the following ]style[ chunk if present. Position at start of next real chunk.
nextDelimited:
Answer the contents of the receiver, up to the next terminator character. Doubled terminators indicate an embedded terminator character. For example: 'this '' was a quote'. Start postioned before the initial terminator.
nextInt32
Read a 32-bit signed integer from the next 4 bytes
nextInt32Put:
Write a signed integer to the next 4 bytes
nextInto:
Read the next elements of the receiver into aCollection.
Return aCollection or a partial copy if less than aCollection
size elements have been read.
nextInto:startingAt:
Read the next elements of the receiver into aCollection.
Return aCollection or a partial copy if less than aCollection
size elements have been read.
nextLine
Answer next line (may be empty), or nil if at end
nextLittleEndianNumber:
Answer the next n bytes as a positive Integer or LargePositiveInteger, where the bytes are ordered from least significant to most significant.
nextLittleEndianNumber:put:
Answer the next n bytes as a positive Integer or LargePositiveInteger, where the bytes are ordered from least significant to most significant.
nextNumber:
Answer the next n bytes as a positive Integer or LargePositiveInteger.
nextNumber:put:
Append to the receiver the argument, v, which is a positive
SmallInteger or a LargePositiveInteger, as the next n bytes.
Possibly pad with leading zeros.
nextString
Read a string from the receiver. The first byte is the length of the string, unless it is greater than 192, in which case the first four bytes encode the length. I expect to be in ascii mode when called (caller puts back to binary).
nextStringOld
Read a string from the receiver. The first byte is the length of the
string, unless it is greater than 192, in which case the first *two* bytes
encode the length. Max size 16K.
nextStringPut:
Append the string, s, to the receiver. Only used by DataStream. Max size of 64*256*256*256.
nextWord
Answer the next two bytes from the receiver as an Integer.
nextWordPut:
Append to the receiver an Integer as the next two bytes.
nextWordsInto:
Fill the word based buffer from my collection.
Stored on stream as Big Endian. Optimized for speed.
Read in BigEndian, then restoreEndianness.
oldBack
Go back one element and return it. Use indirect messages in case I am a StandardFileStream
oldPeekBack
Return the element at the previous position, without changing position. Use indirect messages in case self is a StandardFileStream.
on:
on:from:to:
originalContents
Answer the receiver's actual contents collection, NOT a copy. 1/29/96 sw
padTo:put:
Pad using the argument, aCharacter, to the next boundary of nBytes characters.
padToNextLongPut:
Make position be on long word boundary, writing the padding
character, char, if necessary.
parseLangTagFor:
peek
Answer what would be returned if the message next were sent to the
receiver. If the receiver is at the end, answer nil.
peekBack
Return the element at the previous position, without changing position. Use indirect messages in case self is a StandardFileStream.
peekFor:
Answer false and do not move over the next element if it is not equal to
the argument, anObject, or if the receiver is at the end. Answer true
and increment the position for accessing elements, if the next element is
equal to anObject.
position
Answer the current position of accessing the sequence of objects.
position:
Set the current position for accessing the objects to be anInteger, as long
as anInteger is within the bounds of the receiver's contents. If it is not,
create an error notification.
positionError
Since I am not necessarily writable, it is up to my subclasses to override
position: if expanding the collection is preferrable to giving this error.
positionOfSubCollection:
Return a position such that that element at the new position equals the first element of sub, and the next elements equal the rest of the elements of sub. Begin the search at the current position.
If no such match is found, answer 0.
positionOfSubCollection:ifAbsent:
Return a position such that that element at the new position equals the first element of sub, and the next elements equal the rest of the elements of sub. Begin the search at the current position.
If no such match is found, answer the result of evaluating argument, exceptionBlock.
pushBack:
Compatibility with SocketStreams
reset
Set the receiver's position to the beginning of the sequence of objects.
resetContents
Set the position and limits to 0.
setFrom:to:
setToEnd
Set the position of the receiver to the end of the sequence of objects.
skip:
Set the receiver's position to be the current position+anInteger. A
subclass might choose to be more helpful and select the minimum of the
receiver's size and position+anInteger, or the maximum of 1 and
position+anInteger for the repositioning.
skipSeparators
skipSeparatorsAndPeekNext
A special function to make nextChunk fast
skipStyleChunk
Get to the start of the next chunk that is not a style for the previous chunk
skipTo:
Set the access position of the receiver to be past the next occurrence of
anObject. Answer whether anObject is found.
string
Answer the next string from this (binary) stream.
string:
Store the given string on this (binary) stream. The string must contain 65535 or fewer characters.
trailer
If the stream requires a standard trailer, override this message. See HtmlFileStream
uint16
Answer the next unsigned, 16-bit integer from this (binary) stream.
uint16:
Store the given unsigned, 16-bit integer on this (binary) stream.
uint24
Answer the next unsigned, 24-bit integer from this (binary) stream.
uint24:
Store the given unsigned, 24-bit integer on this (binary) stream.
uint32
Answer the next unsigned, 32-bit integer from this (binary) stream.
uint32:
Store the given unsigned, 32-bit integer on this (binary) stream.
unCommand
If this read stream is at a <, then skip up to just after the next >. For removing html commands.
untilEnd:displayingProgress:
untilEndWithFork:displayingProgress:
upTo:
Answer a subcollection from the current access position to the
occurrence (if any, but not inclusive) of anObject in the receiver. If
anObject is not in the collection, answer the entire rest of the receiver.
upToAll:
Answer a subcollection from the current access position to the occurrence (if any, but not inclusive) of aCollection. If aCollection is not in the stream, answer the entire rest of the stream.
upToAndSkipThroughAll:
Needed for Seaside ports to other dialects where #upToAll: may have
different semantics
upToAny:
Answer a subcollection from the current access position to the
occurrence (if any, but not inclusive) of any objects in the given collection in the receiver. If
any of these is not in the collection, answer the entire rest of the receiver.
upToEnd
Answer a subcollection from the current access position through the last element of the receiver.
verbatim:
Do not attempt to translate the characters. Use to override nextPutAll:
RWBinaryOrTextStream
A simulation of a FileStream, but living totally in memory. Hold the contents of a file or web page from the network. Can then fileIn like a normal FileStream.
Need to be able to switch between binary and text, as a FileStream does, without recopying the whole collection. Convert to binary upon input and output. Always keep as text internally.
asBinaryOrTextStream
Convert to a stream that can switch between bytes and characters
ascii
binary
do nothing
contents
Answer with a copy of my collection from 1 to readLimit.
isBinary
Return true if the receiver is a binary byte stream
next
Primitive. Return the next object in the Stream represented by the
receiver. Fail if the collection of this stream is not an Array or a String.
Fail if the stream is positioned at its end, or if the position is out of
bounds in the collection. Optional. See Object documentation
whatIsAPrimitive.
next:
Answer the next anInteger elements of my collection. Must override to get class right.
next:into:startingAt:
Read n objects into the given collection.
Return aCollection or a partial copy if less than n elements have been read.
next:putAll:startingAt:
Optimized for ByteArrays
nextPut:
Primitive. Insert the argument at the next position in the Stream
represented by the receiver. Fail if the collection of this stream is not an
Array or a String. Fail if the stream is positioned at its end, or if the
position is out of bounds in the collection. Fail if the argument is not
of the right type for the collection. Optional. See Object documentation
whatIsAPrimitive.
nextPutAll:
Optimized for ByteArrays
padToEndWith:
We don't have pages, so we are at the end, and don't need to pad.
reset
Set the receiver's position to the beginning of the sequence of objects.
setFileTypeToObject
do nothing. We don't have a file type
text
upTo:
Answer a subcollection from the current access position to the
occurrence (if any, but not inclusive) of anObject in the receiver. If
anObject is not in the collection, answer the entire rest of the receiver.
upToEnd
Must override to get class right.
ReadStream
I represent an accessor for a sequence of objects that can only read objects from the sequence.
ascii
localName
next
Primitive. Answer the next object in the Stream represented by the
receiver. Fail if the collection of this stream is not an Array or a String.
Fail if the stream is positioned at its end, or if the position is out of
bounds in the collection. Optional. See Object documentation
whatIsAPrimitive.
next:
Answer the next anInteger elements of my collection. overriden for efficiency
next:into:startingAt:
Read n objects into the given collection.
Return aCollection or a partial copy if less than
n elements have been read.
nextPut:
Insert the argument, anObject, as the next object accessible by the
receiver. Answer anObject.
on:from:to:
readStream
polymorphic with SequenceableCollection. Return self
size
Compatibility with other streams (e.g., FileStream)
upTo:
fast version using indexOf:
upToEnd
Answer a subcollection from the current access position through the last element of the receiver.
ReadWriteStream
I represent an accessor for a sequence of objects. My instances can both read and store objects.
=
Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.
asHttpResponseTo:
asUnZippedStream
Decompress this file if needed, and return a stream. No file is written. File extension may be .gz or anything else. Also works on archives (.zip, .gZip).
contents
Answer with a copy of my collection from 1 to readLimit.
fileInObjectAndCode
This file may contain:
1) a fileIn of code
2) just an object in SmartReferenceStream format
3) both code and an object.
File it in and return the object. Note that self must be a FileStream or RWBinaryOrTextStream. Maybe ReadWriteStream incorporate RWBinaryOrTextStream?
fileNameEndsWith:
See comment in FileStream fileNameEndsWith:
fileOutChangeSet:andObject:
Write a file that has both the source code for the named class and an object as bits. Any instance-specific object will get its class written automatically.
fileOutChanges
Append to the receiver a description of all class changes.
fileOutClass:andObject:
Write a file that has both the source code for the named class and an object as bits. Any instance-specific object will get its class written automatically.
fileOutClass:andObject:blocking:
Write a file that has both the source code for the named class and an object as bits. Any instance-specific object will get its class written automatically. Accept a list of objects to map to nil or some other object (blockers). In addition to teh choices in each class's objectToStoreOnDataStream
hash
Answer a SmallInteger whose value is related to the receiver's identity.
May be overridden, and should be overridden in any classes that define =
isZipArchive
Determine if this appears to be a valid Zip archive
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..
next
Primitive. Return the next object in the Stream represented by the
receiver. Fail if the collection of this stream is not an Array or a String.
Fail if the stream is positioned at its end, or if the position is out of
bounds in the collection. Optional. See Object documentation
whatIsAPrimitive.
next:
Answer the next anInteger elements of my collection. overriden for efficiency
readStream
polymorphic with SequenceableCollection. Return self
RunArray
My instances provide space-efficient storage of data which tends to be constant over long runs of the possible indices. Essentially repeated values are stored singly and then associated with a "run" length that denotes the number of consecutive occurrences of the value.
My two important variables are
runs An array of how many elements are in each run
values An array of what the value is over those elements
The variables lastIndex, lastRun and lastOffset cache the last access
so that streaming through RunArrays is not an N-squared process.
Many complexities of access can be bypassed by using the method
RunArray withStartStopAndValueDo:
,
Answer a new RunArray that is a concatenation of the receiver and
aRunArray.
=
Test if all my elements are equal to those of otherArray
addFirst:
Add value as the first element of the receiver.
addLast:
Add value as the last element of the receiver.
addLast:times:
Add value as the last element of the receiver, the given number of times
at:
Primitive. Assumes receiver is indexable. Answer the value of an
indexable element in the receiver. Fail if the argument index is not an
Integer or is out of bounds. Essential. See Object documentation
whatIsAPrimitive.
at:put:
Set an element of the RunArray
at:setRunOffsetAndValue:
Supply all run information to aBlock.
coalesce
Try to combine adjacent runs
copyFrom:to:
Answer a copy of a subset of the receiver, starting from element at
index start until element at index stop.
copyReplaceFrom:to:with:
Answer a copy of the receiver satisfying the following conditions: If
stop is less than start, then this is an insertion; stop should be exactly
start-1, start = 1 means insert before the first character, start = size+1
means append after last character. Otherwise, this is a replacement; start
and stop have to be within the receiver's bounds.
first
Answer the first element of the receiver
isSelfEvaluating
last
Answer the last element of the receiver
mapValues:
NOTE: only meaningful to an entire set of runs
new
new:
new:withAll:
newFrom:
printOn:
Append a sequence of characters that identify the receiver to aStream.
rangeOf:startingAt:
Answer an interval that gives the range of attr at index position startPos. An empty interval with start value startPos is returned when the attribute attr is not present at position startPos. self size > 0 is assumed, it is the responsibility of the caller to test for emptiness of self.
Note that an attribute may span several adjancent runs.
readFrom:
repeatLast:ifEmpty:
add the last value back again, the given number of times. If we are empty, add (defaultBlock value)
repeatLastIfEmpty:
add the last value back again. If we are empty, add (defaultBlock value)
reversed
Answer a copy of the receiver with element order reversed.
runLengthAt:
Answer the length remaining in run beginning at index.
runs
runs:values:
runsAndValuesDo:
Evaluate aBlock with run lengths and values from the receiver
runsFrom:to:do:
Evaluate aBlock with all existing runs in the range from start to stop
scanFrom:
setRuns:setValues:
size
Answer how many elements the receiver contains.
storeOn:
Refer to the comment in Object|storeOn:.
values
Answer the values in the receiver.
withStartStopAndValueDo:
writeOn:
Store the array of bits onto the argument, aStream. (leading byte ~= 16r80) identifies this as raw bits (uncompressed). Always store in Big Endian (Mac) byte order. Do the writing at BitBlt speeds. We only intend this for non-pointer arrays. Do nothing if I contain pointers.
writeScanOn:
Write out the format used for text runs in source files. (14 50 312)f1,f1b,f1LInteger +;i
SequenceableCollection
I am an abstract superclass for collections that have a well-defined order associated with their elements. Thus each element is externally-named by integers referred to as indices.
,
Concatenate two Strings or Collections.
=
Answer true if the receiver is equivalent to the otherCollection.
First test for identity, then rule out different species and sizes of
collections. As a last resort, examine each element of the receiver
and the otherCollection.
@
after:
Answer the element after target. Raise an error if target is not
in the receiver, or if there are no elements after it.
after:ifAbsent:
Answer the element after target. Answer the result of evaluation
the exceptionBlock if target is not in the receiver, or if there are
no elements after it.
aggregateRuns:
Answer a new collection of the same species as the
receiver with elements being collections (of the receiver
species) containing those elements of the receiver
for which the given block consecutively evaluates to
the same object.
allButFirst
Answer a copy of the receiver containing all but the first
element. Raise an error if there are not enough elements.
allButFirst:
Answer a copy of the receiver containing all but the first n
elements. Raise an error if there are not enough elements.
allButFirstDo:
allButLast
Answer a copy of the receiver containing all but the last
element. Raise an error if there are not enough elements.
allButLast:
Answer a copy of the receiver containing all but the last n
elements. Raise an error if there are not enough elements.
allButLastDo:
anyOne
Answer a representative sample of the receiver. This method can
be helpful when needing to preinfer the nature of the contents of
semi-homogeneous collections.
appendTo:
double dispatch for join:
asArray
Answer an Array whose elements are the elements of the receiver.
asByteArray
Answer a ByteArray whose elements are the elements of the receiver.
asColorArray
asCubic
Convert this point array to a Cubic object
asDigitsAt:in:do:
(0 to: 1) asDigitsToPower: 4 do: [:each | Transcript cr; show: each printString]
asDigitsToPower:do:
Repeatedly value aBlock with a single Array. Adjust the collection
so that aBlock is presented all (self size raisedTo: anInteger) possible
combinations of the receiver's elements taken as digits of an anInteger long number.
asFloatArray
Answer a FloatArray whose elements are the elements of the receiver, in
the same order.
asIntegerArray
Answer an IntegerArray whose elements are the elements of the receiver, in
the same order.
asPointArray
Answer an PointArray whose elements are the elements of the receiver, in
the same order.
asStringWithCr
Convert to a string with returns between items. Elements are
usually strings.
Useful for labels for PopUpMenus.
asTraitComposition
For convenience the composition {T1. T2 ...} is the same as T1 + T2 + ...
asWordArray
Answer a WordArray whose elements are the elements of the receiver, in
the same order.
assertSlopesWith:from:to:
We trust everything has been checked.
The following assertions should hold at this point:
at:ifAbsent:
Answer the element at my position index. If I do not contain an element
at index, answer the result of evaluating the argument, exceptionBlock.
at:incrementBy:
atAll:
Answer a new collection like the receiver which contains all elements
of the receiver at the indices of indexArray.
atAll:put:
Put anObject at every index specified by the elements of aCollection.
atAll:putAll:
Store the elements of valueArray into the slots
of this collection selected by indexArray.
atAllPut:
Put anObject at every one of the receiver's indices.
atLast:
Return element at indexFromEnd from the last position.
atLast: 1, returns the last element
atLast:ifAbsent:
Return element at indexFromEnd from the last position.
atLast: 1 ifAbsent: [] returns the last element
atLast:put:
Set the element at indexFromEnd from the last position.
atLast: 1 put: obj, sets the last element
atPin:
Return the index'th element of me if possible.
Return the first or last element if index is out of bounds.
atRandom:
Answer a random element of the receiver. Uses aGenerator which
should be kept by the user in a variable and used every time. Use
this instead of #atRandom for better uniformity of random numbers
because only you use the generator. Causes an error if self has no
elements.
atWrap:
Answer the index'th element of the receiver. If index is out of bounds,
let it wrap around from the end to the beginning until it is in bounds.
atWrap:put:
Store value into the index'th element of the receiver. If index is out
of bounds, let it wrap around from the end to the beginning until it
is in bounds. Answer value.
before:
Answer the receiver's element immediately before target. Raise an
error if target is not an element of the receiver, or if there are no
elements before it (i.e. it is the first element).
before:ifAbsent:
Answer the receiver's element immediately before target. Answer
the result of evaluating the exceptionBlock if target is not an element
of the receiver, or if there are no elements before it.
beginsWith:
changeInSlopes:
A message to knots of a spline. Returns an array with the 3rd cubic coeff.
changeOfChangesInSlopes:
A message to knots of a spline. Returns an array with the 4rd
cubic coeff.
checkedAt:
closedCubicSlopes
Sent to knots returns the slopes of a closed cubic spline.
From the same set of java sources as naturalCubic. This is a squeak
transliteration of the java code.
closedCubicSlopes:
Sent to knots returns a copy of clampedSlopes with the values of the undefined (nil) slopes filled in.
closedFillinList
Answers a list of ranges between which values are undertermined.
Reciever is a list that combines known values and nil entries for
undetermined values.
Answer a list of ranges. Each range starts and ends with a known
value.
The range inbetween the known values are nil. The ranges start and
ends may overlap.
Each nil element in the list appears in exactly one range.
If the list starts or ends with nil the last range will wrap around to the
next known value. There may be only one known value in the list but
there must be atleast one know value.

(self allsatisfy: [ :e | e isNil ] ) ifTrue: [ self error: 'list must contain at
least one known value' ]
collect:
Evaluate aBlock with each of the receiver's elements as the argument.
Collect the resulting values into a collection like the receiver. Answer
the new collection.
collect:displayingProgress:
Evaluate aBlock with each of the receiver's elements as the argument.
Collect the resulting values into a collection like the receiver. Answer
the new collection.
collect:from:to:
Refer to the comment in Collection|collect:.
collectWithIndex:
Use the new version with consistent naming
combinations:atATimeDo:
Take the items in the receiver, kk at a time, and evaluate the block for each combination. Hand in an array of elements of self as the block argument. Each combination only occurs once, and order of the elements does not matter. There are (self size take: kk) combinations.
combinationsAt:in:after:do:
Choose k of N items and put in aCollection. jj-1 already chosen. Indexes of items are in numerical order, to avoid the same combo being used twice. In this slot, we are allowed to use items in self indexed by nn+1 to self size. nn is the index used for position jj-1.
concatenation
copyAfter:
Answer a copy of the receiver from after the first occurence
of anElement up to the end. If no such element exists, answer
an empty copy.
copyAfterLast:
Answer a copy of the receiver from after the last occurence
of anElement up to the end. If no such element exists, answer
an empty copy.
copyEmpty
copyFrom:to:
Answer a copy of a subset of the receiver, starting from element at
index start until element at index stop.
copyLast:
Deprecated. Use #last:
copyReplaceAll:with:
Default is not to do token matching.
See also String copyReplaceTokens:with:
copyReplaceAll:with:asTokens:
Answer a copy of the receiver in which all occurrences of
oldSubstring have been replaced by newSubstring.
ifTokens (valid for Strings only) specifies that the characters
surrounding the recplacement must not be alphanumeric.
Bruce Simth, must be incremented by 1 and not
newSubstring if ifTokens is true. See example below.
copyReplaceFrom:to:with:
Answer a copy of the receiver satisfying the following conditions: If
stop is less than start, then this is an insertion; stop should be exactly
start-1, start = 1 means insert before the first character, start = size+1
means append after last character. Otherwise, this is a replacement; start
and stop have to be within the receiver's bounds.
copyUpTo:
Answer all elements up to but not including anObject. If there
is no such object, answer a copy of the receiver.
copyUpToLast:
Answer a copy of the receiver from index 1 to the last occurrence of
anElement, not including anElement.
copyWith:
Answer a copy of the receiver that is 1 bigger than the receiver and has
newElement at the last element.
copyWithFirst:
Answer a copy of the receiver that is 1 bigger than the receiver with newElement as the first element.
copyWithoutFirst
Deprecatd. Return a copy of the receiver which doesn't include
the first element.
copyWithoutIndex:
Return a copy containing all elements except the index-th.
cubicPointPolynomialAt:
From curve information assemble a 4-array of points representing the coefficents for curve segment between to points. Beginning point is first point in array endpoint is the pointSum of the array. Meant to be sent to newcurves idea of curve coefficents.
customizeExplorerContents
do:
Refer to the comment in Collection|do:.
do:displayingProgress:
do:separatedBy:
Evaluate the elementBlock for all elements in the receiver,
and evaluate the separatorBlock between.
do:without:
Enumerate all elements in the receiver.
Execute aBlock for those elements that are not equal to the given item
doWithIndex:
Use the new version with consistent naming
eighth
Answer the eighth element of the receiver.
Raise an error if there are not enough elements.
endsWith:
errorFirstObject:
errorLastObject:
errorOutOfBounds
fifth
Answer the fifth element of the receiver.
Raise an error if there are not enough elements.
findBinary:
Search for an element in the receiver using binary search.
The argument aBlock is a one-element block returning
0 - if the element is the one searched for
<0 - if the search should continue in the first half
>0 - if the search should continue in the second half
If no matching element is found, raise an error.
Examples:
#(1 3 5 7 11 15 23) findBinary:[:arg| 11 - arg]
findBinary:ifNone:
Search for an element in the receiver using binary search.
The argument aBlock is a one-element block returning
0 - if the element is the one searched for
<0 - if the search should continue in the first half
>0 - if the search should continue in the second half
If no matching element is found, evaluate exceptionBlock.
findBinaryIndex:
Search for an element in the receiver using binary search.
The argument aBlock is a one-element block returning
0 - if the element is the one searched for
<0 - if the search should continue in the first half
>0 - if the search should continue in the second half
If no matching element is found, raise an error.
Examples:
#(1 3 5 7 11 15 23) findBinaryIndex:[:arg| 11 - arg]
findBinaryIndex:ifNone:
Search for an element in the receiver using binary search.
The argument aBlock is a one-element block returning
0 - if the element is the one searched for
<0 - if the search should continue in the first half
>0 - if the search should continue in the second half
If no matching element is found, evaluate exceptionBlock.
findFirst:
Return the index of my first element for which aBlock evaluates as true.
findLast:
Return the index of my last element for which aBlock evaluates as true.
first
Answer the first element of the receiver
first:
Answer the first n elements of the receiver.
Raise an error if there are not enough elements.
flipRotated:
Answer a copy of the receiver with element order indicated by
flipIndex.
forceTo:paddingStartWith:
Force the length of the collection to length, padding
the beginning of the result if necessary with elem.
Note that this makes a copy.
forceTo:paddingWith:
Force the length of the collection to length, padding
if necessary with elem. Note that this makes a copy.
fourth
Answer the fourth element of the receiver.
Raise an error if there are not enough elements.
from:to:do:
Evaluate aBlock for all elements between start and stop (inclusive).
from:to:put:
Put anObject in all indexes between startIndex
and endIndex. Very fast. Faster than to:do: for
more than 26 positions. Answer anObject
groupsOf:atATimeCollect:
Evaluate aBlock with my elements taken n at a time. Ignore any
leftovers at the end.
Allows use of a flattened
array for things that naturally group into groups of n.
If aBlock has a single argument, pass it an array of n items,
otherwise, pass the items as separate arguments.
See also pairsDo:
groupsOf:atATimeDo:
Evaluate aBlock with my elements taken n at a time. Ignore any leftovers at the end.
Allows use of a flattened
array for things that naturally group into groups of n.
If aBlock has a single argument, pass it an array of n items,
otherwise, pass the items as separate arguments.
See also pairsDo:
growSizeGuaranteeing:
grownBy:
Answer a copy of receiver collection with size grown by length
hasEqualElements:
Answer whether the receiver's size is the same as otherCollection's
size, and each of the receiver's elements equal the corresponding
element of otherCollection.
This should probably replace the current definition of #= .
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
identityIndexOf:
Answer the index of anElement within the receiver. If the receiver does
not contain anElement, answer 0.
identityIndexOf:ifAbsent:
Answer the index of anElement within the receiver. If the receiver does
not contain anElement, answer the result of evaluating the argument,
exceptionBlock.
includes:
Answer whether anObject is one of the receiver's elements.
indexOf:
Answer the index of the first occurence of anElement within the
receiver. If the receiver does not contain anElement, answer 0.
indexOf:ifAbsent:
Answer the index of the first occurence of anElement within the
receiver. If the receiver does not contain anElement, answer the
result of evaluating the argument, exceptionBlock.
indexOf:startingAt:ifAbsent:
Answer the index of the first occurence of anElement after start
within the receiver. If the receiver does not contain anElement,
answer the result of evaluating the argument, exceptionBlock.
indexOfSubCollection:startingAt:
Answer the index of the receiver's first element, such that that element
equals the first element of aSubCollection, and the next elements equal
the rest of the elements of aSubCollection. Begin the search at element
anIndex of the receiver. If no such match is found, answer 0.
indexOfSubCollection:startingAt:ifAbsent:
Answer the index of the receiver's first element, such that that element
equals the first element of sub, and the next elements equal
the rest of the elements of sub. Begin the search at element
start of the receiver. If no such match is found, answer the result of
evaluating argument, exceptionBlock.
insertInto:from:to:
integerAt:
Return the integer at the given index
integerAt:put:
Return the integer at the given index
isSequenceable
join:
NB: this implementation only works for Array, since WriteStreams only work for Arrays and Strings. (!)
Overridden in OrderedCollection and SortedCollection.
joinTo:
double dispatch for join:
joinUsing:
joiner - character, string or sequenceable collection
returns collection of the same collection class as 'joiner', or a String
joinUsing:last:
#(1 2 3 4) joinUsing: ', ' last: 'and'. => '1, 2, 3 and 4
keysAndValuesDo:
Enumerate the receiver with all the keys (aka indices) and values.
last
Answer the last element of the receiver
last:
Answer the last n elements of the receiver.
Raise an error if there are not enough elements.
lastIndexOf:
Answer the index of the last occurence of anElement within the
receiver. If the receiver does not contain anElement, answer 0.
lastIndexOf:ifAbsent:
Answer the index of the last occurence of anElement within the
receiver. If the receiver does not contain anElement, answer the
result of evaluating the argument, exceptionBlock.
lastIndexOf:startingAt:ifAbsent:
Answer the index of the last occurence of anElement within the
receiver. If the receiver does not contain anElement, answer the
result of evaluating the argument, exceptionBlock.
makeRoomFor:
middle
Answer the middle element of the receiver.
naturalCubicSlopes
Sent to knots returns the slopes of a natural cubic curve fit.
This is a direct squeak
transliteration of the java code.
naturalCubicSlopes:
Sent to knots returns a copy of clampedSlopes with the values of the undefined (nil) slopes filled in.
naturalFillinList
Return a list of fillin ranges to be used to calculate natural or clamped slopes.
Note that this list is slightly different in mission from the closedFillinList
nextToLast
niDescription
nilTransitions
Return an OrderedCollection of transition indexes.
Indexes represent where the list elements transitions
from nil to nonNil
or from nonNil to nil.
1 is an index in the list iff the first element is nonNil.
ninth
Answer the ninth element of the receiver.
Raise an error if there are not enough elements.
nsReadStream
nsReadStreamClass
nsStreamContents:
nsWriteStream
nsWriteStreamClass
overlappingPairsCollect:
Answer the result of evaluating aBlock with all of the overlapping pairs of my elements.
overlappingPairsDo:
Emit overlapping pairs of my elements into aBlock
overlappingPairsWithIndexDo:
Emit overlapping pairs of my elements into aBlock, along with an index.
paddedWith:do:
Evaluate twoArgBlock with corresponding elements from this collection and otherCollection.
Missing elements from either will be passed as nil.
pairsCollect:
Evaluate aBlock with my elements taken two at a time, and return an Array with the results
pairsDo:
Evaluate aBlock with my elements taken two at a time. If there's an odd number of items, ignore the last one. Allows use of a flattened array for things that naturally group into pairs. See also pairsCollect:
permutationsDo:
Repeatly value aBlock with a single copy of the receiver. Reorder the copy
so that aBlock is presented all (self size factorial) possible permutations.
permutationsStartingAt:do:
#(1 2 3 4) permutationsDo: [:each | Transcript cr; show: each printString]
polynomialEval:
Treat myself as the coeficients of a polynomial in X. Evaluate it with thisX. First element is the constant and last is the coeficient for the highest power.
putOn:
readStream
remove:ifAbsent:
SequencableCollections cannot implement removing.
replaceAll:with:
Replace all occurences of oldObject with newObject
replaceFrom:to:with:
This destructively replaces elements from start to stop in the receiver.
Answer the receiver itself. Use copyReplaceFrom:to:with: for
insertion/deletion which may alter the size of the result.
replaceFrom:to:with:startingAt:
This destructively replaces elements from start to stop in the receiver
starting at index, repStart, in the sequenceable collection,
replacementCollection. Answer the receiver. No range checks are
performed.
reverse
reverseDo:
Evaluate aBlock with each of the receiver's elements as the argument,
starting with the last element and taking each in sequence up to the
first. For SequenceableCollections, this is the reverse of the enumeration
for do:.
reverseWith:do:
Evaluate aBlock with each of the receiver's elements, in reverse order,
along with the
corresponding element, also in reverse order, from
aSequencableCollection.
reversed
Answer a copy of the receiver with element order reversed.
second
Answer the second element of the receiver.
Raise an error if there are not enough elements.
segmentedSlopes
For a collection of floats. Returns the slopes for straight
segments between vertices.
select:
Refer to the comment in Collection|select:.
seventh
Answer the seventh element of the receiver.
Raise an error if there are not enough elements.
shallowCopy
Answer a copy of the receiver which shares the receiver's instance variables.
shuffled
shuffledBy:
sixth
Answer the sixth element of the receiver.
Raise an error if there are not enough elements.
slopesWith:from:to:
Sent to modifiable list of slopes. Fills in the slope values between start
and end. Start and end slopes can be either clamped or nil.
If nil the natural slope for that value will be filled in.
We expect that the parameters meets the assertions in
self assertSlopesWith: knots from: start to: end.
sortBy:
Create a copy that is sorted. Sort criteria is the block that accepts two arguments.
When the block is true, the first arg goes first ([:a :b | a > b] sorts in descending
order).
split:
splitOn:
splitter - can be a subsequence, a Block or a Regex (String receiver only).
Any other object used as a splitter is treated as an Array containing that object.
startsWith:
streamContents:
streamContents:limitedTo:
swap:with:
Move the element at oneIndex to anotherIndex, and vice-versa.
third
Answer the third element of the receiver.
Raise an error if there are not enough elements.
transitions
Sent to a list of boolean values.
Return an OrderedCollection of transition indexes.
Indexes represent where the list elements transitions
from true to false
or from false to true.
1 is an index in the list iff the first element is false.
transitions:
Sent to a list. Select block returns a boolean
Return an OrderedCollection of transition indexes.
Indexes represent where the list elements transitions
from true to false
or from false to true.
1 is an index in the list iff the first element tests false.
upTo:
with:collect:
Collect and return the result of evaluating twoArgBlock with corresponding elements from this collection and otherCollection.
with:do:
Evaluate twoArgBlock with corresponding elements from this collection and otherCollection.
withIndexCollect:
Just like with:collect: except that the iteration index supplies the second argument to the block.
withIndexCollect:displayingProgress:
Just like with:collect: except that the iteration index supplies the second argument to the block.
withIndexDo:
Just like with:do: except that the iteration index supplies the second argument to the block.
writeAllElementsOf:startingAt:
Asserts receiver is big enough
writeStream
Set
I represent a set of objects without duplicates. I can hold anything that responds to
#hash and #=, except for nil. My instances will automatically grow, if necessary,
Note that I rely on #=, not #==. If you want a set using #==, use IdentitySet.
Instance structure:
array An array whose non-nil elements are the elements of the set,
and whose nil elements are empty slots. There is always at least one nil.
In fact I try to keep my "load" at 75% or less so that hashing will work well.
tally The number of elements in the set. The array size is always greater than this.
The core operation is #findElementOrNil:, which either finds the position where an
object is stored in array, if it is present, or finds a suitable position holding nil, if
its argument is not present in array,
=
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, but only if
not already present. Answer newObject.
add:withOccurrences:
Add newObject anInteger times to the receiver. Answer newObject.
array
asSet
Answer a Set whose elements are the unique elements of the receiver.
atNewIndex:put:
atRandom:
Answer a random element of the receiver. Uses aGenerator which
    should be kept by the user in a variable and used every time. Use
    this instead of #atRandom for better uniformity of random numbers because
only you use the generator. Causes an error if self has no elements.
capacity
Answer the current capacity of the receiver.
collect:
Evaluate aBlock with each of the receiver's elements as the argument.
Collect the resulting values into a collection like the receiver. Answer
the new collection.
collect:displayingProgress:
Evaluate aBlock with each of the receiver's elements as the argument.
Collect the resulting values into a collection like the receiver. Answer
the new collection.
comeFullyUpOnReload:
Symbols have new hashes in this image.
copy
Answer another instance just like the receiver. Subclasses typically override postCopy; they typically do not override shallowCopy.
copyEmpty
Answer an empty copy of this collection
copyWithout:
Answer a copy of the receiver that does not contain any
elements equal to oldElement.
do:
Evaluate aBlock with each of the receiver's elements as the argument.
doWithIndex:
Support Set enumeration with a counter, even though not ordered
findElementOrNil:
Answer the index of a first slot containing either a nil (indicating an empty slot) or an element that matches the given object. Answer the index of that slot or zero. Fail if neither a match nor an empty slot is found.
fixCollisionsFrom:
The element at index has been removed and replaced by nil.
This method moves forward from there, relocating any entries
that had been placed below due to collisions with this one
fullCheck
Keep array at least 1/4 free for decent hash behavior
grow
Grow the elements array and reinsert the old elements
growSize
hasContentsInExplorer
includes:
Answer whether anObject is one of the receiver's elements.
initialize:
Initialize array to an array size of n
inspectorClass
Answer the class of the inspector to be used on the receiver. Called by inspect;
use basicInspect to get a normal (less useful) type of inspector.
keyAt:
May be overridden by subclasses so that fixCollisions will work
like:
Answer an object in the receiver that is equal to anObject,
nil if no such object is found. Relies heavily on hash properties
new
new:
newFrom:
niActions
niAddNewEntry
niChildrenBlockForIndexedFields
niDescription
noCheckAdd:
occurrencesOf:
Answer how many of the receiver's elements are equal to anObject.
quickRehashAllSets
rehash
Do nothing. Here so sending this to a Set does not have to do a time consuming respondsTo:
rehashAllSets
remove:ifAbsent:
Remove oldObject from the receiver's elements. If several of the
elements are equal to oldObject, only one is removed. If no element is
equal to oldObject, answer the result of evaluating anExceptionBlock.
Otherwise, answer the argument, oldObject. ArrayedCollections cannot
respond to this message.
removeAll
remove all elements from this collection.
Preserve the capacity
restoreFromSnapshot:
scanFor:
Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or zero if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements.
select:
Use copyEmpty instead of self species new to give subclasses a chance to initialize additional inst vars.
size
Answer how many elements the receiver contains.
sizeFor:
snapshotCopy
someElement
Deprecated. Use anyOne.
swap:with:
May be overridden by subclasses so that fixCollisions will work
union:
Answer the set theoretic union of the receiver and aCollection, using the receiver's notion of equality and not side effecting the receiver at all.
withArray:
private -- for use only in copy
SharedQueue
I provide synchronized communication of arbitrary objects between Processes. An object is sent by sending the message nextPut: and received by sending the message next. If no object has been sent when a next message is sent, the Process requesting the object will be suspended until one is sent.
findFirst:
Answer the next object that satisfies aBlock, skipping any intermediate objects.
If no object is found, answer <nil>.
NOTA BENE: aBlock MUST NOT contain a non-local return (^).
flush
Throw out all pending contents
flushAllSuchThat:
Remove from the queue all objects that satisfy aBlock.
initialize:
isEmpty
Answer whether any objects have been sent through the receiver and
not yet received by anyone.
makeRoomAtEnd
new
new:
next
Answer the object that was sent through the receiver first and has not
yet been received by anyone. If no object has been sent, suspend the
requesting process until one is.
nextOrNil
Answer the object that was sent through the receiver first and has not
yet been received by anyone. If no object has been sent, answer <nil>.
nextOrNilSuchThat:
Answer the next object that satisfies aBlock, skipping any intermediate objects.
If no object has been sent, answer <nil> and leave me intact.
NOTA BENE: aBlock MUST NOT contain a non-local return (^).
nextPut:
Send value through the receiver. If a Process has been suspended
waiting to receive a value through the receiver, allow it to proceed.
peek
Answer the object that was sent through the receiver first and has not
yet been received by anyone but do not remove it from the receiver. If
no object has been sent, return nil
size
Answer the number of objects that have been sent through the
receiver and not yet received by anyone.
SharedQueue2
An implementation of a shared queue based on class Monitor. Clients may may place items on the queue using nextPut: or remove them using methods like next or nextOrNil. Items are removed in first-in first-out (FIFO) order. It is safe for multiple threads to access the same shared queue, which is why this is a "shared" queue.
[monitor] is used to synchronize access from multiple threads.
[items] is an ordered collection holding the items that are in the queue. New items are added at the end, and old items are removed from the beginning.
All methods must hold the monitor while they run.
findFirst:
Answer the next object that satisfies aBlock, skipping any intermediate objects.
If no such object has been queued, answer <nil> and leave me intact.
flush
Remove from the queue all objects
flushAllSuchThat:
Remove from the queue all objects that satisfy aBlock.
initialize
Subclasses should redefine this method to perform initializations on instance creation
isEmpty
new
next
Answer the next object accessible by the receiver.
nextOrNil
nextOrNilSuchThat:
Answer the next object that satisfies aBlock, skipping any intermediate objects.
If no object has been sent, answer <nil> and leave me intact.
NOTA BENE: aBlock MUST NOT contain a non-local return (^).
nextPut:
Insert the argument, anObject, as the next object accessible by the
receiver. Answer anObject.
peek
Answer the object that was sent through the receiver first and has not
yet been received by anyone but do not remove it from the receiver. If
no object has been sent, return nil
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
size
Primitive. Answer the number of indexable variables in the receiver.
This value is the same as the largest legal subscript. Essential. See Object
documentation whatIsAPrimitive.
SmallDictionary
RBSmallDictionary is a special dictionary optimized for small collections. In addition to the normal dictionary protocol, it also supports an #empty message which "empties" the collection but may hang on to the original elements (so it could collect garbage). Without #empty we would either need to create a new dictionary or explicitly remove everything from the dictionary. Both of these take more time and #empty.
Instance Variables:
keys <Array of: Object> array of keys (we don't use Associations for our key value pairs)
size <Integer> the size of the dictionary
values <Array of: Object> array of our values
=
Two dictionaries are equal if
(a) they are the same 'kind' of thing.
(b) they have the same set of keys.
(c) for each (common) key, they have the same value
add:
Include newObject as one of the receiver's elements. Answer newObject.
ArrayedCollections cannot respond to this message.
addAll:
Include all the elements of aCollection as the receiver's elements. Answer
aCollection. Actually, any object responding to #do: can be used as argument.
associationAt:
associationAt:ifAbsent:
Answer the association with the given key.
If key is not found, return the result of evaluating aBlock.
associationDeclareAt:
Return an existing association, or create and return a new one. Needed as a single message by ImageSegment.prepareToBeSaved.
associations
Answer a Collection containing the receiver's associations.
associationsDo:
Evaluate aBlock for each of the receiver's elements (key/value
associations). If any non-association is within, the error is not caught now,
but later, when a key or value message is sent to it.
associationsSelect:
Evaluate aBlock with each of my associations as the argument. Collect
into a new dictionary, only those associations for which aBlock evaluates
to true.
at:
Answer the value associated with the key.
at:ifAbsent:
Answer the value associated with the key or, if key isn't found,
answer the result of evaluating aBlock.
at:ifAbsentPut:
Return the value at the given key.
If key is not included in the receiver store the result
of evaluating aBlock as new value.
at:ifPresent:
Lookup the given key in the receiver. If it is present, answer the value of evaluating the given block with the value associated with the key. Otherwise, answer nil.
at:ifPresentAndInMemory:
Lookup the given key in the receiver. If it is present, answer the value of evaluating the given block with the value associated with the key. Otherwise, answer nil.
at:put:
Set the value at key to be anObject. If key is not found, create a
new entry for key and set is value to anObject. Answer anObject.
capacity
Answer the current capacity of the receiver.
collect:
Evaluate aBlock with each of my values as the argument. Collect the
resulting values into a collection that is like me. Answer with the new
collection.
copy
Answer another instance just like the receiver. Subclasses typically override postCopy; they typically do not override shallowCopy.
customizeExplorerContents
declare:from:
Add key to the receiver. If key already exists, do nothing. If aDictionary
includes key, then remove it from aDictionary and use its association as
the element of the receiver.
do:
Evaluate aBlock with each of the receiver's elements as the argument.
empty
errorKeyNotFound
errorValueNotFound
explorerContentsWithIndexCollect:
findIndexForKey:
flattenOnStream:
seems to not be the best solution to do that.
Imagine if the class Stream should have a method #writeSomething for each object existing in Pharo.
Objects themeself have the information on how to be print . Not the stream.
growKeysAndValues
growTo:
hasBindingThatBeginsWith:
Answer true if the receiver has a key that begins with aString, false otherwise
includes:
Answer whether anObject is one of the receiver's elements.
includesAssociation:
includesIdentity:
Answer whether aValue is one of the values of the receiver. Contrast #includes: in which there is only an equality check, here there is an identity check
includesKey:
Answer whether the receiver has a key equal to the argument, key.
initialize
Subclasses should redefine this method to perform initializations on instance creation
isDictionary
keyAtIdentityValue:
Answer the key that is the external name for the argument, value. If
there is none, answer nil.
Note: There can be multiple keys with the same value. Only one is returned.
keyAtIdentityValue:ifAbsent:
Answer the key that is the external name for the argument, value. If
there is none, answer the result of evaluating exceptionBlock.
Note: There can be multiple keys with the same value. Only one is returned.
keyAtValue:
Answer the key that is the external name for the argument, value. If
there is none, answer nil.
keyAtValue:ifAbsent:
Answer the key that is the external name for the argument, value. If
there is none, answer the result of evaluating exceptionBlock.
: Use =, not ==, so stings like 'this' can be found. Note that MethodDictionary continues to use == so it will be fast.
keyForIdentity:
If aValue is one of the values of the receive, return its key, else return nil. Contrast #keyAtValue: in which there is only an equality check, here there is an identity check
keys
Answer a Set containing the receiver's keys.
keysAndValuesDo:
keysAndValuesRemove:
Removes all entries for which keyValueBlock returns true.
keysDo:
keysSortedSafely
Answer a SortedCollection containing the receiver's keys.
new
new:
occurrencesOf:
Answer how many of the receiver's elements are equal to anObject.
postCopy
self is a shallow copy, subclasses should copy fields as necessary to complete the full copy
printElementsOn:
The original code used #skip:, but some streams do not support that,
and we don't really need it.
privateAt:put:
rehash
we don't use hashing, nothing to be done
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.
remove:ifAbsent:
Remove oldObject from the receiver's elements. If several of the
elements are equal to oldObject, only one is removed. If no element is
equal to oldObject, answer the result of evaluating anExceptionBlock.
Otherwise, answer the argument, oldObject. ArrayedCollections cannot
respond to this message.
removeKey:
Remove key from the receiver.
If key is not in the receiver, notify an error.
removeKey:ifAbsent:
Remove key (and its associated value) from the receiver. If key is not in
the receiver, answer the result of evaluating aBlock. Otherwise, answer
the value externally named by key.
removeUnreferencedKeys
Undeclared removeUnreferencedKeys
scanFor:
Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or zero if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements.
select:
Evaluate aBlock with each of my values as the argument. Collect into a
new dictionary, only those associations for which aBlock evaluates to
true.
size
Answer how many elements the receiver contains.
storeOn:
Refer to the comment in Object|storeOn:.
unreferencedKeys
TextConstants unreferencedKeys
values
Answer a Collection containing the receiver's values.
valuesDo:
Evaluate aBlock for each of the receiver's values.
SmallIdentityDictionary
I'm a SmallDictionary (this means faster than default one when dealing with limited number of items)
but I check my key based on identity.
findIndexForKey:
SortedCollection
I represent a collection of objects ordered by some property of the objects themselves. The ordering is specified in a BlockContext.
=
Answer true if my and aSortedCollection's species are the same,
and if our blocks are the same, and if our elements are the same.
add:
Include newObject as one of the receiver's elements. Answer newObject.
ArrayedCollections cannot respond to this message.
addAll:
Add each element of aCollection at my end. Answer aCollection.
addFirst:
Add newObject to the beginning of the receiver. Answer newObject.
at:put:
Put anObject at element index anInteger. at:put: cannot be used to
append, front or back, to an ordered collection; it is used by a
knowledgeable client to replace an element.
collect:
Evaluate aBlock with each of my elements as the argument. Collect the
resulting values into an OrderedCollection. Answer the new collection.
Override the superclass in order to produce an OrderedCollection instead
of a SortedCollection.
collect:displayingProgress:
Evaluate aBlock with each of my elements as the argument. Collect the
resulting values into an OrderedCollection. Answer the new collection.
Override the superclass in order to produce an OrderedCollection instead
of a SortedCollection.
copy
Answer another instance just like the receiver. Subclasses typically override postCopy; they typically do not override shallowCopy.
copyEmpty
Answer a copy of the receiver without any of the receiver's elements.
defaultSort:to:
Sort elements i through j of self to be nondescending according to
sortBlock.
indexForInserting:
insert:before:
spot is an index in the range firstIndex .. lastIndex, such an index is not known from outside the collection.
Never use this method in your code, it is meant for private use by OrderedCollection only.
The methods for use are:
#add:before: to insert an object before another object
#add:beforeIndex: to insert an object before a given position.
join:
Curiously addAllLast: does not trigger a reSort, so we must do it here.
median
Return the middle element, or as close as we can get.
new:
reSort
sort:to:
Sort elements i through j of self to be nondescending according to
sortBlock.
sortBlock
Answer the blockContext which is the criterion for sorting elements of
the receiver.
sortBlock:
Make the argument, aBlock, be the criterion for ordering elements of the
receiver.
SparseLargeTable
Derivated from Stephan Pair's LargeArray, but to hold a sparse table, in which most of the entries are the same default value, it uses some tricks.
allDefaultValueSubtableAt:
analyzeSpaceSaving
arrayClass
at:
Primitive. Assumes receiver is indexable. Answer the value of an
indexable element in the receiver. Fail if the argument index is not an
Integer or is out of bounds. Essential. See Object documentation
whatIsAPrimitive.
at:put:
Primitive. Assumes receiver is indexable. Store the argument value in
the indexable element of the receiver indicated by index. Fail if the
index is not an Integer or is out of bounds. Or fail if the value is not of
the right type for this kind of collection. Answer the value that was
stored. Essential. See Object documentation whatIsAPrimitive.
base
chunkSize
copyEmpty
Answer a copy of the receiver that contains no elements.
defaultChunkSize
defaultChunkSizeForFiles
findLastNonNilSubTable
initChunkSize:size:arrayClass:base:defaultValue:
new:
new:chunkSize:
new:chunkSize:arrayClass:
new:chunkSize:arrayClass:base:
new:chunkSize:arrayClass:base:defaultValue:
noCheckAt:
noCheckAt:put:
printElementsOn:
The original code used #skip:, but some streams do not support that,
and we don't really need it.
printOn:
Append a sequence of characters that identify the receiver to aStream.
privateSize:
pvtCheckIndex:
similarInstance
similarInstance:
similarSpeciesInstance
similarSpeciesInstance:
size
Answer how many elements the receiver contains.
speciesNew
speciesNew:
storeOn:
Refer to the comment in Object|storeOn:.
zapDefaultOnlyEntries
Stack
I implement a simple Stack. #push: adds a new object of any kind on top of the stack. #pop returns the first element and remove it from the stack. #top answer the first element of the stack without removing it.
errorEmptyStack
ifEmpty:ifNotEmpty:
Evaluate emptyBlock if I'm empty, notEmptyBlock otherwise
ifEmpty:ifNotEmptyDo:
Evaluate emptyBlock if I'm empty, notEmptyBlock otherwise
ifNotEmpty:
Evaluate the given block unless the receiver is empty.
If the block has an argument, eval with the receiver as its argument,
but it might be better to use ifNotEmptyDo: to make the code easier to
understand
ifNotEmptyDo:
Evaluate the given block with the receiver as its argument.
ifNotEmptyDo:ifEmpty:
Evaluate emptyBlock if I'm empty, notEmptyBlock otherwise
Evaluate the notEmptyBlock with the receiver as its argument
initialize
Subclasses should redefine this method to perform initializations on instance creation
isEmpty
isEmptyOrNil
Answer whether the receiver contains any elements, or is nil. Useful in numerous situations where one wishes the same reaction to an empty collection or to nil
linkedList
The stack is implemented with a LinkedList. Do NOT call this function, it
is for private use !
notEmptyCheck
Ensure the stack is not empty.
pop
Returns the first element and remove it from the stack.
push:
Adds a new object of any kind on top of the stack.
size
How many objects in me ?
top
Answer the first element of the stack without removing it.
I implement an element of a stack. I'm a container for any type of object, saved into the 'element' variable. My superclass Link allows me to be part of a LinkedList.
element
element:
Any kind of Object.
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
with:
Stream
I am an abstract class that represents an accessor for a sequence of objects. This sequence is referred to as my "contents".
<<
arguments:
asHttpResponseTo:
atEnd
Answer whether the receiver can access any more objects.
basicNext
basicNextPut:
basicNextPutAll:
binary
do nothing
close
Presumably sets the status of the receiver to be closed. This message does
nothing at this level, but is included for FileStream compatibility.
closed
contents
Answer all of the contents of the receiver.
do:
Evaluate aBlock for each of the objects accessible by receiver.
flush
Do nothing by default
isMessageStream
isStream
Return true if the receiver responds to the stream protocol
isTranscriptStream
isTypeHTTP
javascript:
localName
new
next
Answer the next object accessible by the receiver.
next:
Answer the next anInteger number of objects accessible by the receiver.
next:put:
Make anObject be the next anInteger number of objects accessible by the
receiver. Answer anObject.
nextMatchAll:
Answer true if next N objects are the ones in aColl,
else false. Advance stream of true, leave as was if false.
nextMatchFor:
Gobble the next object and answer whether it is equal to the argument,
anObject.
nextPut:
Insert the argument, anObject, as the next object accessible by the
receiver. Answer anObject.
nextPutAll:
Append the elements of aCollection to the sequence of objects accessible
by the receiver. Answer aCollection.
nextWordsPutAll:
Write the argument a word-like object in big endian format on the receiver.
May be used to write other than plain word-like objects (such as ColorArray).
openReadOnly
print:
Have anObject print itself on the receiver.
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
readOnly
sleep
an FTP-based stream might close the connection here
upToEnd
answer the remaining elements in the string
write:
String
A String is an indexed collection of Characters. Class String provides the abstract super class for ByteString (that represents an array of 8-bit Characters) and WideString (that represents an array of 32-bit characters). In the similar manner of LargeInteger and SmallInteger, those subclasses are chosen accordingly for a string; namely as long as the system can figure out so, the String is used to represent the given string.
Strings support a vast array of useful methods, which can best be learned by browsing and trying out examples as you find them in the code.
Here are a few useful methods to look at...
String match:
String contractTo:
String also inherits many useful methods from its hierarchy, such as
SequenceableCollection ,
SequenceableCollection copyReplaceAll:with:
*
+
-
/
//
<
Answer whether the receiver sorts before aString.
The collation order is simple ascii (with case differences).
<=
Answer whether the receiver sorts before or equal to aString.
The collation order is simple ascii (with case differences).
=
Answer whether the receiver sorts equally as aString.
The collation order is simple ascii (with case differences).
>
Answer whether the receiver sorts after aString.
The collation order is simple ascii (with case differences).
>=
Answer whether the receiver sorts after or equal to aString.
The collation order is simple ascii (with case differences).
\\
adaptToCollection:andSend:
If I am involved in arithmetic with a collection, convert me to a number.
adaptToNumber:andSend:
If I am involved in arithmetic with a number, convert me to a number.
adaptToPoint:andSend:
If I am involved in arithmetic with a point, convert me to a number.
adaptToString:andSend:
If I am involved in arithmetic with a string, convert us both to
numbers, and return the printString of the result.
addToMetacelloPackages:
addToMetacelloRepositories:
alike:
Answer some indication of how alike the receiver is to the argument, 0 is no match, twice aString size is best score. Case is ignored.
allRangesOfRegexMatches:
allRegexMatches:
applyLanguageInfomation:
asAlphaNumeric:extraChars:mergeUID:
Generates a String with unique identifier ( UID ) qualities, the difference to a
UUID is that its beginning is derived from the receiver, so that it has a meaning
for a human reader.
Answers a String of totalSize, which consists of 3 parts
1.part: the beginning of the receiver only consisting of
a-z, A-Z, 0-9 and extraChars in Collection additionallyAllowed ( which can be nil )
2.part: a single _
3.part: a ( random ) UID of size >= minimalSizeOfRandomPart consisting of
a-z, A-Z, 0-9
Starting letters are capitalized.
TotalSize must be at least 1.
Exactly 1 occurrence of $_ is guaranteed ( unless additionallyAllowed includes $_ ).
The random part has even for small sizes good UID qualitites for many practical purposes.
If only lower- or uppercase letters are demanded, simply convert the answer with
say #asLowercase. The probability of a duplicate will rise only moderately ( see below ).
Example:
size of random part = 10
in n generated UIDs the chance p of having non-unique UIDs is
n = 10000 -> p < 1e-10 if answer is reduced to lowerCase: p < 1.4 e-8
n = 100000 -> p < 1e-8
at the bottom is a snippet for your own calculations
Note: the calculated propabilites are theoretical,
for the actually used random generator they may be much worse
asByteArray
Convert to a ByteArray with the ascii values of the string.
asByteString
Convert the receiver into a ByteString
asCapitalizedPhrase
asCharacter
Answer the receiver's first character, or a * if none. Idiosyncratic, provisional.
asDate
Many allowed forms, see Date>>#readFrom:
asDateAndTime
Convert from UTC format
asDefaultDecodedString
asDisplayText
Answer a DisplayText whose text string is the receiver.
asDuration
convert from [nnnd]hh:mm:ss[.nanos] format. [] implies optional elements
asFileName
Answer a String made up from the receiver that is an acceptable file
name.
asFourCode
asFunction:
asHex
asHttpResponseTo:
asIRCLowercase
Answer a String made up from the receiver whose characters are all
lowercase, where 'lowercase' is by IRC's definition
asIdentifier:
Return a legal identifier, with first character in upper case if shouldBeCapitalized is true, else lower case. This will always return a legal identifier, even for an empty string
asInteger
asIpByteArray
asLegalSelector
asLowercase
Answer a String made up from the receiver whose characters are all
lowercase.
asMIMEDocument
asMIMEDocumentType:
asMIMEType
asMetacelloVersionNumber
asMorph
Answer the receiver as a StringMorph
asNumber
Answer the Number created by interpreting the receiver as the string
representation of a number.
asOctetString
Convert the receiver into an octet string
asPacked
Convert to a longinteger that describes the string
asParagraph
Answer a Paragraph whose text string is the receiver.
asPluralBasedOn:
Append an 's' to this string based on whether aNumberOrCollection is 1 or of size 1.
asRegex
Compile the receiver as a regex matcher. May raise RxParser>>syntaxErrorSignal
or RxParser>>compilationErrorSignal.
This is a part of the Regular Expression Matcher package, (c) 1996, 1999 Vassili Bykov.
Refer to `documentation' protocol of RxParser class for details.
asRegexIgnoringCase
Compile the receiver as a regex matcher. May raise RxParser>>syntaxErrorSignal
or RxParser>>compilationErrorSignal.
This is a part of the Regular Expression Matcher package, (c) 1996, 1999 Vassili Bykov.
Refer to `documentation' protocol of RxParser class for details.
asRepository
asSignedInteger
Returns the first signed integer it can find or nil.
asSmalltalkComment
return this string, munged so that it can be treated as a comment in Smalltalk code. Quote marks are added to the beginning and end of the string, and whenever a solitary quote mark appears within the string, it is doubled
asSqueakPathName
asString
Answer this string.
asStringMorph
Answer the receiver as a StringMorph
asStringOrText
Answer this string.
asSymbol
Answer the unique Symbol whose characters are the characters of the
string.
asText
Answer a Text whose string is the receiver.
asTime
Many allowed forms, see Time>>readFrom:
asTimeStamp
Convert from obsolete TimeStamp format
asURI
convert to a Url
asURIForceEncoding
convert to a Url after we do the HTTP string safe encoding
asUnsignedInteger
Returns the first integer it can find or nil.
asUppercase
Answer a String made up from the receiver whose characters are all
uppercase.
asUrl
convert to a Url
asUrlRelativeTo:
asVmPathName
asWideString
base64Decoded
Decode the receiver from base 64
base64Encoded
Encode the receiver as base64
basicType
Answer a symbol representing the inherent type of the receiver
beginsWithEmpty:caseSensitive:
Answer whether the receiver begins with the given prefix string.
The comparison is case-sensitive.
browserIcon
byteAt:
byteAt:put:
byteEncode:
byteSize
capitalized
Return a copy with the first letter capitalized
caseInsensitiveLessOrEqual:
Answer whether the receiver sorts before or equal to aString.
The collation order is case insensitive.
caseSensitiveLessOrEqual:
Answer whether the receiver sorts before or equal to aString.
The collation order is case sensitive.
charactersExactlyMatching:
Do a character-by-character comparison between the receiver and aString. Return the index of the final character that matched exactly.
compare:
Answer a comparison code telling how the receiver sorts relative to aString:
1 - before
2 - equal
3 - after.
The collation sequence is ascii with case differences ignored.
To get the effect of a <= b, but ignoring case, use (a compare: b) <= 2.
compare:caseSensitive:
Answer a comparison code telling how the receiver sorts relative to aString:
1 - before
2 - equal
3 - after.
compare:with:collated:
compressWithTable:
Return a string with all substrings that occur in tokens replaced
by a character with ascii code = 127 + token index.
This will work best if tokens are sorted by size.
Assumes this string contains no characters > 127, or that they
are intentionally there and will not interfere with this process.
contractTo:
return myself or a copy shortened by ellipsis to smallSize
convertFromEncoding:
convertFromSuperSwikiServerString
convertFromWithConverter:
convertToEncoding:
convertToSuperSwikiServerString
convertToSystemString
convertToWithConverter:
copyReplaceTokens:with:
Replace all occurrences of oldSubstring that are surrounded
by non-alphanumeric characters
copyWithRegex:matchesReplacedWith:
copyWithRegex:matchesTranslatedUsing:
correctAgainst:
Correct the receiver: assume it is a misspelled word and return the (maximum of five) nearest words in the wordList. Depends on the scoring scheme of alike:
correctAgainst:continuedFrom:
Like correctAgainst:. Use when you want to correct against several lists, give nil as the first oldCollection, and nil as the last wordList.
correctAgainstDictionary:continuedFrom:
Like correctAgainst:continuedFrom:. Use when you want to correct against a dictionary.
correctAgainstEnumerator:continuedFrom:
The guts of correction, instead of a wordList, there is a block that should take another block and enumerate over some list with it.
cr
crc16
Compute a 16 bit cyclic redundancy check.
crlf
crlfcrlf
decodeMimeHeader
See RFC 2047, MIME Part Three: Message Header Extension for Non-ASCII
Text. Text containing non-ASCII characters is encoded by the sequence
=?character-set?encoding?encoded-text?=
Encoding is Q (quoted printable) or B (Base64), handled by
Base64MimeConverter / RFC2047MimeConverter.
Thanks to Yokokawa-san, it works in m17n package. Try the following:
'=?ISO-2022-JP?B?U1dJS0lQT1AvGyRCPUJDKyVpJXMlQRsoQi8=?= =?ISO-2022-JP?B?GyRCJVElRiUjJSobKEIoUGF0aW8p?=' decodeMimeHeader.
decodeQuotedPrintable
Assume receiver is in MIME 'quoted-printable' encoding, and decode it.
deepCopy
DeepCopy would otherwise mean make a copy of the character; since
characters are unique, just return a shallowCopy.
displayAt:
Display the receiver as a DisplayText at aPoint on the display screen.
displayOn:
Display the receiver on the given DisplayMedium. 5/16/96 sw
displayOn:at:
Show a representation of the receiver as a DisplayText at location aPoint on aDisplayMedium, using black-colored text.
displayOn:at:textColor:
Show a representation of the receiver as a DisplayText at location aPoint on aDisplayMedium, rendering the text in the designated color
displayProgressAt:from:to:during:
Display this string as a caption over a progress bar while workBlock is evaluated.
EXAMPLE (Select next 6 lines and Do It)
'Now here''s some Real Progress'
displayProgressAt: Sensor cursorPoint
from: 0 to: 10
during: [:bar |
1 to: 10 do: [:x | bar value: x.
(Delay forMilliseconds: 500) wait]].
HOW IT WORKS (Try this in any other language :-)
Since your code (the last 2 lines in the above example) is in a block,
this method gets control to display its heading before, and clean up
the screen after, its execution.
The key, though, is that the block is supplied with an argument,
named 'bar' in the example, which will update the bar image every
it is sent the message value: x, where x is in the from:to: range.
do:toFieldNumber:
Considering the receiver as a holder of tab-delimited fields, evaluate aBlock on behalf of a field in this string
encodeDoublingQuoteOn:
Print inside string quotes, doubling inbedded quotes.
encodeForHTTP
change dangerous characters to their %XX form, for use in HTTP transactions
encodeForHTTPAlternate
change dangerous characters to their %XX form, for use in HTTP transactions
encodeForHTTPAlternateSkipSlashColon
change dangerous characters to their %XX form, for use in HTTP transactions
encodeForHTTPWithTextEncoding:
encodeForHTTPWithTextEncoding:conditionBlock:
change dangerous characters to their %XX form, for use in HTTP transactions
encodeOn:
endsWith:
Answer whether the tail end of the receiver is the same as suffix.
The comparison is case-sensitive.
endsWithAColon
Answer whether the final character of the receiver is a colon
endsWithAnyOf:
endsWithDigit
Answer whether the receiver's final character represents a digit. 3/11/96 sw
escapeEntities
evaluateExpression:parameters:
private - evaluate the expression aString with
aCollection as the parameters and answer the
evaluation result as an string
example
expandMacro:argument:withExpansions:
expandMacros
expandMacrosWith:
expandMacrosWith:with:
expandMacrosWith:with:with:
expandMacrosWith:with:with:with:
expandMacrosWithArguments:
extractNumber
findAnySubStr:startingAt:
Answer the index of the character within the receiver, starting at start, that begins a substring matching one of the delimiters. delimiters is an Array of Strings (Characters are permitted also). If the receiver does not contain any of the delimiters, answer size + 1.
findBetweenSubStrs:
Answer the collection of String tokens that result from parsing self. Tokens are separated by 'delimiters', which can be a collection of Strings, or a collection of Characters. Several delimiters in a row are considered as just one separation.
findCloseParenthesisFor:
assume (self at: startIndex) is $(. Find the matching $), allowing parentheses to nest.
findDelimiters:startingAt:
Answer the index of the character within the receiver, starting at start, that matches one of the delimiters. If the receiver does not contain any of the delimiters, answer size + 1.
findFirstInString:inCharacterSet:startingAt:
findFirstInString:inSet:startingAt:
findLastOccuranceOfString:startingAt:
findLastOccurrenceOfString:startingAt:
Answer the index of the last occurrence of subString within the receiver, starting at start. If
the receiver does not contain subString, answer 0. Case-sensitive match used.
findSelector
Dan's code for hunting down selectors with keyword parts; while this doesn't give a true parse, in most cases it does what we want, in where it doesn't, we're none the worse for it.
findString:
Answer the index of subString within the receiver, starting at start. If
the receiver does not contain subString, answer 0.
findString:startingAt:
Answer the index of subString within the receiver, starting at start. If
the receiver does not contain subString, answer 0.
findString:startingAt:caseSensitive:
Answer the index in this String at which the substring key first occurs,
at or beyond start. The match can be case-sensitive or not. If no match
is found, zero will be returned.
findSubstring:in:startingAt:matchTable:
Answer the index in the string body at which the substring key first occurs, at or beyond start. The match is determined using matchTable, which can be used to effect, eg, case-insensitive matches. If no match is found, zero will be returned.
findTokens:
Answer the collection of tokens that result from parsing self. Return strings between the delimiters. Any character in the Collection delimiters marks a border. Several delimiters in a row are considered as just one separation. Also, allow delimiters to be a single character.
findTokens:escapedBy:
Answer a collection of Strings separated by the delimiters, where
delimiters is a Character or collection of characters. Two delimiters in a
row produce an empty string (compare this to #findTokens, which
treats sequential delimiters as one).

The characters in quoteDelimiters are treated as quote characters, such
that any delimiter within a pair of matching quoteDelimiter characters
is treated literally, rather than as a delimiter.

The quoteDelimiter characters may be escaped within a quoted string.
Two sequential quote characters within a quoted string are treated as
a single character.

This method is useful for parsing comma separated variable strings for
spreadsheet import and export.
findTokens:includes:
Divide self into pieces using delimiters. Return the piece that includes subString anywhere in it. Is case sensitive (say asLowercase to everything beforehand to make insensitive).
findTokens:keep:
Answer the collection of tokens that result from parsing self. The tokens are seperated by delimiters, any of a string of characters. If a delimiter is also in keepers, make a token for it. (Very useful for carriage return. A sole return ends a line, but is also saved as a token so you can see where the line breaks were.)
findWordStart:startingAt:
HyperCard style searching. Answer the index in self of the substring key, when that key is preceeded by a separator character. Must occur at or beyond start. The match is case-insensitive. If no match is found, zero will be returned.
format:
format the receiver with aCollection

simplest example:
'foo {1} bar' format: {Date today}.

complete example:
'\{ \} \\ foo {1} bar {2}' format: {12. 'string'}.
fromByteArray:
fromPacked:
fromString:
getEnclosedExpressionFrom:
private - get the expression enclosed between '{' and
'}' and remove all the characters from the stream
getInteger32:
hasContentsInExplorer
hasWideCharacterFrom:to:
Return true if one of my character in the range does not fit in a single byte
hash
#hash is implemented, because #= is implemented
howManyMatch:
Count the number of characters that match up in self and aString.
includesSubString:
includesSubstring:caseSensitive:
includesUnifiedCharacter
indentationIfBlank:
Answer the number of leading tabs in the receiver. If there are
no visible characters, pass the number of tabs to aBlock and return its value.
indexOf:
Answer the index of the first occurence of anElement within the
receiver. If the receiver does not contain anElement, answer 0.
indexOf:startingAt:
indexOf:startingAt:ifAbsent:
Answer the index of the first occurence of anElement after start
within the receiver. If the receiver does not contain anElement,
answer the result of evaluating the argument, exceptionBlock.
indexOfAnyOf:
returns the index of the first character in the given set. Returns 0 if none are found
indexOfAnyOf:ifAbsent:
returns the index of the first character in the given set. Returns the evaluation of aBlock if none are found
indexOfAnyOf:startingAt:
returns the index of the first character in the given set, starting from start. Returns 0 if none are found
indexOfAnyOf:startingAt:ifAbsent:
returns the index of the first character in the given set, starting from start
indexOfAscii:inString:startingAt:
indexOfFirstUppercaseCharacter
indexOfSubCollection:
indexOfSubCollection:startingAt:ifAbsent:
Answer the index of the receiver's first element, such that that element
equals the first element of sub, and the next elements equal
the rest of the elements of sub. Begin the search at element
start of the receiver. If no such match is found, answer the result of
evaluating argument, exceptionBlock.
initialIntegerOrNil
Answer the integer represented by the leading digits of the receiver, or nil if the receiver does not begin with a digit
initialize
Subclasses should redefine this method to perform initializations on instance creation
isAllDigits
whether the receiver is composed entirely of digits
isAllSeparators
whether the receiver is composed entirely of separators
isAsciiString
isBogus
isByteString
Answer whether the receiver is a ByteString
isLiteral
Answer whether the receiver has a literal text form recognized by the
compiler.
isOctetString
Answer whether the receiver can be represented as a byte string.
This is different from asking whether the receiver *is* a ByteString
(i.e., #isByteString)
isPositiveInteger
isString
Overridden to return true in String, natch
isWideString
Answer whether the receiver is a WideString
javascriptOn:
join:
NB: this implementation only works for Array, since WriteStreams only work for Arrays and Strings. (!)
Overridden in OrderedCollection and SortedCollection.
keywords
Answer an array of the keywords that compose the receiver.
lastIndexOfPKSignature:
Answer the last index in me where aSignature (4 bytes long) occurs, or 0 if not found
lastSpacePosition
Answer the character position of the final space or other separator character in the receiver, and 0 if none
leadingCharRunLengthAt:
lf
lineCorrespondingToIndex:
Answer a string containing the line at the given character position. 1/15/96 sw: Inefficient first stab at this
lineCount
Answer the number of lines represented by the receiver, where every cr adds one line. 5/10/96 sw
lineNumber:
Answer a string containing the characters in the given line number. 5/10/96 sw
linesDo:
execute aBlock with each line in this string. The terminating CR's are not included in what is passed to aBlock
loadRequiredForMetacelloMCVersion:
match:
Answer whether text matches the pattern in this string.
Matching ignores upper/lower case differences.
Where this string contains #, text may contain any character.
Where this string contains *, text may contain any sequence of characters.
matchesRegex:
Test if the receiver matches a regex. May raise RxParser>>regexErrorSignal or
child signals.
This is a part of the Regular Expression Matcher package, (c) 1996, 1999 Vassili Bykov.
Refer to `documentation' protocol of RxParser class for details.
matchesRegexIgnoringCase:
Test if the receiver matches a regex. May raise RxParser>>regexErrorSignal or
child signals.
This is a part of the Regular Expression Matcher package, (c) 1996, 1999 Vassili Bykov.
Refer to `documentation' protocol of RxParser class for details.
mergeIntoMetacelloPackages:
mergeIntoMetacelloRepositories:
metacelloIntegerLessThanSelf:
integer version components are always '>' string component
metacelloStringLessThanSelf:
metacelloVersionComponentLessThan:
new:
niDescription
niLabel
nsReadStreamClass
nsWriteStreamClass
numArgs
Answer either the number of arguments that the receiver would take if considered a selector. Answer -1 if it couldn't be a selector. It is intended mostly for the assistance of spelling correction.
numericSuffix
occursInWithEmpty:caseSensitive:
Answer whether the receiver begins with the given prefix string.
The comparison is case-sensitive.
onlyLetters
answer the receiver with only letters
openInWorkspaceWithTitle:
Open up a workspace with the receiver as its contents, with the given title
packageFileSpecFor:
padded:to:with:
prefixMatchesRegex:
Test if the receiver's prefix matches a regex.
May raise RxParser class>>regexErrorSignal or child signals.
This is a part of the Regular Expression Matcher package, (c) 1996, 1999 Vassili Bykov.
Refer to `documentation' protocol of RxParser class for details.
prefixMatchesRegexIgnoringCase:
Test if the receiver's prefix matches a regex.
May raise RxParser class>>regexErrorSignal or child signals.
This is a part of the Regular Expression Matcher package, (c) 1996, 1999 Vassili Bykov.
Refer to `documentation' protocol of RxParser class for details.
printOn:
Print inside string quotes, doubling inbedded quotes.
putInteger32:at:
putOn:
readFrom:
regex:matchesCollect:
regex:matchesDo:
removeFromMetacelloPackages:
removeFromMetacelloRepositories:
renderOn:
Override this method to customize how objects (not components) are rendered when passed as an argument to #render:. The default is the return value of #displayString.
Just remember that you can not use #callback:, #on:of:, or #call:
replaceFrom:to:with:startingAt:
Primitive. This destructively replaces elements from start to stop in the receiver starting at index, repStart, in the collection, replacement. Answer the receiver. Range checks are performed in the primitive only. Optional. See Object documentation whatIsAPrimitive.
resolvePackageSpecsNamedForMetacelloMCVersion:visited:ifAbsent:
romanNumber
sameAs:
Answer whether the receiver sorts equal to aString. The
collation sequence is ascii with case differences ignored.
sansPeriodSuffix
Return a copy of the receiver up to, but not including, the first period. If the receiver's *first* character is a period, then just return the entire receiver.
service
serviceOrNil
setAuthorInMetacelloConfig:
setAuthorInMetacelloVersion:
setBlessingInMetacelloConfig:
setBlessingInMetacelloVersion:
setDescriptionInMetacelloConfig:
setDescriptionInMetacelloVersion:
setIncludesInMetacelloPackage:
setLoadsInMetacelloProject:
setPackage:withInMetacelloConfig:
setProject:withInMetacelloConfig:
setRequiresInMetacelloPackage:
setTimestampInMetacelloConfig:
setTimestampInMetacelloVersion:
skipAnySubStr:startingAt:
Answer the index of the last character within the receiver, starting at start, that does NOT match one of the delimiters. delimiters is a Array of substrings (Characters also allowed). If the receiver is all delimiters, answer size + 1.
skipDelimiters:startingAt:
Answer the index of the character within the receiver, starting at start, that does NOT match one of the delimiters. If the receiver does not contain any of the delimiters, answer size + 1. Assumes the delimiters to be a non-empty string.
space
splitInteger
Answer an array that is a splitting of self into a string and an integer.
'43Sam' ==> #(43 'Sam'). 'Try90' ==> #('Try' 90)
BUT NOTE: 'Sam' ==> #('Sam' 0), and '90' ==> #('' 90) ie, (<string> <integer>).
startingAt:match:startingAt:
Answer whether text matches the pattern in this string.
Matching ignores upper/lower case differences.
Where this string contains #, text may contain any character.
Where this string contains *, text may contain any sequence of characters.
startsWithDigit
Answer whether the receiver's first character represents a digit
stemAndNumericSuffix
Parse the receiver into a string-valued stem and a numeric-valued suffix. 6/7/96 sw
storeOn:
Print inside string quotes, doubling inbedded quotes.
string
stringHash:initialHash:
stringRepresentation
Answer a string that represents the receiver. For most objects this is simply its printString, but for strings themselves, it's themselves, to avoid the superfluous extra pair of quotes. 6/12/96 sw
stringhash
subStrings
Answer an array of the substrings that compose the receiver.
subStrings:
Answer an array containing the substrings in the receiver separated
by the elements of separators.
substrings
Answer an array of the substrings that compose the receiver.
surroundedBySingleQuotes
Answer the receiver with leading and trailing quotes.
tab
tabDelimitedFieldsDo:
Considering the receiver as a holder of tab-delimited fields, evaluate execute aBlock with each field in this string. The separatilng tabs are not included in what is passed to aBlock
translate:from:to:table:
translateFrom:to:table:
translate the characters in the string by the given table, in place
translateToLowercase
Translate all characters to lowercase, in place
translateToUppercase
Translate all characters to lowercase, in place
translateWith:
translate the characters in the string by the given table, in place
translated
answer the receiver translated to the default language
translatedIfCorresponds
answer the receiver translated to the default language only if
the receiver begins and ends with an underscore (_)
translatedTo:
answer the receiver translated to the given locale id
trimBlanks
truncateTo:
return myself or a copy shortened to smallSize. 1/18/96 sw
truncateWithElipsisTo:
Return myself or a copy suitably shortened but with elipsis added
unescapePercents
decode %xx form. This is the opposite of #encodeForHTTP
unescapePercentsWithTextEncoding:
decode string including %XX form
unparenthetically
If the receiver starts with (..( and ends with matching )..), strip them
unzipped
value:
with:
withBlanksCondensed
Return a copy of the receiver with leading/trailing blanks removed
and consecutive white spaces condensed.
withBlanksTrimmed
Return a copy of the receiver from which leading and trailing blanks have been trimmed.
withCRs
Return a copy of the receiver in which backslash (\) characters have been replaced with carriage returns.
withFirstCharacterDownshifted
Return a copy with the first letter downShifted
withInternetLineEndings
change line endings from CR's to CRLF's. This is probably in
prepration for sending a string over the Internet
withNoLineLongerThan:
Answer a string with the same content as receiver, but rewrapped so that no line has more characters than the given number
withSeparatorsCompacted
replace each sequences of whitespace by a single space character
withSqueakLineEndings
assume the string is textual, and that CR, LF, and CRLF are all
valid line endings. Replace each occurence with a single CR
withoutJustTrailingDigits
Answer the portion of the receiver that precedes any trailing series of digits. If the receiver consists entirely of digits and blanks, return an empty string
withoutLeadingBlanks
Return a copy of the receiver from which leading blanks have been
trimmed.
withoutLeadingDigits
Answer the portion of the receiver that follows any leading series of digits and blanks. If the receiver consists entirely of digits and blanks, return an empty string
withoutQuoting
remove the initial and final quote marks, if present
withoutTrailingBlanks
Return a copy of the receiver from which trailing blanks have been trimmed.
withoutTrailingDigits
Answer the portion of the receiver that precedes any trailing series of digits and blanks. If the receiver consists entirely of digits and blanks, return an empty string
wordBefore:
writeLeadingCharRunsOn:
zipped
Symbol
I represent Strings that are created uniquely. Thus, someString asSymbol == someString asSymbol.
=
Compare the receiver and aSymbol.
allSymbolTablesDo:
allSymbolTablesDo:after:
allSymbols
asMutator
Return a setter message from a getter message. For example,
#name asMutator returns #name:
asString
Refer to the comment in String|asString.
asSymbol
Refer to the comment in String|asSymbol.
at:put:
You cannot modify the receiver.
byteEncode:
capitalized
Return a copy with the first letter capitalized
clone
Answer with the receiver, because Symbols are unique.
compactSymbolTable
copy
Answer with the receiver, because Symbols are unique.
errorNoModification
findInterned:
flushCache
Tell the interpreter to remove all entries with this symbol as a selector from its method lookup cache, if it has one. This primitive must be called whenever a method is defined or removed.
NOTE: Only one of the two selective flush methods needs to be used.
Squeak 2.3 and later uses 116 (See CompiledMethod flushCache).
hasInterned:ifTrue:
includesKey:
initialize
Subclasses should redefine this method to perform initializations on instance creation
intern:
internCharacter:
isDoIt
isInfix
Answer whether the receiver is an infix message selector.
isKeyword
Answer whether the receiver is a message keyword.
isOrientedFill
Needs to be implemented here because symbols can occupy 'color' slots of morphs.
isPvtSelector
Answer whether the receiver is a private message selector, that is,
begins with 'pvt' followed by an uppercase letter, e.g. pvtStringhash.
isSymbol
isUnary
Answer whether the receiver is an unary message selector.
lookup:
newFrom:
numArgs:
Answer a string that can be used as a selector with n arguments.
TODO: need to be extended to support shrinking and for selectors like #+
possibleSelectorsFor:
precedence
Answer the receiver's precedence, assuming it is a valid Smalltalk
message selector or 0 otherwise. The numbers are 1 for unary,
2 for binary and 3 for keyword selectors.
readFrom:
rehash
Do nothing. Here so sending this to a Set does not have to do a time consuming respondsTo:
replaceFrom:to:with:startingAt:
Primitive. This destructively replaces elements from start to stop in the receiver starting at index, repStart, in the collection, replacement. Answer the receiver. Range checks are performed in the primitive only. Optional. See Object documentation whatIsAPrimitive.
selectorsContaining:
separateKeywords
shallowCopy
Answer with the receiver, because Symbols are unique.
shutDown:
storeOn:
Print inside string quotes, doubling inbedded quotes.
string:
thatStarts:skipping:
thatStartsCaseSensitive:skipping:
value:
veryDeepCopyWith:
Return self. I am immutable in the Morphic world. Do not record me.
withFirstCharacterDownshifted
Answer an object like the receiver but with first character downshifted if necesary
Text
I represent a character string that has been marked with abstract changes in character appearance. Actual display is performed in the presence of a TextStyle which indicates, for each abstract code, an actual font to be used. A Text associates a set of TextAttributes with each character in its character string. These attributes may be font numbers, emphases such as bold or italic, or hyperling actions. Font numbers are interpreted relative to whatever textStyle appears, along with the text, in a Paragraph. Since most characters have the same attributes as their neighbors, the attributes are stored in a RunArray for efficiency. Each of my instances has
string a String
runs a RunArray
=
Am I equal to the other Text or String?
***** Warning ***** Two Texts are considered equal if they have the same characters in them. They might have completely different emphasis, fonts, sizes, text actions, or embedded morphs. If you need to find out if one is a true copy of the other, you must do (text1 = text2 and: [text1 runs = text2 runs]).
addAttribute:
addAttribute:from:to:
Set the attribute for characters in the interval start to stop.
addAttribute:toArray:
alignmentAt:ifAbsent:
allBold
Force this whole text to be bold.
append:
asDisplayText
Answer a DisplayText whose text is the receiver.
asMorph
Open a morph, as best one can, on the receiver
asNumber
Answer the number created by interpreting the receiver as the textual
representation of a number.
asOctetStringText
asParagraph
Answer a Paragraph whose text is the receiver.
asString
Answer a String representation of the textual receiver.
asStringMorph
Open a StringMorph, as best one can, on the receiver
asStringOrText
Answer the receiver itself.
asText
Answer the receiver itself.
asTextMorph
Open a TextMorph, as best one can, on the receiver
asUrl
asUrlRelativeTo:
at:
Primitive. Assumes receiver is indexable. Answer the value of an
indexable element in the receiver. Fail if the argument index is not an
Integer or is out of bounds. Essential. See Object documentation
whatIsAPrimitive.
at:put:
Primitive. Assumes receiver is indexable. Store the argument value in
the indexable element of the receiver indicated by index. Fail if the
index is not an Integer or is out of bounds. Or fail if the value is not of
the right type for this kind of collection. Answer the value that was
stored. Essential. See Object documentation whatIsAPrimitive.
attributesAt:
Answer the code for characters in the run beginning at characterIndex.
attributesAt:do:
Answer the code for characters in the run beginning at characterIndex.
attributesAt:forStyle:
Answer the code for characters in the run beginning at characterIndex.
basicType
Answer a symbol representing the inherent type I hold
colorAt:
copy
Answer another instance just like the receiver. Subclasses typically override postCopy; they typically do not override shallowCopy.
copyFrom:to:
Answer a copied subrange of the receiver.
copyReplaceFrom:to:with:
Answer a copy of the receiver satisfying the following conditions: If
stop is less than start, then this is an insertion; stop should be exactly
start-1, start = 1 means insert before the first character, start = size+1
means append after last character. Otherwise, this is a replacement; start
and stop have to be within the receiver's bounds.
copyReplaceTokens:with:
Replace all occurrences of oldSubstring that are surrounded
by non-alphanumeric characters
deepCopy
Answer a copy of the receiver with its own copy of each instance
variable.
embeddedMorphs
return the list of morphs embedded in me
embeddedMorphsFrom:to:
return the list of morphs embedded in me
emphasisAt:
Answer the fontfor characters in the run beginning at characterIndex.
find:
Return the first interval over which this attribute applies
findString:startingAt:
Answer the index of subString within the receiver, starting at index
start. If the receiver does not contain subString, answer 0.
findString:startingAt:caseSensitive:
Answer the index of subString within the receiver, starting at index
start. If the receiver does not contain subString, answer 0.
fontAt:withStyle:
Answer the fontfor characters in the run beginning at characterIndex.
fontNumberAt:
Answer the fontNumber for characters in the run beginning at characterIndex.
fromString:
fromUser
hasWideCharacterFrom:to:
hash
#hash is implemented, because #= is implemented. We are now equal to a string with the same characters. Hash must reflect that.
howManyMatch:
initTextConstants
initialize
Subclasses should redefine this method to perform initializations on instance creation
isText
isoToSqueak
lineCount
macToSqueak
Convert the receiver from MacRoman to Squeak encoding
makeBoldFrom:to:
makeSelectorBold
For formatting Smalltalk source code, set the emphasis of that portion of
the receiver's string that parses as a message selector to be bold.
makeSelectorBoldIn:
For formatting Smalltalk source code, set the emphasis of that portion of
the receiver's string that parses as a message selector to be bold.
new:
prepend:
printOn:
Append a sequence of characters that identify the receiver to aStream.
rangeOf:startingAt:
Answer an interval that gives the range of attribute at index position index. An empty interval with start value index is returned when the attribute is not present at position index.
removeAttribute:from:to:
Remove the attribute over the interval start to stop.
removeAttributesThat:replaceAttributesThat:by:
Enumerate all attributes in the receiver. Remove those passing removalBlock and replace those passing replaceBlock after converting it through convertBlock
replaceFrom:to:with:
This destructively replaces elements from start to stop in the receiver.
Answer the receiver itself. Use copyReplaceFrom:to:with: for
insertion/deletion which may alter the size of the result.
replaceFrom:to:with:startingAt:
This destructively replaces elements from start to stop in the receiver starting at index, repStart, in replacementCollection. Do it to both the string and the runs.
reversed
Answer a copy of the receiver with element order reversed.
runLengthFor:
Answer the count of characters remaining in run beginning with
characterIndex.
runs
runs:
setString:setRuns:
setString:setRunsChecking:
Check runs and do the best you can to make them fit...
size
Answer how many elements the receiver contains.
squeakToIso
squeakToMac
Convert the receiver from Squeak to MacRoman encoding
storeOn:
Refer to the comment in Object|storeOn:.
streamContents:
string
Answer the string representation of the receiver.
string:attribute:
string:attributes:
string:emphasis:
string:runs:
unembellished
Return true if the only emphases are the default font and bold
withSqueakLineEndings
Answer a copy of myself in which all sequences of <CR><LF> or <LF> have been changed to <CR>
TextAction
A TextAction is xxxxxxxxx.
Instance Variables
analyze:
Analyze the selected text to find both the parameter to store and the text to emphesize (may be different from original selection). Does not return self!. May be of the form:
3+4
<3+4>
Click Here<3+4>
<3+4>Click Here
dominatedByCmd0
Cmd-0 should turn off active text
emphasizeScanner:
Set the emphasis for text display
info
initialize
Subclasses should redefine this method to perform initializations on instance creation
mayActOnClick
Subclasses may override to provide, eg, hot-spot actions
shoutShouldPreserve
Answer true if Shout should preserve ALL the attributes in the same run as the receiver,
false otherwise
validate:
any format is OK with me
TextAlignment
A TextAlignment is xxxxxxxxx.
Instance Variables
alignment: <Object>
alignment
- xxxxx
=
Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.
alignment
alignment:
alignmentSymbol:
centered
dominates:
There can be only one...
emphasizeScanner:
Set the emphasist for text scanning
hash
#hash is re-implemented because #= is re-implemented
justified
leftFlush
rightFlush
writeScanOn:
TextAttribute
Tells a piece of text to be a certain way.
Select text, press Command-6, choose a attribute. If selected text is of the form
Hi There<Smalltalk beep>
the part in angle brackets is saved for action, and the Hi There appears in the paragraph. If selection has no angle brackets, use the whole thing as both the text and the action.
TextDoIt -- eval as a Smalltalk expression (the part in angle brackets)
TextLink -- Show a method, class comment, class hierarchy, or class defintion.
<Point extent:>, <Point Comment>, <Point Hierarchy>, or <Point Defintion> are what you type.
TextURL -- Show the web page. <www.disney.com>
These attributes of text need to be stored on the disk in a regular file-out. It is done in this form: Hi There
in the text, and a Run containing dSmalltalk beep;;
Click here to see the extent:
in the text, and a Run containing method LPoint extent:;
See RunArray class scanFrom: where decoding is done.
actOnClickFor:
Subclasses may override to provide, eg, hot-spot actions
actOnClickFor:in:
actOnClickFor:in:at:
actOnClickFor:in:at:editor:
anchoredMorph
If one hides here, return it
dominatedByCmd0
Subclasses may override if cmd-0 should turn them off
dominates:
Subclasses may override condense multiple attributes
emphasisCode
Subclasses may override to add bold, italic, etc
emphasizeScanner:
Subclasses may override to set, eg, font, color, etc
forFontInStyle:do:
No action is the default. Overridden by font specs
isKern
mayActOnClick
Subclasses may override to provide, eg, hot-spot actions
mayBeExtended
A quality that may be overridden by subclasses, such as TextAnchors, that really only apply to a single character
oldEmphasisCode:
Allows running thorugh possibly multiple attributes
and getting the emphasis out of any that has an emphasis (font number)
reset
Allow subclasses to prepare themselves for merging attributes
set
Respond true to include this attribute (as opposed to, eg, a bold
emphasizer that is clearing the property
shoutShouldPreserve
Answer true if Shout should preserve ALL the attributes in the same run as the receiver,
false otherwise
TextColor
A TextColor encodes a text color change applicable over a given range of text.
=
Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.
black
blue
color
color:
cyan
dominates:
Subclasses may override condense multiple attributes
emphasizeScanner:
Set the emphasis for text display
gray
green
hash
Answer a SmallInteger whose value is related to the receiver's identity.
May be overridden, and should be overridden in any classes that define =
magenta
printHtmlCloseTagOn:
printHtmlOpenTagOn:
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
red
scanFrom:
white
writeScanOn:
Two formats. c125000255 or cblue;
yellow
TextDoIt
A TextDoIt is xxxxxxxxx.
Instance Variables
evalString: <Object>
evalString
- xxxxx
actOnClickFor:
Note: evalString gets evaluated IN THE CONTEXT OF anObject
-- meaning that self and all instVars are accessible
analyze:
Analyze the selected text to find both the parameter to store and the text to emphesize (may be different from original selection). Does not return self!. May be of the form:
3+4
<3+4>
Click Here<3+4>
<3+4>Click Here
evalString:
info
scanFrom:
writeScanOn:
TextEmphasis
A TextEmphasis, encodes a characteristic applicable to all fonts. The encoding is as follows:
1 bold
2 itallic
4 underlined
8 narrow
16 struck out
=
Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.
bold
dominatedByCmd0
Cmd-0 should turn off emphasis
dominates:
Subclasses may override condense multiple attributes
emphasisCode
Subclasses may override to add bold, italic, etc
emphasisCode:
emphasizeScanner:
Set the emphasist for text scanning
hash
#hash is re-implemented because #= is re-implemented
italic
narrow
normal
printHtmlCloseTagOn:
printHtmlOpenTagOn:
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
set
Respond true to include this attribute (as opposed to, eg, a bold
emphasizer that is clearing the property
struckOut
turnOff
underlined
writeScanOn:
TextFontChange
A TextFontChange encodes a font change applicable over a given range of text. The font number is interpreted relative to the textStyle governing display of this text.
=
Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.
defaultFontChange
dominates:
Subclasses may override condense multiple attributes
emphasizeScanner:
Set the font for text display
font1
font2
font3
font4
fontNumber
fontNumber:
forFontInStyle:do:
No action is the default. Overridden by font specs
hash
#hash is re-implemented because #= is re-implemented
printHtmlCloseTagOn:
printHtmlOpenTagOn:
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
writeScanOn:
TextFontReference
A TextFontReference encodes a font change applicable over a given range of text. The font reference is absolute: unlike a TextFontChange, it is independent of the textStyle governing display of this text.
=
Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.
emphasizeScanner:
Set the actual font for text display
font
forFontInStyle:do:
No action is the default. Overridden by font specs
hash
#hash is re-implemented because #= is re-implemented
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
toFont:
writeScanOn:
TextIndent
create a hanging indent.
amount
number of tab spaces to indent by
amount:
change the number of tabs to indent by
dominates:
Subclasses may override condense multiple attributes
emphasizeScanner:
Subclasses may override to set, eg, font, color, etc
example
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
tabs:
TextKern
A TextKern encodes a kerning change applicable over a given range of text. Positive values of kern spread letters out, negative kern will cause them to overlap more. Note that kerns other than 0 will display somewhat slower, as kerning is not yet supported in the text scanning primitive.
=
Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.
dominatedByCmd0
Cmd-0 should turn off kerning
dominates:
NOTE: The use of active in this code is specific to its use in the method
Text class addAttribute: att toArray: others
emphasizeScanner:
Augment (or diminish) the kerning offset for text display
hash
#hash is re-implemented because #= is re-implemented
isKern
kern
kern:
reset
Allow subclasses to prepare themselves for merging attributes
set
Respond true to include this attribute (as opposed to, eg, a bold
emphasizer that is clearing the property
writeScanOn:
A TextLink is xxxxxxxxx.
Instance Variables
classAndMethod: <Object>
classAndMethod
- xxxxx
actOnClickFor:
Add to the end of the list. 'aClass selector', 'aClass Comment', 'aClass Definition', 'aClass Hierarchy' are the formats allowed.
analyze:
Analyze the selected text to find both the parameter to store and the text to emphesize (may be different from original selection). Does not return self!. May be of the form:
3+4
<3+4>
Click Here<3+4>
<3+4>Click Here
analyze:with:
Initalize this attribute holder with a piece text the user typed into a paragraph. Returns the text to emphesize (may be different from selection) Does not return self!. nonMethod is what to show when clicked, i.e. the last part of specifier (Comment, Definition, or Hierarchy). May be of the form:
Point
<Point>
Click Here<Point>
<Point>Click Here
classAndMethod:
info
scanFrom:
validate:
Can this string be decoded to be Class space Method (or Comment, Definition, Hierarchy)? If so, return it in valid format, else nil
writeScanOn:
TextPrintIt
A TextPrintIt is xxxxxxxxx.
Instance Variables
actOnClickFor:in:at:editor:
Note: evalString gets evaluated IN THE CONTEXT OF anObject
-- meaning that self and all instVars are accessible
writeScanOn:
TextStream
A TextStream is xxxxxxxxx.
Instance Variables
applyAttribute:beginningAt:
nextPutAll:
Optimized access to get around Text at:Put: overhead
withAttribute:do:
No-op here is overriden in TextStream for font emphasis
withAttributes:do:
No-op here is overriden in TextStream for font emphasis
TextURL
A TextURL is xxxxxxxxx.
Instance Variables
url: <Object>
url
- xxxxx
actOnClickFor:
Do what you can with this URL. Later a web browser.
analyze:
Analyze the selected text to find both the parameter to store and the text to emphesize (may be different from original selection). Does not return self!. May be of the form:
3+4
<3+4>
Click Here<3+4>
<3+4>Click Here
info
printHtmlCloseTagOn:
printHtmlOpenTagOn:
scanFrom:
url:
writeScanOn:
TranscriptStream
This class is a much simpler implementation of Transcript protocol that supports multiple views and very simple conversion to morphic. Because it inherits from Stream, it is automatically compatible with code that is designe to write to streams.
bs
buildWith:
characterLimit
Tell the views how much to retain on screen
clear
Clear all characters and redisplay the view.
close
Presumably sets the status of the receiver to be closed. This message does
nothing at this level, but is included for FileStream compatibility.
codePaneMenu:shifted:
Note that unless we override perform:orSendTo:, PluggableTextController will respond to all menu items
endEntry
Display all the characters since the last endEntry, and reset the stream
flush
Do nothing by default
initialExtent
Answer the desired extent for the receiver when a view on it is first opened on the screen.
5/22/96 sw: in the absence of any override, obtain from RealEstateAgent
initialize
Subclasses should redefine this method to perform initializations on instance creation
isSelfEvaluating
isTranscriptStream
new
newTranscript:
open
openAsMorph
Answer a morph viewing this transcriptStream
openAsMorphLabel:
Build a morph viewing this transcriptStream
openLabel:
Open a window on this transcriptStream
openMorphicTranscript
pastEndPut:
If the stream reaches its limit, just output the contents and reset.
perform:orSendTo:
Selector was just chosen from a menu by a user. If can respond, then
perform it on myself. If not, send it to otherTarget, presumably the
editPane from which the menu was invoked.
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
registerInFlapsRegistry
release
Remove references to objects that may refer to the receiver. This message
should be overridden by subclasses with any cycles, in which case the
subclass should also include the expression super release.
semaphore
show:
TextCollector compatibility
step
Objects that may be models of SystemWindows need to respond to this, albeit vacuously
unload
windowColorSpecification
Transcripter
Transcripter is a dog-simple scrolling stream with display. It is intended to operate with no support from MVC or color in a minimal, or headless version of Squeak. No attention has been paid to appearance or performance.
black
clear
confirm:
Put up a yes/no menu with caption queryString. Answer true if the
response is yes, false if no. This is a modal question--the user must
respond yes or no.
emergencyEvaluator
endEntry
No-op for compatibility with TranscriptStream.
initInFrame:
isTranscriptStream
newInFrame:
readEvalPrint
request:
show:
startTranscriptProcess
white
WeakArray
WeakArray is an array which holds only weakly on its elements. This means whenever an object is only referenced by instances of WeakArray it will be garbage collected.
addWeakDependent:
finalizationProcess
initialize
Subclasses should redefine this method to perform initializations on instance creation
isFinalizationSupported
pvtCreateTemporaryObjectIn:
removeWeakDependent:
restartFinalizationProcess
runningFinalizationProcess
startUp:
WeakIdentityKeyDictionary
This class represents an identity dictionary with weak keys.
scanFor:
ar 10/21/2000: The method has been copied to this location to indicate that whenever #scanFor: changes #scanForNil: must be changed in the receiver as well.
scanForNil:
Private. Scan the key array for the first slot containing nil (indicating an empty slot). Answer the index of that slot.
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)
WeakKeyDictionary
I am a dictionary holding only weakly on my keys. This is a bit dangerous since at any time my keys can go away. Clients are responsible to register my instances by WeakArray such that the appropriate actions can be taken upon loss of any keys.
See WeakRegistry for an example of use.
add:
Include newObject as one of the receiver's elements, but only if
not already present. Answer newObject.
at:put:
Set the value at key to be anObject. If key is not found, create a new
entry for key and set is value to anObject. Answer anObject.
finalizeValues
remove all nil keys and rehash the receiver afterwards
finalizeValues:
Remove all associations with key == nil and value is in finiObjects.
This method is folded with #rehash for efficiency.
fixCollisionsFrom:
The element at index has been removed and replaced by nil.
keysDo:
Evaluate aBlock for each of the receiver's keys.
rehash
Rehash the receiver. Reimplemented to allow for multiple nil keys
scanFor:
ar 10/21/2000: The method has been copied to this location to indicate that whenever #scanFor: changes #scanForNil: must be changed in the receiver as well.
scanForNil:
Private. Scan the key array for the first slot containing nil (indicating an empty slot). Answer the index of that slot.
WeakKeyToCollectionDictionary
This class represents an identity dictionary with weak keys, whose values are collections.
Keys not in the dictionary are mapped to the empty collection. Conversely, if a collection becomes empty, the mapping can be removed to save time and space. However, because this requires re-hashing, it does not pay to do this to eagerly.
finalizeValues
remove all nil keys and rehash the receiver afterwards
rehash
Rehash the receiver. Reimplemented to remove nils from the collections
that appear as values, and to entirely remove associations with empty collections
as values.
WeakRegistry
I am a registry for objects needing finalization. When an object is added the object as well as its executor is stored. When the object is garbage collected, the executor can take the appropriate action for any resources associated with the object.
See also:
Object executor
Object actAsExecutor
Object finalize
add:
Add anObject to the receiver. Store the object as well as the associated executor.
add:executor:
Add anObject to the receiver. Store the object as well as the associated executor.
default
do:
Evaluate aBlock with each of the receiver's elements as the argument.
finalizeValues
Some of our elements may have gone away. Look for those and activate the associated executors.
initialize:
keys
new
new:
printElementsOn:
The original code used #skip:, but some streams do not support that,
and we don't really need it.
protected:
Execute aBlock protected by the accessLock
remove:ifAbsent:
Remove oldObject as one of the receiver's elements.
removeAll
See super
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.
WeakSet
A WeakSet is xxxxxxxxx.
Instance Variables
flag: <Object>
flag
- xxxxx
add:
Include newObject as one of the receiver's elements, but only if
not already present. Answer newObject
collect:
Evaluate aBlock with each of the receiver's elements as the argument.
Collect the resulting values into a collection like the receiver. Answer
the new collection.
do:
Evaluate aBlock with each of the receiver's elements as the argument.
do:after:
fixCollisionsFrom:
The element at index has been removed and replaced by nil.
This method moves forward from there, relocating any entries
that had been placed below due to collisions with this one
grow
Grow the elements array if needed.
Since WeakSets just nil their slots, alot of the occupied (in the eyes of the set) slots are usually empty. Doubling size if unneeded can lead to BAD performance, therefore we see if reassigning the <live> elements to a Set of similiar size leads to a sufficiently (50% used here) empty set first.
and reinsert the old elements
growTo:
Grow the elements array and reinsert the old elements
includes:
Answer whether anObject is one of the receiver's elements.
initialize:
Initialize array to an array size of n
inspectorClass
Answer the class of the inspector to be used on the receiver. Called by inspect;
use basicInspect to get a normal (less useful) type of inspector.
like:
Answer an object in the receiver that is equal to anObject,
nil if no such object is found. Relies heavily on hash properties
printElementsOn:
The original code used #skip:, but some streams do not support that,
and we don't really need it.
rehash
Do nothing. Here so sending this to a Set does not have to do a time consuming respondsTo:
remove:ifAbsent:
Remove oldObject from the receiver's elements. If several of the
elements are equal to oldObject, only one is removed. If no element is
equal to oldObject, answer the result of evaluating anExceptionBlock.
Otherwise, answer the argument, oldObject. ArrayedCollections cannot
respond to this message.
scanFor:
Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or zero if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements
scanForLoadedSymbol:
Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or zero if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements
size
Careful! Answer the maximum amount
of elements in the receiver, not the
exact amount
slowSize
Careful! Answer the maximum amount
of elements in the receiver, not the
exact amount
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.
WeakValueDictionary
I am a dictionary holding only weakly on my values. Clients may expect to get a nil value for any object they request.
add:
Include newObject as one of the receiver's elements, but only if
not already present. Answer newObject.
at:put:
Set the value at key to be anObject. If key is not found, create a new
entry for key and set is value to anObject. Answer anObject.
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
WideString
This class represents the array of 32 bit wide characters.
allMultiStringMethods
allNonAsciiMethods
asFourCode
asPacked
Convert to a longinteger that describes the string
at:
Answer the Character stored in the field of the receiver indexed by the argument.
at:put:
Store the Character in the field of the receiver indicated by the index.
byteAt:
byteAt:put:
byteSize
copyFrom:to:
Answer a copy of a subset of the receiver, starting from element at
index start until element at index stop.
from:
fromByteArray:
fromPacked:
fromString:
hasWideCharacterFrom:to:
Return true if one of my character in the range does not fit in a single byte
includesUnifiedCharacter
isUnicodeStringWithCJK
isWideString
Answer whether the receiver is a WideString
mutateJISX0208StringToUnicode
replaceFrom:to:with:startingAt:
Primitive. This destructively replaces elements from start to stop in the receiver starting at index, repStart, in the collection, replacement. Answer the receiver. Range checks are performed in the primitive only. Optional. See Object documentation whatIsAPrimitive.
wordAt:
wordAt:put:
WideSymbol
This class represents the symbols containing 32bit characters.
at:
Answer the Character stored in the field of the receiver indexed by the argument.
byteAt:
byteAt:put:
byteSize
fixUponLoad:seg:
We are in an old project that is being loaded from disk.
Fix up conventions that have changed.
initialize
Subclasses should redefine this method to perform initializations on instance creation
isWideString
Answer whether the receiver is a WideString
mutateJISX0208StringToUnicode
pvtAt:put:
Primitive. Store the Character in the field of the receiver indicated by
the index. Fail if the index is not an Integer or is out of bounds, or if
the argument is not a Character. Essential. See Object documentation
whatIsAPrimitive.
species
Answer the preferred class for reconstructing the receiver.
string:
wordAt:
wordAt:put:
WordArray
WordArrays store 32-bit unsigned Integer values.
*
+
-
/
asWordArray
Answer a WordArray whose elements are the elements of the receiver, in
the same order.
atAllPut:
Fill the receiver with the given value
bobsTest
byteSize
bytesPerElement
Number of bytes in each item. This multiplied by (self size)*8 gives the number of bits stored.
defaultElement
Return the default element of the receiver
primAddArray:and:into:
^ KedamaPlugin doPrimitive: #primitiveAddArrays.
primAddScalar:and:into:
^ KedamaPlugin doPrimitive: #primitiveAddScalar.
primDivArray:and:into:
^ KedamaPlugin doPrimitive: #primitiveDivArrays.
primDivScalar:and:into:
^ KedamaPlugin doPrimitive: #primitiveDivScalar.
primMulArray:and:into:
^ KedamaPlugin doPrimitive: #primitiveMulArrays.
primMulScalar:and:into:
^ KedamaPlugin doPrimitive: #primitiveMulScalar.
primSubArray:and:into:
^ KedamaPlugin doPrimitive: #primitiveSubArrays.
primSubScalar:and:into:
^ KedamaPlugin doPrimitive: #primitiveSubScalar.
replaceFrom:to:with:startingAt:
This destructively replaces elements from start to stop in the receiver
starting at index, repStart, in the sequenceable collection,
replacementCollection. Answer the receiver. No range checks are
performed.
WordArrayForSegment
A WordArrayForSegment is xxxxxxxxx.
Instance Variables
restoreEndianness
This word object was just read in from a stream. Do not correct the Endianness because the load primitive will reverse bytes as needed.
writeOn:
Write quickly and disregard the endianness of the words. Store the array of bits onto the argument, aStream. (leading byte ~= 16r80) identifies this as raw bits (uncompressed).
WriteStream
I represent an accessor for a sequence of objects that can only store objects in the sequence.
<<
we want a readable version of nextPutAll however it may be difficult to fully recreate nextPutAll:
for all the different types of stream. Rather then simply send to nextPutAll:
we handle the String (or ByteArray) argument
as fast as possible - the rest we delegate to putOn: This means that we handle single characters and bytes
whereas nextPutAll: is only for sequencable collections.
.
Note this may not work in every case that nextPutAll: does subject to extensive testing,
but it should work in the important cases
asHttpResponseTo:
braceArray
This method is used in compilation of brace constructs.
It MUST NOT be deleted or altered.
braceArray:
This method is used in compilation of brace constructs.
It MUST NOT be deleted or altered.
contentType
contents
Answer with a copy of my collection from 1 to readLimit.
cr
Append a return character to the receiver.
crlf
crtab
Append a return character, followed by a single tab character, to the
receiver.
crtab:
Append a return character, followed by anInteger tab characters, to the
receiver.
endEntry
No-op for compatibility with TranscriptStream.
ensureASpace
Append a space character to the receiver IFF there is not one on the end.
ensureEndsWith:
Append anObject to the receiver IFF there is not one on the end.
ensureNoSpace
If there is not one on the end, remove it.
growTo:
anInteger is the required minimal new size of the collection
next
Answer the next object accessible by the receiver.
next:putAll:startingAt:
Store the next anInteger elements from the given collection.
nextChunkPut:
Append the argument, aString, to the receiver, doubling embedded terminators.
nextChunkPutWithStyle:
Append the argument, aText, to the receiver, doubling embedded terminators. Put out one chunk for the string and one for the style runs. Mark the style with ]style[.
nextPut:
Primitive. Insert the argument at the next position in the Stream
represented by the receiver. Fail if the collection of this stream is not an
Array or a String. Fail if the stream is positioned at its end, or if the
position is out of bounds in the collection. Fail if the argument is not
of the right type for the collection. Optional. See Object documentation
whatIsAPrimitive.
nextPutAll:
Append the elements of aCollection to the sequence of objects accessible
by the receiver. Answer aCollection.
nextPutKeyword:withArg:
Emit a keyword/value pair in the alternate syntax
on:
on:from:to:
pastEndPut:
Grow the collection by doubling the size, but keeping the growth between 20 and 1000000.
Then put <anObject> at the current write position.
peekLast
Return that item just put at the end of the stream
position:
Refer to the comment in PositionableStream|position:.
reset
Refer to the comment in PositionableStream|reset.
resetToStart
setToEnd
Refer to the comment in PositionableStream|setToEnd.
size
Primitive. Answer the number of indexable variables in the receiver.
This value is the same as the largest legal subscript. Essential. See Object
documentation whatIsAPrimitive.
space
Append a space character to the receiver.
space:
Append anInteger space characters to the receiver.
store:
Have anObject print on the receiver for purposes of rereading.
tab
Append a tab character to the receiver.
tab:
Append anInteger tab characters to the receiver.
timeStamp
Append the current time to the receiver as a String.
with:
with:from:to:
withAttribute:do:
No-op here is overriden in TextStream for font emphasis
withAttributes:do:
No-op here is overriden in TextStream for font emphasis