Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/steveklabnik/indexlist
indexlist: A doubly linked list, backed by a vector
https://github.com/steveklabnik/indexlist
data-structures rust
Last synced: 25 days ago
JSON representation
indexlist: A doubly linked list, backed by a vector
- Host: GitHub
- URL: https://github.com/steveklabnik/indexlist
- Owner: steveklabnik
- Created: 2018-09-14T21:23:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-08-30T21:42:40.000Z (over 1 year ago)
- Last Synced: 2024-11-27T17:46:59.672Z (about 1 month ago)
- Topics: data-structures, rust
- Language: Rust
- Size: 27.3 KB
- Stars: 83
- Watchers: 6
- Forks: 8
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `indexlist` - A doubly linked list, backed by a vector.
[![Build Status](https://travis-ci.org/steveklabnik/indexlist.svg?branch=master)](https://travis-ci.org/steveklabnik/indexlist) [![Build status](https://ci.appveyor.com/api/projects/status/baop9rw1tnd193or/branch/master?svg=true)](https://ci.appveyor.com/project/steveklabnik/indexlist/branch/master)
This crate provides a struct, `IndexList`, which is a doubly-linked
list. However, unlike a traditional linked list, which heap allocates
each of its nodes individually, all nodes are stored in a vector. Rather
than provide pointers to nodes, an `Index` struct can be used to access
a particular element in the middle of the list.# Safety
This crate uses `#![deny(unsafe_code)]` to ensure everything is implemented
in 100% Safe Rust.# Generational indexes
`Index` uses a generations scheme, so that if you hold an `Index` to a node,
and it's removed, and a new node is allocated in its place, you do not access
the new node.# Performance
In general, performance is quite good. Benchmarks against the standard library's
`LinkedList` are provided. But some other details:* The list keeps track of its head and tail for efficient insertion.
* The underlying vector only grows, never shrinks. When a node is removed, its
entry is marked as free for future insertions.
* Free entries are themselves kept as a singly-linked list, meaning that they
can be re-used efficiently.# Missing features
Right now, I've only implemented a minimal number of features; there's `iter`
but no `into_iter` and `iter_mut`. This is on the to-do list. PRs welcome!