[−][src]Crate 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.
-
Set64
is a set for types that are 64 bits in size or less and areCopy
, 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. -
SetU64
just holdsu64
items, and is the internal storage ofSet64
. -
SetU32
just holdsu32
items, and uses a bit less memory thanSetU64
. -
SetUsize
holdsusize
items, and uses either SetU64 or SetU32 internally.
All of these set types will do no heap allocation for small sets of
small elements. TinySet
will store up to 16 bytes of elements
before doing any heap allocation, while Set
stores sets up to size 8
without allocation. Set64
will store up to 22 bytes of elements,
and if all your elements are small (e.g. 0..22 as u64
it will store
them in as few bytes as possible.
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.
Examples
use tinyset::Set64; let mut s: Set64<usize> = Set64::new(); s.insert(1); assert!(s.contains(&1));
Re-exports
pub use setusize::SetUsize; |
pub use setu32::SetU32; |
pub use setu64::SetU64; |
pub use crate::set64::Set64; |
pub use crate::set64::Fits64; |
Modules
set64 | A set that is compact in size. |
setu32 | This is a crate for the tiniest sets ever. |
setu64 | This is a crate for the tiniest sets ever. |
setusize | A set that is compact in size. |