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

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

#988 in Algorithms

Download history 78/week @ 2024-08-01 49/week @ 2024-08-08 31/week @ 2024-08-15 21/week @ 2024-08-22 31/week @ 2024-08-29 25/week @ 2024-09-05 28/week @ 2024-09-12 82/week @ 2024-09-19 66/week @ 2024-09-26 29/week @ 2024-10-03 53/week @ 2024-10-10 126/week @ 2024-10-17 64/week @ 2024-10-24 91/week @ 2024-10-31 45/week @ 2024-11-07 66/week @ 2024-11-14

272 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–650KB
~11K SLoC