Discord.SortedSet.NifBridge (SortedSet v2.0.1) View Source
Discord.SortedSet.NifBridge is an internal implementation detail of the NIF backed
Discord.SortedSet.
This module exists to provide a clean separation between the FFI and API exposed to the end
user, see the Discord.SortedSet module for the public API.
There may be advanced use cases that find it useful to use the Discord.SortedSet.NifBridge
directly, but for most use-cases the Discord.SortedSet module provides a more conventional
interface.
Link to this section Summary
Functions
Adds an item to the SortedSet.
Appends a buckets worth of sorted terms to the SortedSet
Retrieve the item at the specified index
Returns a string representation of the underlying Rust data structure.
Creates an empty SortedSet.
Finds the index of the specified item
Creates a new SortedSet.
Removes an item from the SortedSet.
Gets the size of the SortedSet.
Retrieve a slice of starting at the start index and taking up to amount
Converts a SortedSet into a standard list
Link to this section Types
Specs
Link to this section Functions
Specs
add(set :: Discord.SortedSet.t(), item :: any()) :: Discord.SortedSet.Types.nif_add_result() | Discord.SortedSet.Types.common_errors()
Adds an item to the SortedSet.
Specs
append_bucket( set :: Discord.SortedSet.t(), terms :: [Discord.SortedSet.Types.supported_term()] ) :: :ok | Discord.SortedSet.Types.nif_append_bucket_result() | Discord.SortedSet.Types.common_errors()
Appends a buckets worth of sorted terms to the SortedSet
This is mostly an internal implementation detail, it is used to implement the
Discord.SortedSet.from_enumerable/2 and Discord.SortedSet.from_proper_enumerable/2
functions. The NIF will append a buckets worth of items without performing any checks on them.
This is a very efficient way to build the SortedSet but care must be taken since the call
circumvents the sorting and sanity checking logic. Use the constructors in Discord.ßSortedSet
for a safer and more ergonomic experience, use great care when calling this function directly.
Specs
at(set :: Discord.SortedSet.t(), index :: non_neg_integer()) :: Discord.SortedSet.Types.nif_at_result() | Discord.SortedSet.Types.common_errors()
Retrieve the item at the specified index
Specs
debug(set :: Discord.SortedSet.t()) :: String.t() | Discord.SortedSet.Types.common_errors()
Returns a string representation of the underlying Rust data structure.
This function is mostly provided as a convenience, since the actual data structure is stored in the NIF memory space it can be difficult to introspect the data structure as it changes. This function allows the caller to get the view of the data structure as Rust sees it.
Specs
empty(capacity :: pos_integer(), bucket_size :: pos_integer()) :: {:ok, Discord.SortedSet.t()}
Creates an empty SortedSet.
This is mostly an internal implementation detail, it is used to implement the
Discord.SortedSet.from_enumerable/2 and Discord.SortedSet.from_proper_enumerable/2
functions. The only valid operation that can be performed on an empty Discord.SortedSet is
append_bucket/2, all other functions expect that the bucket not be completely empty.
Specs
find_index(set :: Discord.SortedSet.t(), item :: any()) :: Discord.SortedSet.Types.nif_find_result() | Discord.SortedSet.Types.common_errors()
Finds the index of the specified item
Specs
jemalloc_allocation_info() ::
{:ok, jemalloc_allocation_data()} | {:error, any()}
Specs
new(capacity :: pos_integer(), bucket_size :: pos_integer()) :: {:ok, Discord.SortedSet.t()}
Creates a new SortedSet.
To prevent copying the set into and out of NIF space, the NIF returns an opaque reference handle that should be used in all subsequent calls to identify the SortedSet.
Specs
remove(set :: Discord.SortedSet.t(), item :: any()) :: Discord.SortedSet.Types.nif_remove_result() | Discord.SortedSet.Types.common_errors()
Removes an item from the SortedSet.
Specs
size(set :: Discord.SortedSet.t()) :: non_neg_integer()
Gets the size of the SortedSet.
This function follows the standard Elixir naming convention, size takes O(1) time as the size is tracked with every addition and removal.
Specs
slice( set :: Discord.SortedSet.t(), start :: non_neg_integer(), amount :: non_neg_integer() ) :: [any()] | Discord.SortedSet.Types.common_errors()
Retrieve a slice of starting at the start index and taking up to amount
Specs
to_list(set :: Discord.SortedSet.t()) :: [any()] | Discord.SortedSet.Types.common_errors()
Converts a SortedSet into a standard list
Note: This is potentially an expensive operation because it must copy the NIF data back into BEAM VM space.