Back: CObject-testing functionality Up: Base classes Forward: Collection class-instance creation   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document

1.36 Collection

Defined in namespace Smalltalk
Superclass: Iterable
Category: Collections
I am an abstract class. My instances are collections of objects. My subclasses may place some restrictions or add some definitions to how the objects are stored or organized; I say nothing about this. I merely provide some object creation and access routines for general collections of objects.

1.36.1 Collection class: instance creation  (class)
1.36.2 Collection class: multibyte encodings  (class)
1.36.3 Collection: adding  (instance)
1.36.4 Collection: compiler  (instance)
1.36.5 Collection: concatenating  (instance)
1.36.6 Collection: converting  (instance)
1.36.7 Collection: copying Collections  (instance)
1.36.8 Collection: copying SequenceableCollections  (instance)
1.36.9 Collection: enumeration  (instance)
1.36.10 Collection: finalization  (instance)
1.36.11 Collection: printing  (instance)
1.36.12 Collection: removing  (instance)
1.36.13 Collection: sorting  (instance)
1.36.14 Collection: storing  (instance)
1.36.15 Collection: testing collections  (instance)


1.36.1 Collection class: instance creation

from: anArray
Convert anArray to an instance of the receiver. anArray is structured such that the instance can be conveniently and fully specified using brace-syntax, possibly by imposing some additional structure on anArray.

join: aCollection
Answer a collection formed by treating each element in aCollection as a `withAll:' argument collection to be added to a new instance.

with: anObject
Answer a collection whose only element is anObject

with: firstObject with: secondObject
Answer a collection whose only elements are the parameters in the order they were passed

with: firstObject with: secondObject with: thirdObject
Answer a collection whose only elements are the parameters in the order they were passed

with: firstObject with: secondObject with: thirdObject with: fourthObject
Answer a collection whose only elements are the parameters in the order they were passed

with: firstObject with: secondObject with: thirdObject with: fourthObject with: fifthObject
Answer a collection whose only elements are the parameters in the order they were passed

withAll: aCollection
Answer a collection whose elements are all those in aCollection


1.36.2 Collection class: multibyte encodings

isUnicode
Answer true; the receiver is able to store arbitrary Unicode characters.


1.36.3 Collection: adding

add: newObject
Add newObject to the receiver, answer it

addAll: aCollection
Adds all the elements of 'aCollection' to the receiver, answer aCollection


1.36.4 Collection: compiler

literalEquals: anObject
Not commented.

literalHash
Not commented.


1.36.5 Collection: concatenating

join
Answer a new collection like my first element, with all the elements (in order) of all my elements, which should be collections.

I use my first element instead of myself as a prototype because my elements are more likely to share the desired properties than I am, such as in:

#('hello, ' 'world') join => 'hello, world'


1.36.6 Collection: converting

asArray
Answer an Array containing all the elements in the receiver

asBag
Answer a Bag containing all the elements in the receiver

asByteArray
Answer a ByteArray containing all the elements in the receiver

asOrderedCollection
Answer an OrderedCollection containing all the elements in the receiver

asRunArray
Answer the receiver converted to a RunArray. If the receiver is not ordered the order of the elements in the RunArray might not be the #do: order.

asSet
Answer a Set containing all the elements in the receiver with no duplicates

asSortedCollection
Answer a SortedCollection containing all the elements in the receiver with the default sort block - [ :a :b | a <= b ]

asSortedCollection: aBlock
Answer a SortedCollection whose elements are the elements of the receiver, sorted according to the sort block aBlock

asString
Answer a String containing all the elements in the receiver

asUnicodeString
Answer a UnicodeString containing all the elements in the receiver


1.36.7 Collection: copying Collections

copyReplacing: targetObject withObject: newObject
Copy replacing each object which is = to targetObject with newObject

copyWith: newElement
Answer a copy of the receiver to which newElement is added

copyWithout: oldElement
Answer a copy of the receiver to which all occurrences of oldElement are removed


1.36.8 Collection: copying SequenceableCollections

, anIterable
Append anIterable at the end of a copy of the receiver (using #add:), and answer a new collection


1.36.9 Collection: enumeration

anyOne
Answer an unspecified element of the collection.

collect: aBlock
Answer a new instance of a Collection containing all the results of evaluating aBlock passing each of the receiver's elements

gather: aBlock
Answer a new instance of a Collection containing all the results of evaluating aBlock, joined together. aBlock should return collections. The result is the same kind as the first collection, returned by aBlock (as for #join).

readStream
Answer a stream that gives elements of the receiver

reject: aBlock
Answer a new instance of a Collection containing all the elements in the receiver which, when passed to aBlock, don't answer true

select: aBlock
Answer a new instance of a Collection containing all the elements in the receiver which, when passed to aBlock, answer true


1.36.10 Collection: finalization

mourn: anObject
Private - anObject has been found to have a weak key, remove it and possibly finalize the key.


1.36.11 Collection: printing

displayLines
Print each element of the receiver to a line on standard output.

examineOn: aStream
Print all the instance variables and objects in the receiver on aStream

printOn: aStream
Print a representation of the receiver on aStream


1.36.12 Collection: removing

empty
Remove everything from the receiver.

remove: oldObject
Remove oldObject from the receiver. If absent, fail, else answer oldObject.

remove: oldObject ifAbsent: anExceptionBlock
Remove oldObject from the receiver. If absent, evaluate anExceptionBlock and answer the result, else answer oldObject.

removeAll: aCollection
Remove each object in aCollection, answer aCollection, fail if some of them is absent. Warning: this could leave the collection in a semi-updated state.

removeAll: aCollection ifAbsent: aBlock
Remove each object in aCollection, answer aCollection; if some element is absent, pass it to aBlock.

removeAllSuchThat: aBlock
Remove from the receiver all objects for which aBlock returns true.


1.36.13 Collection: sorting

sorted
Return a sequenceable collection with the contents of the receiver sorted according to the default sort block, which uses #<= to compare items.

sorted: sortBlock
Return a sequenceable collection with the contents of the receiver sorted according to the given sort block, which accepts pair of items and returns true if the first item is less than the second one.


1.36.14 Collection: storing

storeOn: aStream
Store Smalltalk code compiling to the receiver on aStream


1.36.15 Collection: testing collections

capacity
Answer how many elements the receiver can hold before having to grow.

identityIncludes: anObject
Answer whether we include the anObject object

includes: anObject
Answer whether we include anObject

includesAllOf: aCollection
Answer whether we include all of the objects in aCollection

includesAnyOf: aCollection
Answer whether we include any of the objects in aCollection

isEmpty
Answer whether we are (still) empty

isSequenceable
Answer whether the receiver can be accessed by a numeric index with #at:/#at:put:.

notEmpty
Answer whether we include at least one object

occurrencesOf: anObject
Answer how many occurrences of anObject we include

size
Answer how many objects we include



Back: Collection-storing Up: Collection Forward: CompiledBlock   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document


This document was generated on April, 16 2013 using texi2html