Programming Search⌘K

std.mem

The entries of std.mem in the Zig reference. This page has 173 cards.

std.mem.alignInBytes

pub fn alignInBytes(bytes: []u8, comptime new_alignment: usize) ?[]align(new_alignment) u8

Returns the largest slice in the given bytes that conforms to the new alignment, or `null` if the given bytes contain no conforming address.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.alignInSlice

pub fn alignInSlice(slice: anytype, comptime new_alignment: usize) ?AlignedSlice(@TypeOf(slice), new_alignment)

Returns the largest sub-slice within the given slice that conforms to the new alignment, or `null` if the given slice contains no conforming address.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.bytesAsValue

pub fn bytesAsValue(comptime T: type, bytes: anytype) BytesAsValueReturnType(T, @TypeOf(bytes))

Given a pointer to an array of bytes, returns a pointer to a value of the specified type backed by those bytes, preserving pointer attributes.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.len

pub fn len(value: anytype) usize

Takes a sentinel-terminated pointer and iterates over the memory to find the sentinel and determine the length. `[*c]` pointers are assumed to be non-null and 0-terminated.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.readInt

pub fn readInt(comptime T: type, buffer: *const [@divExact(@typeInfo(T).int.bits, 8)]u8, endian: Endian) T

Reads an integer from memory with bit count specified by T. The bit count of T must be evenly divisible by 8.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.readVarPackedInt

pub fn readVarPackedInt(comptime T: type, bytes: []const u8, bit_offset: usize, bit_count: usize, endian: std.builtin.Endian, signedness: std.builtin.Signedness) T

Loads an integer from packed memory with provided bit_count, bit_offset, and signedness.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.replace

pub fn replace(comptime T: type, input: []const T, needle: []const T, replacement: []const T, output: []T) usize

Replace needle with replacement as many times as possible, writing to an output buffer which is assumed to be of appropriate size.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.sliceTo

pub fn sliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) SliceTo(@TypeOf(ptr), end)

Takes a pointer to an array, a many-item pointer, or a slice, and returns a slice of the items up to the first occurrence of `end`.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.sort

pub fn sort(comptime T: type, items: []T, context: anytype, comptime lessThanFn: fn (@TypeOf(context), lhs: T, rhs: T) bool) void

Sorts a slice in-place using a stable algorithm (maintains relative order of equal elements).

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.sortUnstable

pub fn sortUnstable(comptime T: type, items: []T, context: anytype, comptime lessThanFn: fn (@TypeOf(context), lhs: T, rhs: T) bool) void

Sorts a slice in-place using an unstable algorithm (does not preserve relative order of equal elements).

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.splitAny

pub fn splitAny(comptime T: type, buffer: []const T, delimiters: []const T) SplitIterator(T, .any)

Returns an iterator that iterates over the slices of `buffer` that are separated by any item in `delimiters`. `splitAny(u8, "abc,def||ghi", "|,")` will return slices for "abc", "def", "", "ghi", null, in that order.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.splitBackwardsAny

pub fn splitBackwardsAny(comptime T: type, buffer: []const T, delimiters: []const T) SplitBackwardsIterator(T, .any)

Returns an iterator that iterates backwards over the slices of `buffer` that are separated by any item in `delimiters`. `splitBackwardsAny(u8, "abc,def||ghi", "|,")` will return slices for "ghi", "", "def", "abc", null, in that order.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.splitBackwardsScalar

pub fn splitBackwardsScalar(comptime T: type, buffer: []const T, delimiter: T) SplitBackwardsIterator(T, .scalar)

Returns an iterator that iterates backwards over the slices of `buffer` that are separated by `delimiter`. `splitBackwardsScalar(u8, "abc|def||ghi", '|')` will return slices for "ghi", "", "def", "abc", null, in that order.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.splitScalar

pub fn splitScalar(comptime T: type, buffer: []const T, delimiter: T) SplitIterator(T, .scalar)

Returns an iterator that iterates over the slices of `buffer` that are separated by `delimiter`. `splitScalar(u8, "abc|def||ghi", '|')` will return slices for "abc", "def", "", "ghi", null, in that order.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.splitSequence

pub fn splitSequence(comptime T: type, buffer: []const T, delimiter: []const T) SplitIterator(T, .sequence)

Returns an iterator that iterates over the slices of `buffer` that are separated by the byte sequence in `delimiter`. `splitSequence(u8, "abc||def||||ghi", "||")` will return slices for "abc", "def", "", "ghi", null, in that order.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.tokenizeAny

pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) TokenIterator(T, .any)

Returns an iterator that iterates over the slices of `buffer` that are not any of the items in `delimiters`. `tokenizeAny(u8, " abc|def || ghi ", " |")` will return slices for "abc", "def", "ghi", null, in that order.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.tokenizeScalar

pub fn tokenizeScalar(comptime T: type, buffer: []const T, delimiter: T) TokenIterator(T, .scalar)

Returns an iterator that iterates over the slices of `buffer` that are not `delimiter`. `tokenizeScalar(u8, " abc def ghi ", ' ')` will return slices for "abc", "def", "ghi", null, in that order.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.

std.mem.tokenizeSequence

pub fn tokenizeSequence(comptime T: type, buffer: []const T, delimiter: []const T) TokenIterator(T, .sequence)

Returns an iterator that iterates over the slices of `buffer` that are not the sequence in `delimiter`. `tokenizeSequence(u8, "<>abc><def<><>ghi", "<>")` will return slices for "abc><def", "ghi", null, in that order.

Kind
function
Module
std.mem

Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.