Collections-Abstract

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