Java/Comparable: Difference between revisions
From charlesreid1
No edit summary |
No edit summary |
||
| Line 6: | Line 6: | ||
This is a generic type interface, and can be used to define a class that can be compared using custom criteria. For example, we can organize a list according to a very specific method of ordering (right-to-left, filling in with "ghost" titles, as in the [[Classy]] problem), or according to custom criteria like when a Cartesian (x,y) point would be visited by a space-filling curve, as with the [[Hilbert Sort]] problem. | This is a generic type interface, and can be used to define a class that can be compared using custom criteria. For example, we can organize a list according to a very specific method of ordering (right-to-left, filling in with "ghost" titles, as in the [[Classy]] problem), or according to custom criteria like when a Cartesian (x,y) point would be visited by a space-filling curve, as with the [[Hilbert Sort]] problem. | ||
{{CSFlag}} | |||
Revision as of 05:30, 11 June 2017
Comparable is the interface that is implemented in order for objects to be comparable using operators like < > == etc.
https://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html
This is a generic type interface, and can be used to define a class that can be compared using custom criteria. For example, we can organize a list according to a very specific method of ordering (right-to-left, filling in with "ghost" titles, as in the Classy problem), or according to custom criteria like when a Cartesian (x,y) point would be visited by a space-filling curve, as with the Hilbert Sort problem.
| Computer Science notes on computer science topics on the wiki, for educational and learning purposes
Part of the 2017 CS Study Plan.
Python/Exceptions · Python/Assertions · Python/Decorators Python/Os (os module) · Python/Strings Python/Splat · Python/Iterators · Python/Generators Python/Comparators · Python/Lambdas
Builtin features of Java: Java/Exceptions · Java/Assertions · Java/Memory · Java/Interfaces Java/Generics · Java/Decorators · Java/Diamond Notation Java/Iterators · Java/Iterable · Iterators vs Iterable Java/Comparators · Java/Comparable · Comparators vs Comparable Java/Numeric · Java/TypeChecking · Java/Testing · Java/Timing · Java/Profiling Documentation: Javadocs · Java/Documentation Tools and functionality: Java/URLs · Java/CSV External libraries: Guava · Fastutil · Eclipse Collections OOP: OOP Checklist · Java/Abstract Class · Java/Encapsulation · Java/Generics
|
See also: