[squeak-dev] The Inbox: Collections-ct.873.mcz

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Fri Jan 31 10:55:39 UTC 2020


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.

<http://www.hpi.de/>

Best,
Christoph
________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von commits at source.squeak.org <commits at source.squeak.org>
Gesendet: Freitag, 31. Januar 2020 11:53:16
An: squeak-dev at lists.squeakfoundation.org
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!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200131/5871f1b5/attachment.html>


More information about the Squeak-dev mailing list