Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0006943 [Squeak] Collections minor always 02-21-08 21:18 02-06-11 23:48
Reporter nicolas cellier View Status public  
Assigned To nicolas cellier
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version trunk Product Version 3.10
  Product Build
Summary 0006943: Heap equality should be associative
Description "This example shows that equality is not associative"

    | anArray heap1 heap2 |
    anArray := #(1 2 3).
    heap1 := Heap withAll: (1 to: 3) sortBlock: [:a :b | a < b].
    heap2 := Heap withAll: (1 to: 3) sortBlock: [:a :b | b > a].
    self assert: (heap1 = anArray) & (heap2 = anArray) ==> (heap1 = heap2)
Steps To Reproduce
Additional Information
Heaps do compare their sortBlock.
They are more relax when comparing with their species.

This does happen since their species is Array...
http://lists.squeakfoundation.org/pipermail/squeak-dev/2000-March/011043.html [^]

As noted by Klaus Witzel, why did species change?
Correcting which bug?
Attached Files  Heap-Equality-IsNotAssociative-M6943-Test.1.cs [^] (733 bytes) 02-21-08 21:28
 M6943-Heap-Equality-IsNotTransitive-Fix .1.cs [^] (831 bytes) 08-21-10 14:03

- Relationships

- Notes
(0011858 - 248 - 324 - 324 - 324 - 324 - 324)
nicolas cellier
02-21-08 22:12

I'm loosing my maths, #= should be an equivalence relation,

  reflexive, self assert: (a = a),
  symmetric, self assert: (a = b) ==> (b = a),
  transitive, self assert: (a = b) & (b = c) ==> (a = c)

Yes Transitive rather than Associative...
 
(0013836 - 326 - 359 - 359 - 359 - 359 - 359)
nicolas cellier
08-21-10 14:07

The fix makes Heap behave like a SortedCollection:
1) re-establish the Heap species -> Heap.
2) collect: does collect:as: Array because there is no guarantee the sortBlock works after transformation
3) select: use #copyEmpty strategy (like OrderedCollection)

Beware of load order, a Heap is used in your morphic world...
 
(0013837 - 117 - 123 - 453 - 453 - 453 - 453)
nicolas cellier
08-21-10 15:47

http://source.squeak.org/trunk/Collections-nice.370.mcz [^]
http://source.squeak.org/trunk/CollectionsTests-nice.170.mcz [^]
 

- Issue History
Date Modified Username Field Change
02-21-08 21:18 nicolas cellier New Issue
02-21-08 21:28 nicolas cellier File Added: Heap-Equality-IsNotAssociative-M6943-Test.1.cs
02-21-08 22:12 nicolas cellier Note Added: 0011858
08-21-10 14:03 nicolas cellier File Added: M6943-Heap-Equality-IsNotTransitive-Fix .1.cs
08-21-10 14:07 nicolas cellier Note Added: 0013836
08-21-10 15:47 nicolas cellier Status new => resolved
08-21-10 15:47 nicolas cellier Fixed in Version  => trunk
08-21-10 15:47 nicolas cellier Resolution open => fixed
08-21-10 15:47 nicolas cellier Assigned To  => nicolas cellier
08-21-10 15:47 nicolas cellier Note Added: 0013837
02-06-11 23:48 leves Status resolved => closed


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
49 total queries executed.
35 unique queries executed.
Powered by Mantis Bugtracker