Squeak Class Documentation category index | class index  
 
SequenceableCollection
  category: Collections-Abstract
  superclass: Collection
  subclasses: ArrayedCollection MappedCollection LinkedList OrderedCollection Interval Heap SourceFileArray

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.

instance methods
  accessing
  after:
after:ifAbsent:
allButFirst
allButFirst:
allButLast
allButLast:
anyOne
at:ifAbsent:
atAll:
atAll:put:
atAll:putAll:
atAllPut:
atPin:
atRandom:
atWrap:
atWrap:put:
before:
before:ifAbsent:
eighth
fifth
first
first:
fourth
from:to:put:
identityIndexOf:
identityIndexOf:ifAbsent:
indexOf:
indexOf:ifAbsent:
indexOf:startingAt:ifAbsent:
indexOfSubCollection:startingAt:
indexOfSubCollection:startingAt:ifAbsent:
integerAt:
integerAt:put:
last
last:
lastIndexOf:
lastIndexOf:ifAbsent:
middle
ninth
replaceAll:with:
replaceFrom:to:with:
replaceFrom:to:with:startingAt:
second
seventh
sixth
swap:with:
third

  comparing
  =
hasEqualElements:
hash

  converting
  @
asArray
asByteArray
asColorArray
asFloatArray
asIntegerArray
asPointArray
asStringWithCr
asWordArray
isSequenceable
readStream
reverse
reversed
writeStream

  copying
  ,
copyAfter:
copyAfterLast:
copyEmpty
copyFrom:to:
copyLast:
copyReplaceAll:with:
copyReplaceFrom:to:with:
copyUpTo:
copyUpToLast:
copyWith:
copyWithoutFirst
copyWithoutIndex:
forceTo:paddingStartWith:
forceTo:paddingWith:
shallowCopy
shuffled
shuffledBy:
sortBy:

  enumerating
  asDigitsToPower:do:
collect:
collect:from:to:
collectWithIndex:
combinations:atATimeDo:
do:
do:separatedBy:
do:without:
doWithIndex:
findBinary:
findBinary:ifNone:
findBinaryIndex:
findBinaryIndex:ifNone:
findFirst:
findLast:
from:to:do:
keysAndValuesDo:
pairsCollect:
pairsDo:
permutationsDo:
polynomialEval:
reverseDo:
reverseWith:do:
select:
upTo:
with:collect:
with:do:
withIndexCollect:
withIndexDo:

  private
  asDigitsAt:in:do:
checkedAt:
combinationsAt:in:after:do:
copyReplaceAll:with:asTokens:
errorFirstObject:
errorLastObject:
errorOutOfBounds
permutationsStartingAt:do:

  removing
  remove:ifAbsent:

  testing
  includes:

class methods
  stream creation
  streamContents:
streamContents:limitedTo:

instance methods
  accessing top  
 

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.


 

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.


 

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.


 

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.


 

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.


 

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.


 

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.


 

eighth

Answer the eighth element of the receiver.
Raise an error if there are not enough elements.


 

fifth

Answer the fifth element of the receiver.
Raise an error if there are not enough elements.


 

first

Answer the first element of the receiver.
Raise an error if the collection is empty.


 

first:

Answer the first n elements of the receiver.
Raise an error if there are not enough elements.


 

fourth

Answer the fourth element of the receiver.
Raise an error if there are not enough elements.


 

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


 

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.


 

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.


 

integerAt:

Return the integer at the given index


 

integerAt:put:

Return the integer at the given index


 

last

Answer the last element of the receiver.
Raise an error if the collection is empty.


 

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.


 

middle

Answer the middle element of the receiver.


 

ninth

Answer the ninth element of the receiver.
Raise an error if there are not enough elements.


 

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.


 

second

Answer the second element of the receiver.
Raise an error if there are not enough elements.


 

seventh

Answer the seventh element of the receiver.
Raise an error if there are not enough elements.


 

sixth

Answer the sixth element of the receiver.
Raise an error if there are not enough elements.


 

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.


  comparing top  
 

=

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.


 

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


  converting top  
 

@


 

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


 

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.


 

asWordArray

Answer a WordArray whose elements are the elements of the receiver, in
the same order.


 

isSequenceable


 

readStream


 

reverse


 

reversed

Answer a copy of the receiver with element order reversed.


 

writeStream


  copying top  
 

,

Concatenate two Strings or Collections.


 

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:


 

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.


 

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.


 

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.


 

shallowCopy

Answer a copy of the receiver which shares the receiver's instance variables.


 

shuffled


 

shuffledBy:


 

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


  enumerating top  
 

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.


 

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


 

do:

Refer to the comment in Collection|do:.


 

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


 

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.


 

from:to:do:

Evaluate aBlock for all elements between start and stop (inclusive).


 

keysAndValuesDo:

Enumerate the receiver with all the keys (aka indices) and values.


 

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.


 

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.


 

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.


 

select:

Refer to the comment in Collection|select:.


 

upTo:

Deprecated. Use copyUpTo:


 

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.


 

withIndexDo:

Just like with:do: except that the iteration index supplies the second argument to the block.


  private top  
 

asDigitsAt:in:do:

(0 to: 1) asDigitsToPower: 4 do: [:each | Transcript cr; show: each printString]


 

checkedAt:


 

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.


 

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.


 

errorFirstObject:


 

errorLastObject:


 

errorOutOfBounds


 

permutationsStartingAt:do:

#(1 2 3 4) permutationsDo: [:each | Transcript cr; show: each printString]


  removing top  
 

remove:ifAbsent:

SequencableCollections cannot implement removing.


  testing top  
 

includes:

Answer whether anObject is one of the receiver's elements.


class methods
  stream creation top  
 

streamContents:


 

streamContents:limitedTo: