package com.github.vlsi.mat.optiq;

import org.eclipse.mat.snapshot.ISnapshot;
import org.eclipse.mat.snapshot.model.IObject;

public class HeapReference {
    private final ISnapshot snapshot;
    private final IObject o;

    public HeapReference(ISnapshot snapshot, IObject o) {
        this.snapshot = snapshot;
        this.o = o;
    }

    public IObject getIObject() {
        return o;
    }

    @Override
    public String toString() {
        String classSpecific = o.getClassSpecificName();
        if (classSpecific != null)
            return classSpecific;
        return o.getDisplayName();
    }
}

@@ -146,16 +146,53 @@
 eference
+ implements Comparable%3CHeapReference%3E
  %7B%0A    p
@@ -461,185 +461,931 @@
 lic 
-String toString() %7B%0A        String classSpecific = o.getClassSpecificName();%0A        if (classSpecific != null)%0A            return classSpecific;%0A        return o.getDisplayName
+boolean equals(Object o1) %7B%0A        if (this == o1) return true;%0A        if (o1 == null %7C%7C getClass() != o1.getClass()) return false;%0A%0A        HeapReference that = (HeapReference) o1;%0A%0A        if (!o.equals(that.o)) return false;%0A        if (!snapshot.equals(that.snapshot)) return false;%0A%0A        return true;%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        int result = snapshot.hashCode();%0A        result = 31 * result + o.hashCode();%0A        return result;%0A    %7D%0A%0A    @Override%0A    public String toString() %7B%0A        String classSpecific = o.getClassSpecificName();%0A        if (classSpecific != null)%0A            return classSpecific;%0A        return o.getDisplayName();%0A    %7D%0A%0A    @Override%0A    public int compareTo(HeapReference o) %7B%0A        int cmp = this.toString().compareTo(o.toString());%0A        if (cmp != 0)%0A            return cmp;%0A        return getIObject().getObjectId() - o.getIObject().getObjectId
 ();%0A

Add equals/hashCode/compareTo methods to HeapReference for proper grouping and sorting