Collection
Collection inherits from Object and defines no instance variables. It has subclasses Bag, KeyedCollection, and Set.
Collections are general purpose data structures. Growable collections are implemented using #become:.
Of interest are a few methods implemented here that are not part of some other Smalltalks:
#accumulate:into:
This is useful for concatenating several collections (usually Strings).
#allSatisfy: and #anySatisfy:
These work as generalized AND or OR statements. Some other Smalltalks call these #conform: and #contains: (respectively).
#do:separatedBy:
Like #do:, but evaluates the 'separatedBy' block between every evaluation of the 'do' block.
#select:do:
Like #select: followed by #do:, but avoids creating an intermediate collection.
Methods defined in Collection:
Methods for accessing:
- capacity
- size
Everyone reimplements this, so this implementation was removed to save space.
- species
Methods for adding/removing:
- add: collection
By default, collections do not support #add:.
- addAll: collection
- remove: object
- remove: object ifAbsent: exceptionBlock
- removeAll: collection
Methods for comparing:
- = collection
- hash
- shallowEquals: collection
Methods for converting:
- asArray
- asByteArray
- asList
- asSet
- asString
Methods for copying:
Methods for enumerating:
- accumulate: block into: collection
Evaluate block---which must return a collection---for each element of the receiver. Accumulate all results into the given collection.
- allSatisfy: block
#conform: in non-ANSI
- anySatisfy: block
#contains: in non-ANSI
- collect: block
- detect: block
- detect: block ifNone: exceptionBlock
- do: block
- do: block separatedBy: betweenBlock
- inject: initial into: block
Answer the last value of #scan:into:
- reject: block
#reject: is used much less frequently than #select:, so it is defined once here, in terms of #select:.
- select: block
This is implemented too differently in different subclasses to bother defining a default implementation here.
- select: block do: action
Like select: then do:, but avoids creating an intermediate collection.
Methods for predicates:
- identityIncludes: object
- includes: object
- isArrayed
- isEmpty
- notEmpty
Methods for streaming:
Pocket Smalltalk Documentation