Discord.SortedSet.new

You're seeing just the function new, go back to Discord.SortedSet module for more information.
Link to this function

new(capacity \\ 500, bucket_size \\ 500)

View Source

Specs

new(capacity :: pos_integer(), bucket_size :: pos_integer()) ::
  t() | Discord.SortedSet.Types.common_errors()

Construct a new SortedSet with a given capacity and bucket size

See the README for more information about how SortedSet works.

Capacity

The caller can pre-allocate capacity for the data structure, this can be helpful when the initial set's size can be reasonably estimated. The pre-allocation will be for the buckets but not the contents of the buckets, so setting a high capacity and not using it is still memory efficient.

Bucket Size

Internally the SortedSet is a collection of sorted Buckets, this allows the SortedSet to out perform a simpler array of items. The default bucket size was chosen based off of benchmarking to select a size that performs well for most uses.

Returned Resource

Unlike a native Elixir data structure, the data in the SortedSet is held in the NIF's memory space, there are some important caveats to be aware of when using the SortedSet.

First, new/2 returns a reference/0 instead of a struct/0. This reference/0 can be used to access the SortedSet in subsequent calls.

Second, because the data is stored in the NIF's memory space, the data structure acts more like a mutable data structure than a standard immutable data structure. It's best to treat the reference/0 like one would treat an ETS tid.