Crate rblist

source ·
Expand description

rblist implemented a block based non-circular double-linked list. It is not multi-thread safe. Application should use a mutex to protect the list if it is used by multiple threads. Application can hold a reference to a node and use it to access the data directly. Application can also remove the node directly with the reference instead of going through the list. Example:

use rblist::{BList, Scale};

let mut list: BList<i32> = BList::new(Scale::default());
let node1 = list.push_back(1).unwrap();
let node3 = list.push_back(3).unwrap();
let node2 = list.insert_before(3, &node3).unwrap();

for x in list.iter() {
    println!("{}", *x.value().unwrap());
}

assert_eq!(list.len(), 3);
assert_eq!(*list.value(&node1).unwrap(), 1);
let v = list.remove(&node2).unwrap();
assert_eq!(v, 3);
assert_eq!(list.len(), 2);
let v = list.pop_front();
assert_eq!(v.unwrap(), 1);
assert_eq!(list.len(), 1);
assert_eq!(*list.front().unwrap(), 3);

Modules§

Macros§

  • Macro to create a BList from a list of elements #Example:

Structs§

Enums§