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

= Introduction = See appendix A for formal definition.

= Method along consideration =

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

hashCode
Object.hashCode

Natural order - compareTo
Comparable#compareTo

compareTo
Comparable#compareTo

Comparable#equals

Map (Hashtable)
= Combination consideration =

equals and hashCode
Object.hashCode

TreeMap, equals and compareTo
= Maps, Hashtable and Set and Arrays =

HashMap's and Set's key
Immutable. keys are Uniformly distributed.

Sort
QuickSort MergeSort Stable sort Comparator TreeMap

= Miscellaneous =

Sorting with Comparator
Arrays.sort

= Appendix B =

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