MCPcopy Index your code
hub / github.com/droundy/tinyset

github.com/droundy/tinyset @0.5.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.5.2 ↗ · + Follow
370 symbols 956 edges 15 files 42 documented · 11%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Build Status Build status Crates.io version

Read the documentation.

tinyset

tinyset contains a few collections that are optimized to scale in size well for small numbers of elements, while still scaling well in time (and size) for numbers of elements. We now have just a few types that you might care for.

  1. [Set64] is a set for types that are 64 bits in size or less and are Copy, intended for essentially integer types. This is our most efficient type, since it can store small sets with just the size of one pointer, with no heap storage.

  2. [SetU64] just holds u64 items, and is the internal storage of [Set64].

  3. [SetU32] just holds u32 items, and can use a bit less memory than [SetU64].

  4. [SetUsize] holds usize items, and uses either [SetU64] or [SetU32] internally.

All of these set types will do no heap allocation for small sets of small elements. On 64-bit systems, each set will store up to seven elements with no heap allocation, if the elements are small. The more elements there are, the smaller they need to be. For details of implementation, see [SetU64].

These sets all differ from the standard sets in that they iterate over items rather than references to items, because they do not store values directly in a way that can be referenced. All of the type-specific sets further differ in that remove and contains accept values rather than references.

This crate has an optional dependency on the rand crate (enabled by default), used for randomization to avoid DOS collision attacks. You can speed up your compile (or use it on a platform unsupported by rand) by disabling this feature with

tinyset = { version = "0.4", default-features = false }

which will result in using a very simple pseudorandom number generator seeded by the system time.

There is another feature deterministic_ieration which conflicts with rand, which causes the order of iteration to be deterministic, i.e. the order of iteration through a set will only depend on the sequence of insertions and deletions from that set.

There is a second optional dependency on serde, which serializes sets in non-compressed form.

tinyset = { version = "0.4.13", features = ["serde"] }

to enable this feature.

There is also an experimental feature compactserde which serializes in a compact form identical to what is held in memory. The format used, however, is not stable, so you cannot expect your serialized sets to be readable by a different version of tinyset. If you would like to have a stable and compact serialized format, please file an issue. Note also that a corrupt (or malicious) file could easily trigger undefined behavior, besides just triggering incorrect and confusing behavior.

Benchmarks

To run the benchmark suite, run

cargo bench

This will give you loads of timings and storage requirements for a wide variety of set types.

Extension points exported contracts — how you extend this code

CopySet (Interface)
(no doc) [6 implementers]
src/copyset.rs
Fits64 (Interface)
This describes a type which can be stored in 64 bits without loss. It is defined for all signed and unsigned integer typ [1 …
src/set64.rs

Core symbols most depended-on inside this repo

iter
called by 187
src/set64.rs
insert
called by 126
src/set64.rs
remove
called by 115
src/set64.rs
len
called by 48
src/set64.rs
len
called by 28
src/setu32.rs
unwrap
called by 27
src/setu32.rs
into_iter
called by 26
src/set64.rs
iter
called by 25
src/setu32b.rs

Shape

Method 205
Function 126
Class 25
Enum 12
Interface 2

Languages

Rust100%

Modules by API surface

src/setu64.rs91 symbols
src/setu32.rs87 symbols
src/setu32b.rs65 symbols
src/set64.rs38 symbols
src/setusize.rs30 symbols
benches/bench.rs14 symbols
src/setu64/iter.rs12 symbols
src/setu32/iter.rs12 symbols
src/copyset.rs8 symbols
david_allocator/src/lib.rs8 symbols
src/rand.rs3 symbols
tests/issue-21.rs1 symbols

For agents

$ claude mcp add tinyset \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact