Three-way comparison
In computer science, a three-way comparison takes two values A and B belonging to a type with a total order and determines whether A < B, A = B, or A > B in a single operation, in accordance with the mathematical law of trichotomy.
It can be implemented in terms of a function (such as strcmp
in C), a method (such as compareTo
in Java), or an operator (such as the spaceship operator <=>
, in Perl and C++).
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.