The Trunk: Collections-ul.616.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-ul.616.mcz

commits-2
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.616.mcz

==================== Summary ====================

Name: Collections-ul.616
Author: ul
Time: 11 April 2015, 11:12:16.588 pm
UUID: ff292158-e8cd-4d21-aae6-c15135dd707f
Ancestors: Collections-bf.615

Optimized Interval >> #sum, OrderedCollection >> #at: and OrderedCollection >> #at:put:.

=============== Diff against Collections-bf.615 ===============

Item was changed:
  ----- Method: Interval>>sum (in category 'accessing') -----
  sum
+ "Optimized version. Use the sum(n * i - k, i=a..b) = -1/2 * (a - b - 1) * (n * (a + b) - 2 * k) equation with a = 1, n = step, b = self size and k = step - start."
- "Optimized version. Use the sum(n*i - k, i=a..b) = -1/2*(a - b - 1)*(n * (a + b) - 2 * k) equation with a = 1, n = step, b = self size."
 
  | b |
  b := self size.
+ ^b * ((b - 1) * step + (start * 2)) / 2!
- ^b * ((b + 1) * step - (step - start * 2)) / 2!

Item was changed:
  ----- Method: OrderedCollection>>at: (in category 'accessing') -----
  at: anInteger
  "Answer my element at index anInteger. at: is used by a knowledgeable
  client to access an existing element"
 
+ | index |
+ 1 <= anInteger ifFalse: [ self errorNoSuchElement ].
+ (index := anInteger + firstIndex - 1) <= lastIndex ifFalse: [ self errorNoSuchElement ].
+ ^array at: index!
- (anInteger < 1 or: [anInteger + firstIndex - 1 > lastIndex])
- ifTrue: [self errorNoSuchElement]
- ifFalse: [^ array at: anInteger + firstIndex - 1]!

Item was changed:
  ----- Method: OrderedCollection>>at:put: (in category 'accessing') -----
  at: anInteger put: anObject
  "Put anObject at element index anInteger. at:put: cannot be used to
  append, front or back, to an ordered collection; it is used by a
  knowledgeable client to replace an element."
 
+ | index |
+ 1 <= anInteger ifFalse: [ self errorNoSuchElement ].
+ (index := anInteger + firstIndex - 1) <= lastIndex ifFalse: [ self errorNoSuchElement ].
+ ^array at: index put: anObject!
- (anInteger < 1 or: [anInteger + firstIndex - 1 > lastIndex])
- ifTrue: [self errorNoSuchElement]
- ifFalse: [^array at: anInteger + firstIndex - 1 put: anObject]!