Utils

Cubiomes.UtilsModule

Some utility functions and types that are used in various places in the codebase. It should not be used directly by the user and could be nice if this module does not exist at all.

source

Index

API

Cubiomes.Utils.length_of_trimmedMethod
length_of_trimmed(predicate, x) where N

Returns the length of the collection x after removing the elements from the beginning and the end that satisfy the predicate.

⚠ The collection must have the property so that x[i] for i in firstindex(x):lastindex(x) is valid.

source
Cubiomes.Utils.u64_seedFunction
u64_seed(x)

Converts x to UInt64 for use as a seed, exactly as the Minecraft Java Edition does. It can be any integer or a string.

Example

julia> u64_seed(1234)
0x00000000000004d2

julia> u64_seed("hello world")
0x000000006aefe2c4
source
Cubiomes.Utils.@only_float32Macro
@only_float32 expr

Transforms all real literals in the expr to Float32.

Example

@only_float32 function f()
    x = 1 + 2im # expand to `1.0f0 + 2.0f0im`
    x += 1 # expand to `x += 1.0f0`
    return x
end
source

Private API

Click to see
Cubiomes.Utils.bytes2uint64Method
bytes2uint64(itr)

Converts an iterator of bytes to an iterator of UInt64.

Example

julia> bytes2uint64([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10]) |> collect
2-element Vector{UInt64}:
0x0102030405060708
0x090a0b0c0d0e0f10
source
Cubiomes.Utils.findfirst_defaultMethod
findfirst_default(predicate::Function, A, default)

Return the first index i of A where predicate(A[i]) is true. If no i satisfy this, default is returned instead.

source