rblist

Crates.iorblist
lib.rsrblist
version0.1.0
sourcesrc
created_at2024-09-10 16:26:28.46811
updated_at2024-09-10 16:26:28.46811
descriptionA block-based, non-circular double-linked list implementation for Rust.
homepage
repositoryhttps://github.com/pecktalk/pex/tree/main/rblist
max_upload_size
id1370592
size92,224
Lorby (Lorby04)

documentation

README

rblist

Crates.io Docs.rs

A block-based, non-circular double-linked list implementation for Rust.

Overview

rblist is a block-based, non-circular double-linked list that allows for efficient manipulation of data. It supports standard operations such as inserting, removing, and iterating over elements. The crate is optimized for use cases where you need a high-performance list structure for quick inserting and deletion, but with some flexibility in managing nodes and data directly.

Features

  • Block-based architecture for better memory efficiency.
  • Support for inserting and removing elements by node reference.
  • Iterator support for traversing elements.
  • Simple and clean API for list manipulation.
  • Not multi-thread safe by design (can be protected with a mutex).

Example

Here is a basic example of how to use rblist:

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(2, &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, 2);
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);

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Installation

To use rblist in your project, add the following to your Cargo.toml:

[dependencies]
rblist = "0.1.x"
Commit count: 0

cargo fmt