kotlin.Comparable
Comparable
interface Comparable<in T>
Classes which inherit from this interface have a defined total ordering between their instances.
Functions
abstract operator fun compareTo(other: T): Int Compares this object with the specified object for order. Returns zero if this object is equal to the specified other object, a negative number if it's less than other, or a positive number if it's greater than other. |
Inherited Functions
open operator fun equals(other: Any?): Boolean Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements: | |
open fun hashCode(): Int Returns a hash code value for the object. The general contract of hashCode is: | |
open fun toString(): String Returns a string representation of the object. |
Extension Functions
fun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): T Ensures that this value is not less than the specified minimumValue. | |
fun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): T Ensures that this value is not greater than the specified maximumValue. | |
fun <T : Comparable<T>> T.coerceIn( minimumValue: T?, maximumValue: T? ): T Ensures that this value lies in the specified range minimumValue..maximumValue. fun <T : Comparable<T>> T.coerceIn( range: ClosedFloatingPointRange<T> ): T fun <T : Comparable<T>> T.coerceIn(range: ClosedRange<T>): T Ensures that this value lies in the specified range. | |
operator fun <T : Comparable<T>> T.rangeTo( that: T ): ClosedRange<T> Creates a range from this Comparable value to the specified that value. |
Inheritors
class Boolean : Comparable<Boolean> Represents a value which is either | |
class Byte : Number, Comparable<Byte> Represents a 8-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type | |
class Char : Comparable<Char> Represents a 16-bit Unicode character. On the JVM, non-nullable values of this type are represented as values of the primitive type | |
class Double : Number, Comparable<Double> Represents a double-precision 64-bit IEEE 754 floating point number. On the JVM, non-nullable values of this type are represented as values of the primitive type | |
abstract class Enum<E : Enum<E>> : Comparable<E> The common base class of all enum classes. See the Kotlin language documentation for more information on enum classes. | |
class Float : Number, Comparable<Float> Represents a single-precision 32-bit IEEE 754 floating point number. On the JVM, non-nullable values of this type are represented as values of the primitive type | |
class Int : Number, Comparable<Int> Represents a 32-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type | |
class KotlinVersion : Comparable<KotlinVersion> Represents a version of the Kotlin standard library. | |
class Long : Number, Comparable<Long> Represents a 64-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type | |
class Short : Number, Comparable<Short> Represents a 16-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type | |
class String : Comparable<String>, CharSequence The |
© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-comparable/