Implement unsigned comparisons
This commit is contained in:
@@ -28,28 +28,28 @@ public inline class UByte internal constructor(private val data: Byte) : Compara
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public override operator fun compareTo(other: UByte): Int = TODO()
|
||||
public override operator fun compareTo(other: UByte): Int = this.toUInt().compareTo(other.toUInt())
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public operator fun compareTo(other: UShort): Int = TODO()
|
||||
public operator fun compareTo(other: UShort): Int = this.toUInt().compareTo(other.toUInt())
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public operator fun compareTo(other: UInt): Int = TODO()
|
||||
public operator fun compareTo(other: UInt): Int = this.toUInt().compareTo(other)
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public operator fun compareTo(other: ULong): Int = TODO()
|
||||
public operator fun compareTo(other: ULong): Int = this.toULong().compareTo(other)
|
||||
|
||||
/** Adds the other value to this value. */
|
||||
public operator fun plus(other: UByte): UInt = TODO()
|
||||
|
||||
@@ -28,28 +28,28 @@ public inline class UInt internal constructor(private val data: Int) : Comparabl
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public operator fun compareTo(other: UByte): Int = TODO()
|
||||
public operator fun compareTo(other: UByte): Int = this.compareTo(other.toUInt())
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public operator fun compareTo(other: UShort): Int = TODO()
|
||||
public operator fun compareTo(other: UShort): Int = this.compareTo(other.toUInt())
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public override operator fun compareTo(other: UInt): Int = TODO()
|
||||
public override operator fun compareTo(other: UInt): Int = uintCompare(this.data, other.data)
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public operator fun compareTo(other: ULong): Int = TODO()
|
||||
public operator fun compareTo(other: ULong): Int = this.toULong().compareTo(other)
|
||||
|
||||
/** Adds the other value to this value. */
|
||||
public operator fun plus(other: UByte): UInt = TODO()
|
||||
|
||||
@@ -28,28 +28,28 @@ public inline class ULong internal constructor(private val data: Long) : Compara
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public operator fun compareTo(other: UByte): Int = TODO()
|
||||
public operator fun compareTo(other: UByte): Int = this.compareTo(other.toULong())
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public operator fun compareTo(other: UShort): Int = TODO()
|
||||
public operator fun compareTo(other: UShort): Int = this.compareTo(other.toULong())
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public operator fun compareTo(other: UInt): Int = TODO()
|
||||
public operator fun compareTo(other: UInt): Int = this.compareTo(other.toULong())
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public override operator fun compareTo(other: ULong): Int = TODO()
|
||||
public override operator fun compareTo(other: ULong): Int = ulongCompare(this.data, other.data)
|
||||
|
||||
/** Adds the other value to this value. */
|
||||
public operator fun plus(other: UByte): ULong = TODO()
|
||||
|
||||
@@ -28,28 +28,28 @@ public inline class UShort internal constructor(private val data: Short) : Compa
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public operator fun compareTo(other: UByte): Int = TODO()
|
||||
public operator fun compareTo(other: UByte): Int = this.toUInt().compareTo(other.toUInt())
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public override operator fun compareTo(other: UShort): Int = TODO()
|
||||
public override operator fun compareTo(other: UShort): Int = this.toUInt().compareTo(other.toUInt())
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public operator fun compareTo(other: UInt): Int = TODO()
|
||||
public operator fun compareTo(other: UInt): Int = this.toUInt().compareTo(other)
|
||||
|
||||
/**
|
||||
* Compares this value with the specified value for order.
|
||||
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
|
||||
* or a positive number if it's greater than other.
|
||||
*/
|
||||
public operator fun compareTo(other: ULong): Int = TODO()
|
||||
public operator fun compareTo(other: ULong): Int = this.toULong().compareTo(other)
|
||||
|
||||
/** Adds the other value to this value. */
|
||||
public operator fun plus(other: UByte): UInt = TODO()
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package kotlin
|
||||
|
||||
internal fun uintCompare(v1: Int, v2: Int): Int = (v1 xor Int.MIN_VALUE).compareTo(v2 xor Int.MIN_VALUE)
|
||||
internal fun ulongCompare(v1: Long, v2: Long): Int = (v1 xor Long.MIN_VALUE).compareTo(v2 xor Long.MIN_VALUE)
|
||||
Reference in New Issue
Block a user