Chris Muller uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-cmm.608.mcz ==================== Summary ==================== Name: Collections-cmm.608 Author: cmm Time: 3 April 2015, 3:26:16.674 pm UUID: ff08c5f7-9d9e-4d4f-99e1-b5e52118e9fb Ancestors: Collections-ul.607, Collections-cmm.603 Merged cmm.603. =============== Diff against Collections-ul.607 =============== 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! Item was removed: - ----- Method: WeakKeyDictionary>>finalizeValues: (in category 'finalization') ----- - finalizeValues: finiObjects - "Remove all associations with key == nil and value is in finiObjects. - This method is folded with #rehash for efficiency." - - | oldArray | - self deprecated: 'The finalization logic changed, this method shouldn''t be called anymore.'. - oldArray := array. - array := Array new: oldArray size. - tally := 0. - 1 to: array size do: [ :index | - (oldArray at: index) ifNotNil: [ :association | - association key ifNotNil: [ :key | "Don't let the key go away" - (finiObjects includes: association value) ifFalse: [ - array - at: (self scanForEmptySlotFor: key) - put: association. - tally := tally + 1 ] ] ] ]! |
Free forum by Nabble | Edit this page |