eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Collection':

Home

everywhere
www.exept.de
for:
[back]

Class: Collection


Inheritance:

   Object
   |
   +--Collection
      |
      +--BTree
      |
      +--Bag
      |
      +--BinaryTree
      |
      +--Iterator
      |
      +--KeyedCollection
      |
      +--MappedCollection
      |
      +--Queue
      |
      +--SequenceableCollection
      |
      +--Set
      |
      +--SharedCollection
      |
      +--TSTree
      |
      +--TreeSet

Package:
stx:libbasic
Category:
Collections-Abstract
Version:
rev: 1.241 date: 2010/01/29 16:41:43
user: cg
file: Collection.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Claus Gittinger

Description:


Abstract superclass for all collections.
This abstract class provides functionality common to all collections,
without knowing how the concrete class implements things. Thus, all
methods found here depend on some basic mechanisms to be defined in the
concrete class. 
These basic methods are usually defined as #subclassResponsibility here.
Some methods are also redefined for better performance.

Subclasses should at least implement:
    do:     - enumerate elements

they should implement one of the following set of access messages:
keyed collections:
    at:ifAbsent:            - fetching an element
    at:                     - fetching an element
    at:put:                 - storing an element

unkeyed collections:
    add:                    - add an element
    remove:ifAbsent:        - remove an element


Class protocol:

Compatibility-Squeak
o  ofSize: n
return a new collection which really provides space for n elements.
Kludges around the stupid definition of OrderedCollection>>new:

JS syntactic sugar
o  with: el1 _: el2
for JS easy syntax - allows: Array.with(el1, el2,...)

o  with: el1 _: el2 _: el3
for JS easy syntax - allows: Array.with(el1, el2,...)

o  with: el1 _: el2 _: el3 _: el4
for JS easy syntax - allows: Array.with(el1, el2,...)

o  with: el1 _: el2 _: el3 _: el4 _: el5
for JS easy syntax - allows: Array.with(el1, el2,...)

o  with: el1 _: el2 _: el3 _: el4 _: el5 _: el6
for JS easy syntax - allows: Array.with(el1, el2,...)

o  with: el1 _: el2 _: el3 _: el4 _: el5 _: el6 _: el7
for JS easy syntax - allows: Array.with(el1, el2,...)

o  with: el1 _: el2 _: el3 _: el4 _: el5 _: el6 _: el7 _: el8
for JS easy syntax - allows: Array.with(el1, el2,...)

Signal constants
o  emptyCollectionSignal
return the signal used to report non-allowed operation on empty collections

o  invalidKeySignal
return the signal used to report bad key usage

o  notEnoughElementsSignal
return the signal used to report attempts for an operation, for which
there are not enough elements in the collection

o  valueNotFoundSignal
return the signal used to report a nonexisting element.

initialization
o  initialize
setup the signal

instance creation
o  new: size withAll: element
return a new Collection of size, where all elements are
initialized to element

o  newFrom: aCollection
Return an instance of me containing the same elements as aCollection.

o  with: anObject
return a new Collection with one element:anObject

o  with: firstObject with: secondObject
return a new Collection with two elements:firstObject and secondObject

o  with: firstObject with: secondObject with: thirdObject
return a new Collection with three elements

o  with: firstObject with: secondObject with: thirdObject with: fourthObject
return a new Collection with four elements

o  with: a1 with: a2 with: a3 with: a4 with: a5
return a new Collection with five elements

o  with: a1 with: a2 with: a3 with: a4 with: a5 with: a6
return a new Collection with size elements

o  with: a1 with: a2 with: a3 with: a4 with: a5 with: a6 with: a7
return a new Collection with seven elements

o  with: a1 with: a2 with: a3 with: a4 with: a5 with: a6 with: a7 with: a8
return a new Collection with eight elements

o  withAll: aCollection
return a new Collection with all elements taken from the argument,
aCollection

o  withSize: n
return a new collection which really provides space for n elements.
Kludges around the stupid definition of OrderedCollection>>new:

misc ui support
o  iconInBrowserSymbol

queries
o  growIsCheap
return true, if this collection can easily grow
(i.e. without a need for become:).
Returns true here; this method is redefined in fix-size
collections

o  isAbstract
Return if this class is an abstract class.
True is returned for Collection here; false for subclasses.
Abstract subclasses must redefine again.


Instance protocol:

Compatibility-Dolphin
o  identityIncludes: anObject
return true, if the argument, anObject is in the collection.
Same as #includesIdentical for Dolphin compatibility.

o  includesAnyOf: aCollection
same as #includesAny for Dolphin compatibility.

o  symmetricDifference: aCollection
return a new set containing all elements,
which are contained in either the receiver or aCollection, but not in both.
Same as xor: - for compatibility

Compatibility-Squeak
o  addIfNotPresent: anObject
Include anObject as one of the receiver's elements, but only if there
is no such element already. Anwser anObject.

o  anyOne
return any element from the collection.
Report an error if there is none.
Same as #anElement - for Squeak compatibility

o  difference: aCollection
Answer the set-theoretic difference of two collections.

o  gather: aBlock
return an Array,
containing all elements as returned from applying aBlock to each element if the receiver,
where the block returns a collection of to-be-added elements.
This could also be called: collectAllAsArray:

o  gather: aBlock as: aClass
return an instance of the collection-class aClass,
containing all elements as returned from applying aBlock to each element if the receiver.
where the block returns a collection of to-be-added elements.
This could also be called: collectAll:as:

o  groupBy: keyBlock having: selectBlock
Like in SQL operation - Split the receiver's contents into collections of
elements for which keyBlock returns the same results, and return those
collections allowed by selectBlock.

o  ifEmpty: ifEmptyValue ifNotEmpty: ifNotEmptyValue

o  ifEmpty: ifEmptyValue ifNotEmptyDo: ifNotEmptyValue

o  ifEmptyDo: ifEmptyValue ifNotEmpty: ifNotEmptyValue

o  ifNotEmpty: ifNotEmptyValue

o  ifNotEmptyDo: ifNotEmptyValue

o  ifNotEmptyDo: ifNotEmptyValue ifEmpty: ifEmptyValue

o  intersection: aCollection

o  withIndexDo: aTwoArgBlock
evaluate the argument, aBlock for every element in the collection,
passing both element and index as arguments.

JavaScript support
o  length
returns the length of the string

accessing
o  anElement
return any element from the collection,
report an error if there is none

o  atAll: indexCollection put: anObject
put anObject into all indexes from indexCollection in the receiver.
This abstract implementation requires that the receiver supports
access via a key (and indexCollection contains valid keys).

Notice: This operation modifies the receiver, NOT a copy;
therefore the change may affect all others referencing the receiver.

o  fifth
return the fifth element of the collection.
For unordered collections, this simply returns the fifth
element when enumerating them.
This should be redefined in subclasses.

o  first
return the first element of the collection.
For unordered collections, this simply returns the first
element when enumerating them.
This should be redefined in subclasses.

o  first: n
return the n first elements of the collection.
Raises an error if there are not enough elements in the receiver.
For unordered collections, this simply returns the first
n elements when enumerating them
(Warning: the contents of the returned collection is not deterministic in this case).
This should be redefined in subclasses.

o  firstIfEmpty: exceptionValue
return the first element of the collection.
If its empty, return the exceptionValue.
(i.e. dont trigger an error as done in #first)

o  firstOrNil
return the first element of the collection.
If its empty, return nil.
(i.e. dont trigger an error as done in #first)

o  fourth
return the fourth element of the collection.
For unordered collections, this simply returns the fourth
element when enumerating them.
This should be redefined in subclasses.

o  last
return the last element of the collection.
This should be redefined in subclasses.

o  last: n
return the n last elements of the collection.
Raises an error if there are not enough elements in the receiver.
For unordered collections, this simply returns the last
n elements when enumerating them
(Warning: the contents of the returned collection is not deterministic in this case).
This should be redefined in subclasses since the implementation here is VERY inefficient.

o  lastIfEmpty: exceptionValue
return the last element of the collection.
If its empty, return the exceptionValue.
(i.e. dont trigger an error as done in #last)

o  median
Return the middle element, or as close as we can get.

o  nth: n
return the nth element of the collection.
For unordered collections, this simply returns the nth
element when enumerating them.
This should be redefined in subclasses.

o  order
report an error that only OrderedXXX's have an order

o  second
return the second element of the collection.
For unordered collections, this simply returns the second
element when enumerating them.
This should be redefined in subclasses.

o  seventh
return the seventh element of the collection.
For unordered collections, this simply returns the sixth
element when enumerating them.
This should be redefined in subclasses.

o  sixth
return the sixth element of the collection.
For unordered collections, this simply returns the sixth
element when enumerating them.
This should be redefined in subclasses.

o  third
return the third element of the collection.
For unordered collections, this simply returns the third
element when enumerating them.
This should be redefined in subclasses.

o  values
return a collection containing all values of the receiver.
This is to make value access to an OrderedDictionary compatible with any-Collection

adding & removing
o  add: anObject
add the argument, anObject to the receiver.
If the receiver is ordered, the position of the new element is undefined
(i.e. don't depend on where it will be put).
An error is raised here - it is to be implemented by a concrete subclass.

** This method raises an error - it must be redefined in concrete classes **

o  add: newObject withOccurrences: anInteger
add the argument, anObject anInteger times to the receiver.
Returns the object.

o  addAll: aCollection
add all elements of the argument, aCollection to the receiver.
Returns the argument, aCollection (sigh).

o  addAllFirst: aCollection
insert all elements of the argument, aCollection at the beginning
of the receiver. Returns the argument, aCollection.

o  addAllLast: aCollection
add all elements of the argument, aCollection to the receiver.
Returns the argument, aCollection.

o  addFirst: anObject
add the argument, anObject to the receiver.
If the receiver is ordered, the new element will be added at the beginning.
An error is raised here - it is to be implemented by a concrete subclass.

** This method raises an error - it must be redefined in concrete classes **

o  addLast: anObject
add the argument, anObject to the receiver.
If the receiver is ordered, the new element will be added at the end.
Return the argument, anObject.

This usually has the same semantics as #add:.
OrderedSet and OrderedDictionary redefine this, to move anObject to
the end, even if it is already present in the collection.

o  contents: aCollection
set my contents from aCollection
- this may be redefined in a concrete subclass for more performance

o  remove: anObject
search for the first element, which is equal to anObject;
if found, remove and return it.
If not found, report a 'value not found'-error.
Uses equality compare (=) to search for the occurrence.

o  remove: anObject ifAbsent: exceptionBlock
search for the first element, which is equal to anObject;
if found, remove and return it.
If not found, return the the value of the exceptionBlock.
Uses equality compare (=) to search for the occurrence.
An error is raised here - it is to be implemented by a concrete subclass.

** This method raises an error - it must be redefined in concrete classes **

o  removeAll
remove all elements from the receiver. Returns the receiver.
This should be reimplemented in subclasses for better
performance.

o  removeAll: aCollection
remove all elements of the argument, aCollection from the receiver.
Return the argument, aCollection.
Raises an error, if some element-to-remove is not in the receiver.
(see also: #removeAllFoundIn:, which does not raise an error).

Notice: for some collections (those not tuned for
resizing themself) this may be very slow.
If the number of removed elements is big compared to to
the receivers size, it may be better to copy the
ones which are not to be removed into a new collection.

o  removeAllFoundIn: aCollection
Remove each element of aCollection, which is present in the receiver
from the receiver.
No error is raised, if some element-to-remove is not in the receiver.
(see also: #removeAll:, which does raise an error).

o  removeAllKeys: aCollection
remove all keys of the argument, aCollection from the receiver.
Raises an error, if some element-to-remove is not in the receiver.
Notice: only works for keyed collections, such as dictionaries.

o  removeAllSuchThat: aBlock
Apply the condition to each element and remove it if the condition is true.
Return a collection of removed elements.
First elements-to-remove are collected, then removed in one operation.

o  removeFirst
remove the first element from the receiver.
Return the removed element.

o  removeFirst: n
remove the first n elements from the receiver.
Return a collection of removed elements.
Notice: for some collections (those not tuned for
resizing themself) this may be very slow.

o  removeIdentical: anObject
search for the first element, which is identical to anObject;
if found, remove and return it.
If not found, report a 'value not found'-error.
Uses identity compare (==) to search for the occurrence.

o  removeIdentical: anObject ifAbsent: exceptionBlock
search for the first element, which is identical to anObject;
if found, remove and return it.
If not found, return the the value of the exceptionBlock.
Uses identity compare (==) to search for the occurrence.
An error is raised here - it is to be implemented by a concrete subclass.

** This method raises an error - it must be redefined in concrete classes **

o  removeLast
remove the last element from the receiver.
Return the removed element.
An error is raised here - it is to be implemented by a concrete subclass.

** This method raises an error - it must be redefined in concrete classes **

o  removeLast: n
remove the last n elements from the receiver collection.
Return a collection of removed elements.
Notice: for some collections this may be very slow
(those not tuned for resizing themself).

bulk operations
o  abs
Absolute value of all elements in the collection

o  negated
Negated value of all elements in the collection

o  product
multiply up all elements.

o  sum
sum up all elements; return 0 for an empty collection.

o  sum: aBlock
for each element in the receiver, evaluate the argument, aBlock
and sum up the results. Return the total sum or 0 for an empty collection.
Similar to (self collect...) sum, but avoids creation of an intermediate collection.

converting
o  asArray
return a new Array with the collections elements

o  asBag
return a new Bag with the receiver collections elements

o  asByteArray
return a new ByteArray with the collections elements
(which must convert to 8bit integers in the range 0..255).

o  asCollection
return myself as a Collection.
I am already a Collection.

o  asDictionary
return a new Dictionary with the receiver collections elements

o  asDoubleArray
return a new DoubleArray with the collections elements
(which must convert to 64bit floats).

o  asFlatOrderedCollection

o  asFloatArray
return a new FloatArray with the collections elements
(which must convert to 32bit floats).

o  asIdentitySet
return a new IdentitySet with the receiver collections elements

o  asIntegerArray
return a new IntegerArray with the collection's elements
(which must convert to 32bit integers in the range 0..16rFFFFFFFF).

o  asIntegerArray: arrayClass
return a new Array with the collection's elements

o  asList
return a new List with the receiver collections elements

o  asLongIntegerArray
return a new LongIntegerArray with the collections elements
(which must convert to 64bit integers in the range 0..16rFFFFFFFFFFFFFFFF).

o  asOrderedCollection
return a new OrderedCollection with the receiver collections elements

o  asRunArray
return a new RunArray with the collections elements

o  asSequenceableCollection
return myself as a SequenceableCollection.
I am already a Collection, but not sequenceable.

o  asSet
return a new Set with the receiver collections elements

o  asSharedCollection
return a shared collection on the receiver.
This implements synchronized access to me.

o  asSortedCollection
return a new SortedCollection with the receiver collections elements

o  asSortedCollection: sortBlock
return a new SortedCollection with the receiver collections elements,
using sortBlock for comparing

o  asSortedStrings
Create & return a SortedCollection that sorts the receivers
elements according to the locales collating policy.
This is currently not really support - strings are sorted
without caring for the locale.

o  asSortedStrings: sortBlock
Create & return a SortedCollection that sorts the receivers
elements using sortBlock and according to the locales collating policy,
which is passed as first arg to sortBlock.
This is currently not really support - strings are sorted
without caring for the locale.

o  asSortedStrings: sortBlock with: aCollationPolicy
Create & return a SortedCollection that sorts the receivers
elements using sortBlock and according to the specified locales collating policy.
This is currently not really support - strings are sorted
without caring for the locale.

o  asSortedStringsWith: aCollationPolicy
Create & return a SortedCollection that sorts the receivers
elements according to the specified locales collating policy.
This is currently not really support - strings are sorted
without caring for the locale.

o  asString
return a String with the collection's elements
(which must convert to characters)

o  asStringCollection
return a new string collection containing the elements;
these ought to be strings. (i.e. String or Text instances)

o  asUnicodeString
return a String with the collections elements
(which must convert to characters)

o  asWordArray
return a new WordArray with the collections elements
(which must convert to integers in the range 0..16rFFFF).

o  copyAs: collectionClass
return a new instance of collectionClass with the receiver collection's elements.
This is similar to copy as:collectionClass, to ensure that we get a new
(unshared) collection, but avoids the copy if the receiver is not already an
instance of collectionClass.

o  copyAsOrderedCollection
return a new OrderedCollection with the receiver collection's elements.
This is similar to copy asOrderedCollection, to ensure that we get a new
(unshared) collection, but avoids the copy if the receiver is not already an
OrderedCollection.

o  keysAndValues

o  literalArrayEncoding
encode myself as an array literal, from which a copy of the receiver
can be reconstructed with #decodeAsLiteralArray.

o  readStream
return a stream for reading from the receiver

o  readStreamOrNil
return a stream for reading from the receiver.
This has been defined for protocol compatibility with FileName,
but nil is never returned here

o  readWriteStream
return a stream for reading and writing from/to the receiver

o  writeStream
return a stream for writing onto the receiver

o  writeStreamOrNil
return a stream for writing onto the receiver.
This has been defined for protocol compatibility with FileName,
but nil is never returned here

copying
o  copy
return a copy of the receiver.
Redefined to pass the original as argument to the postCopyFrom method.

o  copyEmpty
return a copy of the receiver with no elements.
This is used by copying and enumeration methods
to get a new instance which is similar to the receiver.

o  copyEmpty: size
return a copy of the receiver with no elements, but space for
size elements. This is used by copying and enumeration methods
to get a new instance which is similar to the receiver.
This method should be redefined in subclasses with instance
variables, which should be put into the copy too.
For example, SortedCollection has to copy its sortBlock into the
new collection.

o  copyEmptyAndGrow: size
return a copy of the receiver with size nil elements.
This is used by copying and enumeration methods
to get a new instance which is similar to the receiver.

o  postCopyFrom: original
sent to a freshly copied object to give it a chance to adjust things.
Notice, that for Sets/Dicts etc. a rehash is not needed, since the copy
will have the same hash key as the receiver (as long as ST/X provides the
setHash: functionality).

enumerating
o  addAllNonNilElementsTo: aCollection
add all nonNil elements of the receiver to aCollection.
Return aCollection.

o  addAllTo: aCollection
add all elements of the receiver, to aCollection.
Return aCollection.

o  collect: aBlock
for each element in the receiver, evaluate the argument, aBlock
and return a new collection with the results

o  collect: aBlock as: aClass
like collect, but use an instance of aClass to collect the results.
Also avoids the need for an extra intermediate collection which is created with
the standard coding: 'self asXXXX collect:[...]

o  collect: collectBlock thenReject: rejectBlock
combination of collect followed by reject.
May be redefined by some subclasses for optimal performance
(avoiding the creation of intermediate garbage)

o  collect: collectBlock thenSelect: selectBlock
combination of collect followed by select.
May be redefined by some subclasses for optimal performance
(avoiding the creation of intermediate garbage)

o  collectAll: aBlock
for each element in the receiver, evaluate the argument, aBlock.
The block is supposed to return a collection, whose elements are collected.
The species of the returned collection is that of the first returned
partial result.

o  count: aBlock
count elements, for which aBlock returns true.
Return the sum.

o  detect: aBlock
evaluate the argument, aBlock for each element in the receiver until
the block returns true; in this case return the element which caused
the true evaluation.
If none of the evaluations returns true, report an error

o  detect: generatorBlock forWhich: testBlock ifNone: exceptionBlock
evaluate generatorBlock for each element in the receiver until
testBlock returns true for it;
in this case return the value from generatorBlock, which caused the true evaluation.
If none of the test evaluations returns true, return the result of the
evaluation of the exceptionBlock

o  detect: aOneArgBlock ifNone: exceptionBlock
evaluate the argument, aBlock for each element in the receiver until
the block returns true; in this case return the element which caused
the true evaluation.
If none of the evaluations returns true, return the result of the
evaluation of the exceptionBlock

o  detectLast: aBlock
evaluate the argument, aBlock for each element in the receiver until
the block returns true; in this case return the element which caused
the true evaluation. The elements are processed in reverse order.
If none of the evaluations returns true, report an error

o  detectLast: aBlock ifNone: exceptionBlock
evaluate the argument, aBlock for each element in the receiver until
the block returns true; in this case return the element which caused
the true evaluation. The elements are processed in reverse order.
If none of the evaluations returns true, return the result of the
evaluation of the exceptionBlock

o  do: aBlock
evaluate the argument, aBlock for each element

** This method raises an error - it must be redefined in concrete classes **

o  do: aBlock inBetweenDo: betweenBlock
evaluate the argument, aBlock for each element.
Between elements (i.e. after each except for the last),
evaluate betweenBlock.
This is a utility helper for collection printers
(for example, to print a space between elements).

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  do: aBlock separatedBy: betweenBlock
evaluate the argument, aBlock for each element.
Between elements (i.e. after each except for the last),
evaluate betweenBlock.
This is a utility helper for collection printers
(for example, to print a space between elements).

o  doWithExit: aBlock
evaluate the argument, aBlock for each element.
Passes an additional exit object, which can be used to leave
the loop early, by sending it a #value: message.
Returns nil or the value passed to the exit>>value: message.

Notice, that this is different to a return statement in the block,
which returns from the enclosed method, NOT only from the block.

o  flatDo: aBlock
for each element of the collection, if its a scalar, evaluate aBlock for it;
otherwise, recursively invoke flatDo on the collection.

o  inject: thisValue into: binaryBlock
starting with thisValue for value, pass this value and each element
to binaryBlock, replacing value with the result returned from the block
in the next iteration.

o  keysAndValuesDo: aTwoArgBlock
evaluate the argument, aBlock for every element in the collection,
passing both index and element as arguments.

o  keysAndValuesReverseDo: aTwoArgBlock
evaluate the argument, aBlock in reverse order for every element in the collection,
passing both index and element as arguments.

o  keysAndValuesSelect: selectBlockWith2Args thenCollect: collectBlockWith2Args

o  map: selector
for lisp fans - similar to collect

o  map: selector with: arg
for lisp fans - similar to collect

o  nonNilElementsDo: aBlock
evaluate the argument, aBlock for every non-nil element in the collection.

o  pairsDo: aTwoArgBlock
evaluate the argument, aTwoArgBlock for every element in the collection,
which is supposed to consist of 2-element collections.
The block is called with 2 arguments for each collection in the receiver.
CONFUSION ATTACK:
this is different from pairWiseDo:.
but the Squeak-pairsDo: does the same as our pairWiseDo:
(sigh: but we were first, so they should have adapted...)

o  reject: aBlock
return a new collection with all elements from the receiver, for which
the argument aBlock evaluates to false

o  reject: rejectBlock thenCollect: collectBlock
combination of reject followed by collect.
May be redefined by some subclasses for optimal performance
(avoiding the creation of intermediate garbage)

o  reverseDo: aBlock
evaluate the argument, aBlock for each element in reverse order.

** This method raises an error - it must be redefined in concrete classes **

o  select: aBlock
return a new collection with all elements from the receiver, for which
the argument aBlock evaluates to true.
See also: #removeAllFoundIn: and #removeAllSuchThat:

o  select: aBlock ifNone: exceptionBlock
try a new collection with all elements from the receiver, for which
the argument aBlock evaluates to true. If none of the elements passes
the check of aBlock, return the result of evaluating exceptionBlock.
See also: #removeAllFoundIn: and #removeAllSuchThat:

o  select: selectBlock thenCollect: collectBlock
combination of select followed by collect.
May be redefined by some subclasses for optimal performance
(avoiding the creation of intermediate garbage)

o  select: selectBlock thenDo: doBlock
combination of select followed by do
Avoids the creation of intermediate garbage

o  triplesDo: aBlock
evaluate the argument, aBlock for every element in the collection,
which is supposed to consist of 3-element collections.
The block is called with 3 arguments for each collection in the receiver.

o  with: aCollection collect: aTwoArgBlock
evaluate the argument, aBlock for successive elements from
each the receiver and the argument, aSequenceableCollection;
The second argument, aBlock must be a two-argument block, which is
evaluated for each element-pair.
Collect the results and return a collection containing them.
This method fails if neither the receiver nor aCollection is
a sequenceable collection (i.e. implements numeric key access).

o  with: aCollection count: aTwoArgBlock
evaluate the argument, aBlock for successive elements from
each the receiver and the argument, aSequenceableCollection.
Count, how often the second argument, aTwoArgBlock returns true.
This method fails if neither the receiver nor aCollection is
a sequenceable collection (i.e. implements numeric key access).

o  with: aCollection do: aTwoArgBlock
evaluate the argument, aBlock for successive elements from
each the receiver and the argument, aSequenceableCollection.
The second argument, aBlock must be a two-argument block.
This method fails if neither the receiver nor aCollection is
a sequenceable collection (i.e. implements numeric key access).

enumerating-tests
o  allSatisfy: aBlock
evaluate aBlock for each of the receiver's elements.
Return true, if aBlock returns true for all elements, false otherwise
(i.e. false if any element fails to satisfy the block-condition).
This is an ANSI renomer of #conform:

o  anySatisfy: aBlock
evaluate aBlock for each of the receiver's elements.
Return true, if aBlock ever returns true, false otherwise
(i.e. if any element satisfies the block-condition).
This is an ANSI renomer of #contains:

o  conform: aOneArgBlock
return true, if every element conforms to some condition.
I.e. return false, if aBlock returns false for any element;
true otherwise.

o  contains: aOneArgBlock
evaluate aOneArgBlock for each of the receiver's elements.
Return true, if aBlock ever returns true, false otherwise.

o  noneSatisfy: aBlock
evaluate aBlock for each of the receiver's elements.
Return true, if aBlock returns false for all elements, false otherwise
(i.e. false if any element satisfies the block-condition).

error handling
o  emptyCheck
check if the receiver is empty; report an error if so

o  emptyCollectionError
report an error that the operation is not allowed for
empty collections

o  errorInvalidKey: aKey
report an error that the given key was invalid

o  errorNotKeyed
report an error that keyed access methods are not allowed

o  errorValueNotFound: anObject
report an error that an object was not found in the collection

o  notEnoughElementsError
report an error that the operation is not allowed,
since not enough elements are in the collection

growing
o  changeCapacityTo: newSize

o  grow
make the receiver larger

o  grow: howBig
change the receivers size

** This method raises an error - it must be redefined in concrete classes **

o  growSize
return a suitable size increment for growing.
The default returned here may be (and is) redefined in subclasses.

inspecting
o  inspectorExtraAttributes
extra (pseudo instvar) entries to be shown in an inspector.

operations
o  decrementAt: aKey

o  incrementAt: aKey

printing & storing
o  displayString
return a printed representation of the receiver for display in inspectors etc.

o  displayStringName
redefinable helper for displayString

o  maxPrint
the print-limit; printOn: will try to not produce more output
than the limit defined here.

o  printElementsDo: aBlock
perform aBlock (1 arg) for all elements.
Used in #printOn:.
Subclasses (e.g. Dictionary) may redefine this.

o  printElementsOn: aStream
append a user readable representation of the receiver to aStream.
The text appended is not meant to be read back for reconstruction of
the receiver. Also, this method limits the size of generated string.

o  printOn: aStream
append a user readable representation of the receiver to aStream.
The text appended is not meant to be read back for reconstruction of
the receiver. Also, this method limits the size of generated string.

o  storeOn: aStream
output a printed representation onto the argument, aStream.
The text can be re-read to reconstruct (a copy of) the receiver.
Recursive (i.e. cyclic) collections cannot be stored correctly
(use storeBinaryOn: to handle those).

queries
o  defaultElement

o  largest: n
return the n largest elements

o  longestCommonPrefix
return the longest common prefix of my elements.
Typically used with string collections.

o  longestCommonPrefixIgnoreCase: ignoreCase
return the longest common prefix of my elements (which must be sequenceableCollections).
Typically used with string collections,
especially with completion of selectors or filenames.

o  longestCommonSuffix
return the longest common suffix (tail) of my elements.
Typically used with string collections.

o  longestCommonSuffixIgnoreCase: ignoreCase
return the longest common suffix (tail) of my elements
(which must be sequenceableCollections).

o  max
return the maximum value in the receiver collection,
using #< to compare elements.
Raises an error, if the receiver is empty.

o  min
return the minimum value in the receiver collection,
using < to compare elements.
Raises an error, if the receiver is empty.

o  minMax
return the minimum and maximum values in the receiver collection
as a two element array, using #< to compare elements.
Raises an error, if the receiver is empty.

o  nthLargest: n
return the n-largest element

o  size
return the number of elements in the receiver.
This is usually redefined in subclasses for more performance.

o  speciesForAdding
like species, but redefined for collections which cannot grow easily.
Used by functions which create a growing collection (see collect:with:, for example)

searching
o  findFirst: aBlock
find the index of the first element, for which evaluation of the argument, aBlock
returns true; return its index or 0 if none detected.
This is much like #detect, however, here an INDEX is returned,
while #detect returns the element.

set operations
o  \ aCollection
return a new set containing all elements of the receiver,
which are NOT also contained in the aCollection
For large collections you better use a Set for aCollection

o  intersect: aCollection
return a new set containing all elements of the receiver,
which are also contained in the argument collection.
For large collections you better use a Set for self

o  union: aCollection
return a new set containing all elements of the receiver
plus those of the aCollection

o  xor: aCollection
return a new set containing all elements,
which are contained in either the receiver or aCollection, but not in both.

For large collections you better use Sets for both self and aCollection

sorting & reordering
o  topologicalSort
Sort a partial ordered collection.
The receiver consists of tupels defining a partial order.
Use the algorithm by R. E. Tarjan from 1972.
Answer an OrderedCollection containing the sorted items

testing
o  capacity
return the number of elements, that the receiver is
prepared to take. For most collections, this is the actual
size. However, some have more space preallocated to allow
for faster adding of elements.
Not used by the system; added for ST-80 compatibility.

o  includes: anElement
return true, if an object equal to the argument, anObject is in the list.
This compares using #= (i.e. it does not look for the object itself,
instead, one that compares equal).
See #includesIdentical: when identity is asked for.
This is a *very* slow fallback - many subclasses redefine this for performance.

o  includesAll: aCollection
return true, if the the receiver includes all elements of
the argument, aCollection; false if any is missing.
Notice: this method has O-square runtime behavior and may be
slow for big receivers/args.
Think about using a Set, or Dictionary.

o  includesAny: aCollection
return true, if the the receiver includes any elements of
the argument, aCollection; false if it includes none.
Notice: this method has O^2(N) runtime behavior and may be
slow for big receivers/args.
Think about using a Set or Dictionary.
Some speedup is also possible, by arranging highly
probable elements towards the beginning of aCollection,
to avoid useless searches.

o  includesAnyIdentical: aCollection
return true, if the the receiver includes any elements of
the argument, aCollection; false if it includes none.
Use identity compare for comparing.
Notice: this method has O^2(N) runtime behavior and may be
slow for big receivers/args.
Think about using a Set or Dictionary.
Some speedup is also possible, by arranging highly
probable elements towards the beginning of aCollection,
to avoid useless searches.

o  includesIdentical: anElement
return true, if the argument, anObject is in the collection.
This compares using #== (i.e. object identity).
See #includes: when equality is asked for.
This is a *very* slow fallback - many subclasses redefine this for performance.

o  isCollection
return true, if the receiver is some kind of collection;
true is returned here - the method is redefined from Object.

o  isEmpty
return true, if the receiver is empty

o  isEmptyOrNil
return true if I am nil or an empty collection - true here, if the receivers size is 0,
(from Sqeak)

o  isNilOrEmptyCollection
return true if I am nil or an empty collection - false here.
Obsolete, use isEmptyOrNil.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  isNonByteCollection
return true, if the receiver is some kind of collection, but not a String, ByteArray etc.;
true is returned here - the method is redefined from Object.

o  isSorted
return true, if the receiver is sorted.
Collections which hold their elements in sorted order
should return true. Some algorithms (quicksort) degenerate when
operating on sorted collections and can be avoided if this information
is given. The default returned here (false) should not hurt.
I.e. you should NEVER depend on that in your application.

o  isSortedBy: aBlock
return true, if my elements are sorted (already) by the given criterion (sortBlock).
Collections which hold their elements in sorted order
should return true. Some algorithms (quicksort) degenerate when
operating on sorted collections and can be avoided if this information
is given. The default returned here (false) should not hurt.
I.e. you should NEVER depend on that in your application.

o  isSortedCollection
return true, if the receiver is a sortedCollection.

o  isWeakCollection
return true, if the receiver has weak references to its elements.

o  notEmpty
return true, if the receiver is not empty

o  notEmptyOrNil
Squeak compatibility:
return true if I am neither nil nor an empty collection.

o  occurrencesOf: anElement
return the number of occurrences of the argument, anElement in
the receiver. Uses #= (i.e. equality) compare.

o  occurrencesOfAny: aCollectionOfElements
return the number of occurrences of any in aCollectionOfElements in the receiver.
Uses #= (i.e. equality) compare.
Should be redefined in subclass(es) if ever used heavily.

tracing
o  traceInto: aRequestor level: level from: referrer
double dispatch into tracer, passing my type implicitely in the selector

visiting
o  acceptVisitor: aVisitor with: aParameter



ST/X 6.1.1; WebServer 1.620 at exept:8081; Thu, 17 May 2012 16:16:28 GMT