A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-cmm.603.mcz ==================== Summary ==================== Name: Collections-cmm.603 Author: cmm Time: 11 February 2015, 2:38:57.218 pm UUID: 48d4fe0c-cde3-4244-b87f-2d44e3214240 Ancestors: Collections-mt.602 - Collection>>#groupBy:having: is already being used for non-Integer groups, and integerDictionary is now slower than a regular Dictionary in Spur. - PositionableStream>>#nextInto:, #next:into:, #nextInto:startingAt:, #next:into:startingAt:, and #readInto:startingAt:count require no services specific to PositionableStream. Move them up to Stream and remove the redundant implementations from various subclasses. - Let WeakArray>>#species be a regular Array instead of its own class, so that WeakArray's can be successfully compared to Arrays with equivalent contents. =============== Diff against Collections-mt.602 =============== Item was changed: ----- Method: Collection>>groupBy:having: (in category 'enumerating') ----- groupBy: keyBlock having: selectBlock + "Like in SQL operation - Split the recievers contents into collections of elements for which keyBlock returns the same results, and return those collections allowed by selectBlock." - "Like in SQL operation - Split the recievers contents into collections of - elements for which keyBlock returns the same results, and return those - collections allowed by selectBlock. keyBlock should return an Integer." | result | + result := Dictionary new. + self do: + [ : each | | key | + key := keyBlock value: each. + (result + at: key + ifAbsentPut: [ OrderedCollection new ]) add: each ]. + ^ result select: selectBlock! - result := PluggableDictionary integerDictionary. - self do: - [:e | - | key | - key := keyBlock value: e. - (result includesKey: key) - ifFalse: [result at: key put: OrderedCollection new]. - (result at: key) - add: e]. - ^result select: selectBlock! Item was removed: - ----- Method: NullStream>>next:into: (in category 'reading') ----- - next: n into: aCollection - "Read n objects into the given collection. - Return aCollection or a partial copy if less than - n elements have been read." - - ^self next: n into: aCollection startingAt: 1! Item was removed: - ----- Method: NullStream>>nextInto:startingAt: (in category 'reading') ----- - nextInto: aCollection startingAt: startIndex - "Read the next elements of the receiver into aCollection. - Return aCollection or a partial copy if less than aCollection - size elements have been read." - - ^self next: (aCollection size - startIndex+1) into: aCollection startingAt: startIndex.! Item was removed: - ----- Method: PositionableStream>>next:into: (in category 'accessing') ----- - next: n into: aCollection - "Read n objects into the given collection. - Return aCollection or a partial copy if less than - n elements have been read." - ^self next: n into: aCollection startingAt: 1! Item was removed: - ----- Method: PositionableStream>>next:into:startingAt: (in category 'accessing') ----- - next: n into: aCollection startingAt: startIndex - "Read n objects into the given collection. - Return aCollection or a partial copy if less than n elements have been read." - - | count | - count := self readInto: aCollection startingAt: startIndex count: n. - count = n - ifTrue:[ ^aCollection ] - ifFalse:[ ^aCollection copyFrom: 1 to: startIndex + count - 1 ]! Item was removed: - ----- Method: PositionableStream>>nextInto: (in category 'accessing') ----- - nextInto: aCollection - "Read the next elements of the receiver into aCollection. - Return aCollection or a partial copy if less than aCollection - size elements have been read." - ^self next: aCollection size into: aCollection startingAt: 1.! Item was removed: - ----- Method: PositionableStream>>nextInto:startingAt: (in category 'accessing') ----- - nextInto: aCollection startingAt: startIndex - "Read the next elements of the receiver into aCollection. - Return aCollection or a partial copy if less than aCollection - size elements have been read." - ^self next: (aCollection size - startIndex+1) into: aCollection startingAt: startIndex.! Item was removed: - ----- Method: PositionableStream>>readInto:startingAt:count: (in category 'accessing') ----- - readInto: aCollection startingAt: startIndex count: n - "Read n objects into the given collection. - Return number of elements that have been read." - | obj | - 0 to: n - 1 do: [:i | - (obj := self next) == nil ifTrue: [^i]. - aCollection at: startIndex + i put: obj]. - ^n! Item was added: + ----- Method: Stream>>next:into: (in category 'accessing') ----- + next: n into: aCollection + "Read n objects into the given collection. + Return aCollection or a partial copy if less than + n elements have been read." + ^self next: n into: aCollection startingAt: 1! Item was added: + ----- Method: Stream>>next:into:startingAt: (in category 'accessing') ----- + next: n into: aCollection startingAt: startIndex + "Read n objects into the given collection. + Return aCollection or a partial copy if less than n elements have been read." + + | count | + count := self readInto: aCollection startingAt: startIndex count: n. + count = n + ifTrue:[ ^aCollection ] + ifFalse:[ ^aCollection copyFrom: 1 to: startIndex + count - 1 ]! Item was added: + ----- Method: Stream>>nextInto: (in category 'accessing') ----- + nextInto: aCollection + "Read the next elements of the receiver into aCollection. + Return aCollection or a partial copy if less than aCollection + size elements have been read." + ^self next: aCollection size into: aCollection startingAt: 1.! Item was added: + ----- Method: Stream>>nextInto:startingAt: (in category 'accessing') ----- + nextInto: aCollection startingAt: startIndex + "Read the next elements of the receiver into aCollection. + Return aCollection or a partial copy if less than aCollection + size elements have been read." + ^self next: (aCollection size - startIndex+1) into: aCollection startingAt: startIndex.! Item was added: + ----- Method: Stream>>readInto:startingAt:count: (in category 'accessing') ----- + readInto: aCollection startingAt: startIndex count: n + "Read n objects into the given collection. + Return number of elements that have been read." + | obj | + 0 to: n - 1 do: [:i | + (obj := self next) == nil ifTrue: [^i]. + aCollection at: startIndex + i put: obj]. + ^n! Item was added: + ----- Method: WeakArray>>species (in category 'as yet unclassified') ----- + species + "More useful to have strongly-referenced results of #select: and #collect:." + ^ Array! |
Free forum by Nabble | Edit this page |