toLongs
Executes the specified block of code, providing access to the uuid's bits in the form of two Long values.
This function is intended for use when one needs to perform bitwise operations with the uuid. For example, to retrieve the version number of this uuid:
val version = uuid.toLongs { mostSignificantBits, _ ->
((mostSignificantBits shr 12) and 0xF).toInt()
}
The action will receive two Long arguments:
mostSignificantBits
: The most significant 64 bits of this uuid presented in big-endian byte order.leastSignificantBits
: The least significant 64 bits of this uuid presented in big-endian byte order.
For example, for the uuid 550e8400-e29b-41d4-a716-446655440000
, the breakdown is the following:
mostSignificantBits = 0x550e8400e29b41d4L
.leastSignificantBits = 0xa716446655440000uL.toLong()
.
Since Kotlin
2.0Return
The result of action.
Parameters
A function that takes two Long arguments (mostSignificantBits, leastSignificantBits). This function is guaranteed to be called exactly once.