Crates.io | rblist |
lib.rs | rblist |
version | 0.1.0 |
source | src |
created_at | 2024-09-10 16:26:28.46811 |
updated_at | 2024-09-10 16:26:28.46811 |
description | A block-based, non-circular double-linked list implementation for Rust. |
homepage | |
repository | https://github.com/pecktalk/pex/tree/main/rblist |
max_upload_size | |
id | 1370592 |
size | 92,224 |
A block-based, non-circular double-linked list implementation for Rust.
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.
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);
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.
To use rblist in your project, add the following to your Cargo.toml:
[dependencies]
rblist = "0.1.x"