#key-value #id #integer #order-id #maps #vec #automatic

idmap

Efficient maps of integer id keys to values, backed by an underlying Vec

24 releases

0.2.21 Sep 6, 2021
0.2.19 Jun 7, 2020
0.2.16 Aug 24, 2018
0.2.14 May 22, 2018
0.2.3 Oct 29, 2017

#898 in Algorithms

Download history 18/week @ 2024-06-17 22/week @ 2024-06-24 14/week @ 2024-07-08 10/week @ 2024-07-15 39/week @ 2024-07-22 174/week @ 2024-07-29 58/week @ 2024-08-05 30/week @ 2024-08-12 23/week @ 2024-08-19 33/week @ 2024-08-26 26/week @ 2024-09-02 22/week @ 2024-09-09 34/week @ 2024-09-16 113/week @ 2024-09-23 32/week @ 2024-09-30

207 downloads per month

MIT license

84KB
2K SLoC

rust-idmap Crates.io Documentation

Efficient maps of integer id keys to values, backed by an underlying Vec.

Features

  • Compiles on stable rust
    • I only officially support the latest stable ;)
  • Automatically derived IntegerId for enums and newtype structs
    • Implemented in the idmap-derive proc_macro crate
  • Maintains insertion order of the entries, as there's an indirection like OrderMap.
    • Therefore, entries which aren't present take little space, as only a u32 needs to be stored.
    • This indirection can be avoided with a DirectIdMap which doesn't preserve order, and saves space when the ids of the map's keys are densly packed and mostly present.

lib.rs:

Efficient maps of integer id keys to values, backed by an underlying Vec.

However, unless a CompactIdMap is used, space requirements are O(n) the largest key. Any type that implements IntegerId can be used for the key, but no storage is wasted if the key can be represented from the id.

Dependencies

~78–660KB
~11K SLoC