Crate compactmap [] [src]

A map-esque data structure that small integer keys for you on insertion. Key of removed entries are reused for new insertions. Underlying data is stored in a vector, keys are just indexes of that vector. The main trick is keeping in-place linked list of freed indexes for reuse.

Serde is supported. If you need pre-computed length at serialization time (for example, for bincode), use serde_ser_len feature.

If you are worried about losing strict typing advantages because of those usizes, you can use special wrapper

See also: Slab

Modules

wrapped

Special version of CompactMap that helps you not to confuse those usize tokens with something else

Macros

declare_compactmap_token

Create usize-equivalent struct that implements From<usize> and Into<usize>

Structs

CompactMap

A map that chooses small integer keys for you. You store something into this map and then access it by ID returned by it. For small V entries are expected to take 16 bytes.

Drain

A draining iterator over the key-value pairs of a map.

IntoIter

A consuming iterator over the key-value pairs of a map.

Iter

An iterator over the key-value pairs of a map.

IterMut

An iterator over the key-value pairs of a map, with the values being mutable.

Keys

An iterator over the keys of a map.

Values

An iterator over the values of a map.

ValuesMut

An iterator over the values of a map.