Algorithms.h file
Namespaces
- namespace nCine
- Root namespace of nCine game engine.
Functions
- auto lerp(float a, float b, float ratio) -> float
- Linearly interpolates between two values by the given ratio.
-
auto lerp(std::
int32_t a, std:: int32_t b, float ratio) -> std:: int32_t - Linearly interpolates between two integers by the given ratio, rounding the result.
- auto lerpByTime(float a, float b, float ratio, float timeMult) -> float
- Frame-rate independent interpolation between two values.
-
auto copyStringFirst(char* dest,
std::
int32_t destSize, const char* source, std:: int32_t count = -1) -> std:: int32_t - Copies the beginning of a string into a fixed-size buffer, always null-terminating it.
-
template<std::auto copyStringFirst(char(&dest)[size], const char* source, std::
size_t size> int32_t count = -1) -> std:: int32_t - Copies the beginning of a string into a fixed-size array, deducing its size.
-
template<std::auto copyStringFirst(char(&dest)[size], Containers::
size_t size> StringView source) -> std:: int32_t - Copies the beginning of a string view into a fixed-size array, deducing its size.
-
auto formatString(char* buffer,
std::
size_t maxLen, const char* format, ...) -> std:: int32_t - Writes a
printf-style formatted string into a buffer. -
template<std::auto formatString(char(&dest)[size], const char* format, const TArg&... args) -> std::
size_t size, class ... TArg> int32_t - Writes a
printf-style formatted string into a fixed-size array, deducing its size. -
void u32tos(std::
uint32_t value, char* buffer) - Writes an unsigned 32-bit integer to a buffer as a decimal string.
-
void i32tos(std::
int32_t value, char* buffer) - Writes a signed 32-bit integer to a buffer as a decimal string.
-
void u64tos(std::
uint64_t value, char* buffer) - Writes an unsigned 64-bit integer to a buffer as a decimal string.
-
void i64tos(std::
int64_t value, char* buffer) - Writes a signed 64-bit integer to a buffer as a decimal string.
-
void ftos(double value,
char* buffer,
std::
int32_t bufferSize) - Writes a floating-point value to a buffer as a decimal string.
- auto isDigit(char c) -> bool constexpr
- Returns
trueif the character is a decimal digit. -
auto stou32(const char* str,
std::
size_t length) -> std:: uint32_t constexpr - Parses up to
lengthleading decimal digits into an unsigned 32-bit integer. -
auto stou64(const char* str,
std::
size_t length) -> std:: uint64_t constexpr - Parses up to
lengthleading decimal digits into an unsigned 64-bit integer. -
template<class Iter, class Compare>void sort(Iter begin, Iter end, Compare comp)
- Sorts the range in place using the given comparator.
-
template<class Iter>void sort(Iter begin, Iter end)
- Sorts the range in place into ascending order.
-
auto halfToFloat(std::
uint16_t value) -> float - Converts a 16-bit half-precision value to a single-precision float.
-
auto floatToHalf(float value) -> std::
uint16_t - Converts a single-precision float to a 16-bit half-precision value.
-
auto parseVersion(Containers::
StringView version) -> std:: uint64_t constexpr - Packs a dotted version string into a single 64-bit number.
-
template<class Iterator>static auto toBase64Url(const Iterator begin, const Iterator end) -> std::
string - Encodes the byte range into a URL-safe Base64 string (without padding).
-
auto crc32(Containers::
ArrayView<std:: uint8_t> data) -> std:: uint32_t - Returns the CRC-32 checksum of the given byte buffer.
-
auto crc32(IO::
Stream& stream) -> std:: uint32_t - Returns the CRC-32 checksum of the remaining contents of the given stream.