<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 29, 2018 at 12:36 PM Nicolas Cellier <<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Is <span style="font-family:sans-serif">Interval = Array such an important feature?</span><div dir="auto">My opinion now is that we should rather abandon it.</div></div></blockquote><div><br></div><div>+1</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><div class="gmail_quote"><div dir="ltr">Le lun. 29 oct. 2018 à 01:16,  <<a href="mailto:commits@source.squeak.org" rel="noreferrer" target="_blank">commits@source.squeak.org</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Chris Cunningham uploaded a new version of Collections to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/Collections-cbc.810.mcz" rel="noreferrer noreferrer noreferrer" target="_blank">http://source.squeak.org/inbox/Collections-cbc.810.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Collections-cbc.810<br>
Author: cbc<br>
Time: 28 October 2018, 5:15:56.960512 pm<br>
UUID: 729c4dd2-f677-3c40-9ded-4a407a71f824<br>
Ancestors: Collections-topa.809<br>
<br>
Do NOT move to trunk!<br>
Various option for fixing the internval hash issue related to collectionsTests cbc.296.<br>
<br>
Some explanation to go to mailing list - this is so interested folks can try out the code.<br>
<br>
=============== Diff against Collections-topa.809 ===============<br>
<br>
Item was added:<br>
+ ----- Method: Array>>hashBetterFastIntervalCompatible (in category 'comparing') -----<br>
+ hashBetterFastIntervalCompatible<br>
+       | hash |<br>
+       self size < 48 ifTrue: [^super hash]. "Just check every element."<br>
+       hash := self species hash.<br>
+       1 to: 16 do: [:i| hash := (hash + (self at: i) hash) hashMultiply].<br>
+       self size - 15 to: self size do: [:i| hash := (hash + (self at: i) hash) hashMultiply].<br>
+       ^(hash + self size hash) hashMultiply!<br>
<br>
Item was added:<br>
+ ----- Method: Array>>hashFastIntervalCompatible (in category 'comparing') -----<br>
+ hashFastIntervalCompatible<br>
+       self size = 0 ifTrue: [^self species hash].<br>
+       ^(self species hash + <br>
+               (((((self at: 1) hash bitShift: 2)<br>
+                       bitOr: (self at: self size) hash)<br>
+                       bitShift: 1)<br>
+                       bitOr: self size)<br>
+               ) hashMultiply!<br>
<br>
Item was changed:<br>
  ----- Method: Interval>>hash (in category 'comparing') -----<br>
  hash<br>
        "Hash is reimplemented because = is implemented."<br>
<br>
        ^(((start hash bitShift: 2)<br>
                bitOr: stop hash)<br>
                bitShift: 1)<br>
                bitOr: self size!<br>
<br>
Item was added:<br>
+ ----- Method: Interval>>hashBetter (in category 'comparing') -----<br>
+ hashBetter<br>
+       "Hash is reimplemented because = is implemented."<br>
+ <br>
+       ^(((start hash bitShift: 2)<br>
+               bitOr: self last hash)<br>
+               bitShift: 1)<br>
+               bitOr: self size!<br>
<br>
Item was added:<br>
+ ----- Method: Interval>>hashBetterAlsoFixBug3380 (in category 'comparing') -----<br>
+ hashBetterAlsoFixBug3380<br>
+       "Hash is reimplemented because = is implemented."<br>
+       "Altered so that we has the same as self asArray hash"<br>
+       ^self inject: Array hash into: [:workingHash :each| (workingHash + each hash) hashMultiply ].!<br>
<br>
Item was added:<br>
+ ----- Method: Interval>>hashBetterFastArrayCompatible (in category 'comparing') -----<br>
+ hashBetterFastArrayCompatible<br>
+       | hash |<br>
+       self size < 48 ifTrue: [^self slowHash]. "Just check every element."<br>
+       hash := Array hash.<br>
+       1 to: 16 do: [:i| hash := (hash + (self at: i) hash) hashMultiply].<br>
+       self size - 15 to: self size do: [:i| hash := (hash + (self at: i) hash) hashMultiply].<br>
+       ^(hash + self size hash) hashMultiply!<br>
<br>
Item was added:<br>
+ ----- Method: Interval>>hashFastArrayCompatible (in category 'comparing') -----<br>
+ hashFastArrayCompatible<br>
+       "Hash is reimplemented because = is implemented."<br>
+       self size = 0 ifTrue: [^Array hash].<br>
+       ^(Array hash + <br>
+               ((((start hash bitShift: 2)<br>
+                       bitOr: self last hash)<br>
+                       bitShift: 1)<br>
+                       bitOr: self size)<br>
+               ) hashMultiply!<br>
<br>
Item was added:<br>
+ ----- Method: Interval>>hashSlowerBetterAlsoFixBug3380 (in category 'comparing') -----<br>
+ hashSlowerBetterAlsoFixBug3380<br>
+       "Hash is reimplemented because = is implemented."<br>
+       "Altered so that we has the same as self asArray hash"<br>
+       | hash |<br>
+ <br>
+       hash := Array hash.<br>
+       1 to: self size do: [:i | hash := (hash + (self at: i) hash) hashMultiply].<br>
+       ^hash!<br>
<br>
Item was added:<br>
+ ----- Method: Interval>>slowHash (in category 'comparing') -----<br>
+ slowHash<br>
+       "Hash is reimplemented because = is implemented."<br>
+       "Altered so that we has the same as self asArray hash"<br>
+       ^self inject: Array hash into: [:workingHash :each| (workingHash + each hash) hashMultiply ].!<br>
<br>
<br>
</blockquote></div>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div>