BTreeMap
BTreeMap is an ordered key-value collection implemented with a balanced B-tree and supporting traversal in key order.
Learn Rust in a Month of Lunches
BTreeMap is Rust's ordered map collection that associates keys with values and iterates them in key order.
- How it is used
- Uses an ordered map when iteration must follow key order instead of HashMap’s unspecified order.
- How deep it goes
- Defines ordered iteration and demonstrates construction, insertion, and traversal, but defers the collection’s internal implementation.
- Examples
- Demonstrates a city population map keyed by years and prints entries in ascending key order.
- What you can do after
- Apply BTreeMap by creating one, inserting key-value pairs, and iterating over entries in key order.
Read how Learn Rust in a Month of Lunches explains BTreeMap →
Rust in Action: Systems programming concepts and techniques
A BTreeMap is a Rust ordered map that stores key-value pairs in a B-tree and supports ordered traversal.
- How it is used
- Uses BTreeMap when key order supports ordered iteration or selecting a range of entries.
- How deep it goes
- Demonstrates construction, insertion, ordered iteration, and range querying without explaining B-tree internals.
- Examples
- Shows six investments keyed by amount, printing them in order and selecting amounts below 500,000.
- What you can do after
- Apply it via std::collections::BTreeMap to iterate in key order and select entries with range.
Read how Rust in Action: Systems programming concepts and techniques explains BTreeMap →
Related concepts
- Mapalternative to · A map is an associative data structure that stores key-value pairs and supports retrieving values by key.
- data structurekind of · A data structure is an organized representation of data and its relationships that supports defined operations for storing, accessing, or modifying it.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

