#cpp #emulation #map

cpp_map

A simple C++ std::map emulator

6 releases

Uses new Rust 2024

0.2.0 Dec 3, 2025
0.1.1 Jul 29, 2021
0.0.3 Jul 11, 2021

#1159 in Algorithms

Download history 33/week @ 2025-11-03 46/week @ 2025-11-10 35/week @ 2025-11-17 121/week @ 2025-11-24 55/week @ 2025-12-01 26/week @ 2025-12-08 25/week @ 2025-12-15 27/week @ 2025-12-22 13/week @ 2025-12-29 9/week @ 2026-01-05 7/week @ 2026-01-12 59/week @ 2026-01-19 44/week @ 2026-01-26 39/week @ 2026-02-02 11/week @ 2026-02-09 11/week @ 2026-02-16

107 downloads per month
Used in 5 crates (2 directly)

MIT/Apache

210KB
4.5K SLoC

Latest version Documentation workflow dependency status license

cpp_map.rs

C++ std::map Emulator for Rust

A simple C++ std::map emulator for Rust.

This library provides a data structure that emulates C++'s std::map, particularly its pointer-based cursors/iterators.

Key Features

  • Replicates C++ behavior where insert(key, value) is a no-op if the key exists (the new value isn't used)
  • Maintains pointer stability like C++'s std::map
  • Provides familiar C++-style iterator interface

Implementations

Skip List

  • O(log n) search and insert
  • O(1) sequential access

Linked List

  • O(n) search and insert
  • O(1) sequential access

Performance Note

For primarily position/hint-based operations, the linked list implementation will typically be faster.

Minimum Supported Rust Version (MSRV)

The minimum supported version of Rust for cpp_map is 1.87.0.

License

Licensed under either of

at your option.

Dependencies

~0.5–1MB
~21K SLoC