Class Collection Magnitude Methods Collection isEmpty ^ self size == 0 ] Methods Collection printString ^ ( self inject: self class printString , ' (' into: [:x :y | x , ' ' , y printString]), ' )' ] Methods Collection sort ^ self sort: [:x :y | x < y ] ] Methods Collection includes: value self do: [:x | (x = value) ifTrue: [ ^ true ] ]. ^ false ] Methods Collection = coll self do: [:x | (self occurrencesOf: x) = (coll occurrencesOf: x) ifFalse: [ ^ false ] ]. ^ true ] Methods Collection asString ^ self asByteArray asString ] Methods Collection size ^ self inject: 0 into: [:x :y | x + 1] ] Methods Collection < coll (coll respondsTo: #includes:) ifFalse: [ ^ smalltalk error: 'collection compared to non collection']. self do: [:x | ((self occurrencesOf: x) < (coll occurrencesOf: x))ifFalse: [ ^ false ]]. coll do: [:x | (self includes: x) ifFalse: [ ^ true ]]. ^ false ] Methods Collection asSet ^ Set new addAll: self ] Methods Collection asByteArray | newArray i | newArray <- ByteArray new size: self size. i <- 0. self do: [:x | i <- i + 1. newArray at: i put: x]. ^ newArray ] Methods Collection asArray | newArray i | newArray <- Array new: self size. i <- 0. self do: [:x | i <- i + 1. newArray at: i put: x]. ^ newArray ] Methods Collection display self do: [:x | x print ] ] Methods Collection inject: thisValue into: binaryBlock | last | last <- thisValue. self do: [:x | last <- binaryBlock value: last value: x]. ^ last ] Methods Collection occurrencesOf: anObject ^ self inject: 0 into: [:x :y | (y = anObject) ifTrue: [x + 1] ifFalse: [x] ] ] Methods Collection sort: aBlock ^ self inject: List new into: [:x :y | x add: y ordered: aBlock. x] ]