User:Alexsmail/Computer programming/How Objects should be correctly compared in Java

Introduction edit

See appendix A for formal definition.

Method along consideration edit

equals() edit

Object hirerachy and its state (getClass() or instanceof ?). Immutable object. Object.equals()

hashCode() edit

Object.hashCode()

Natural order - compareTo() edit

Comparable#compareTo()

compareTo() edit

Comparable#compareTo()

Comparable#equals()

Map (Hashtable) edit

Combination consideration edit

equals() and hashCode() edit

Object.hashCode()

equals() and compareTo() edit

equals() and compareTo() and hashCode() edit

HashMap, equals() and compareTo() edit

TreeMap, equals() and compareTo() edit

Maps, Hashtable and Set and Arrays edit

HashMap's and Set's key edit

Immutable. keys are Uniformly distributed.

TreeMap vs HashMap edit

Sort edit

QuickSort MergeSort Stable sort Comparator TreeMap


Miscellaneous edit

signum function edit

Sorting with Comparator edit

Arrays.sort()


Appendix B edit

Mathematic background edit

Set Order pair Relation Relation over Set Two-place relation function function in Java Partial Order Full order Equivalence relation Equivalence class