#linked-list #doubly-linked-list #key-value-store

key-node-list

Doubly-linked list that stores key-node pairs

6 releases

Uses new Rust 2024

0.0.6 Nov 10, 2025
0.0.5 Jan 12, 2023
0.0.4 Jan 9, 2022
0.0.2 Dec 24, 2021

#531 in Data structures

Download history 281/week @ 2025-08-26 295/week @ 2025-09-02 300/week @ 2025-09-09 211/week @ 2025-09-16 255/week @ 2025-09-23 215/week @ 2025-09-30 257/week @ 2025-10-07 179/week @ 2025-10-14 192/week @ 2025-10-21 149/week @ 2025-10-28 265/week @ 2025-11-04 186/week @ 2025-11-11 243/week @ 2025-11-18 271/week @ 2025-11-25 335/week @ 2025-12-02 361/week @ 2025-12-09

1,238 downloads per month
Used in 2 crates

MIT/Apache

53KB
1K SLoC

key-node-list

github crates.io docs.rs build status

Doubly-linked list that stores key-node pairs.

KeyNodeList is a doubly-linked list, it uses a hash map to maintain correspondence between keys and nodes, and records the previous key and the next key of the current node in the node itself. There is no pointer operations during this process, so key_node_list is all implemented in safe Rust.

You can complete key lookups, key-node pair updates, key-node pair deletions and other operations of KeyNodeList in O(1)~ time. You can also use cursor-based interface to traverse or edit the linked list.

Usage

key_node_list is available on crates.io:

cargo add key-node-list

Example

use key_node_list::KeyValueList;

// construct key-value list from tuple array
let mut list = KeyValueList::from([(1, "Reimu"), (2, "Marisa")]);

// or pushing other key-value pairs to the front/back of list
list.push_front(0, "Alice").unwrap();
list.push_back(3, "Patchouli").unwrap();

// query nodes by key
assert_eq!(list[&1].value(), &"Reimu");
assert_eq!(list[&0].value(), &"Alice");

// also you can update nodes by key
*list.node_mut(&3).unwrap().value_mut() = "Youmu";
*list.front_node_mut().unwrap().value_mut() = "Mokou";
assert_eq!(list[&3].value(), &"Youmu");
assert_eq!(list[&0].value(), &"Mokou");
assert_eq!(list.front_node().unwrap().value(), &"Mokou");

// remove some key-node pairs
assert!(list.pop_front().is_some());
assert!(list.remove(&2).is_some());

// all key-node pairs are in order
list.push_back(5, "Yuyuko");
let vec: Vec<_> = list.into_iter().map(|(k, n)| (k, n.into_value())).collect();
assert_eq!(vec, [(1, "Reimu"), (3, "Youmu"), (5, "Yuyuko")]);

For more details, visit key_node_list on docs.rs.

Changelog

See CHANGELOG.md.

License

Copyright (C) 2021-2025 MaxXing. Licensed under either of Apache 2.0 or MIT at your option.

No runtime deps