The Inbox: Collections-ct.873.mcz

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

The Inbox: Collections-ct.873.mcz

commits-2
Christoph Thiede uploaded a new version of Collections to project The Inbox:
http://source.squeak.org/inbox/Collections-ct.873.mcz

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

Name: Collections-ct.873
Author: ct
Time: 31 January 2020, 11:53:15.549625 am
UUID: 431b3440-c343-7949-b8c4-c5627d640b36
Ancestors: Collections-nice.870

Extends #atLast: protocol on SequenceableCollection by implementing complete ifPresent:Absent: pattern.

See also Collections-ct.872.

=============== Diff against Collections-nice.870 ===============

Item was changed:
  ----- Method: SequenceableCollection>>atLast:ifAbsent: (in category 'accessing') -----
+ atLast: indexFromEnd ifAbsent: aBlock
- atLast: indexFromEnd ifAbsent: block
- "Return element at indexFromEnd from the last position.
- atLast: 1 ifAbsent: [] returns the last element"
 
+ ^ self
+ atLast: indexFromEnd
+ ifPresent: [:element | element]
+ ifAbsent: aBlock!
- ^ self at: self size + 1 - indexFromEnd ifAbsent: block!

Item was added:
+ ----- Method: SequenceableCollection>>atLast:ifPresent: (in category 'accessing') -----
+ atLast: indexFromEnd ifPresent: elementBlock
+
+ ^ self
+ at: self size + 1 - indexFromEnd
+ ifPresent: elementBlock
+ ifAbsent: []!

Item was added:
+ ----- Method: SequenceableCollection>>atLast:ifPresent:ifAbsent: (in category 'accessing') -----
+ atLast: indexFromEnd ifPresent: elementBlock ifAbsent: exceptionBlock
+ "Answer the value of elementBlock on the element at indexFromEnd from the last position. If the receiver does not contain an element at this position, answer the result of evaluating exceptionBlock."
+
+ ^ self
+ at: self size + 1 - indexFromEnd
+ ifPresent: elementBlock
+ ifAbsent: exceptionBlock!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Collections-ct.873.mcz

Christoph Thiede

Now a possible question could be whether we favor deduplication over performance, for example in the #atLast:ifAbsent:. Opinions? :-)


Tests will be added on request.


Best,
Christoph

Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Freitag, 31. Januar 2020 11:53:16
An: [hidden email]
Betreff: [squeak-dev] The Inbox: Collections-ct.873.mcz
 
Christoph Thiede uploaded a new version of Collections to project The Inbox:
http://source.squeak.org/inbox/Collections-ct.873.mcz

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

Name: Collections-ct.873
Author: ct
Time: 31 January 2020, 11:53:15.549625 am
UUID: 431b3440-c343-7949-b8c4-c5627d640b36
Ancestors: Collections-nice.870

Extends #atLast: protocol on SequenceableCollection by implementing complete ifPresent:Absent: pattern.

See also Collections-ct.872.

=============== Diff against Collections-nice.870 ===============

Item was changed:
  ----- Method: SequenceableCollection>>atLast:ifAbsent: (in category 'accessing') -----
+ atLast: indexFromEnd ifAbsent: aBlock
- atLast: indexFromEnd ifAbsent: block
-        "Return element at indexFromEnd from the last position.
-         atLast: 1 ifAbsent: [] returns the last element"
 
+        ^ self
+                atLast: indexFromEnd
+                ifPresent: [:element | element]
+                ifAbsent: aBlock!
-        ^ self at: self size + 1 - indexFromEnd ifAbsent: block!

Item was added:
+ ----- Method: SequenceableCollection>>atLast:ifPresent: (in category 'accessing') -----
+ atLast: indexFromEnd ifPresent: elementBlock
+
+        ^ self
+                at: self size + 1 - indexFromEnd
+                ifPresent: elementBlock
+                ifAbsent: []!

Item was added:
+ ----- Method: SequenceableCollection>>atLast:ifPresent:ifAbsent: (in category 'accessing') -----
+ atLast: indexFromEnd ifPresent: elementBlock ifAbsent: exceptionBlock
+        "Answer the value of elementBlock on the element at indexFromEnd from the last position. If the receiver does not contain an element at this position, answer the result of evaluating exceptionBlock."
+
+        ^ self
+                at: self size + 1 - indexFromEnd
+                ifPresent: elementBlock
+                ifAbsent: exceptionBlock!




Carpe Squeak!