| Crates.io | generational_array |
| lib.rs | generational_array |
| version | 0.1.1 |
| created_at | 2022-05-04 17:25:24.829038+00 |
| updated_at | 2022-05-04 19:18:23.612759+00 |
| description | A small package to handle generational arrays and prevent the ABA problem while reusing unused space |
| homepage | |
| repository | https://github.com/MaxoozX/generational_array |
| max_upload_size | |
| id | 580533 |
| size | 7,737 |
Using a generational array presents two main advantages :
This module provides a simple interface for working with generational arrays with almost no additionnal runtime complexity compared to a classic vector.
This module exposes 4 different types
| Name | Description |
|---|---|
GenerationalIndex |
Type representing an index in a generational array. It's made of an index (usize) and a generation (usize) See methods |
GenerationalArray |
Generic type representing the generational array |
GenerationalArrayResult |
Enum used when getting a reference to an item from the generational array See variants |
GenerationalArrayResultMut |
Enum used when getting a mutable reference to an item from the generational array See variants |
| Method | Use |
|---|---|
new |
Creates new instance of GenerationalArray |
insert |
Adds an element, takes the value as parameter and returns the index (GenerationalIndex) |
remove |
Removes an element, takes index as parameters and returns a Result<_, &'static str> |
get |
Get a reference to an element, takes index and returns GenerationalArrayResult |
get_mut |
Get a reference to an element, takes index and returns GenerationalArrayResultMut |
is_empty |
Whether the array is empty or not, returns bool |
size |
Returns the size (usize) of the array |
used_size |
Returns the actual number (usize) of not empty cells in the array |
| Variant | Meaning |
|---|---|
None |
The current index contains None |
OutDated |
The index's generation doesn't match with the current generation |
OutOfBounds |
The index is out of bounds |
Some |
The value has been found, mutable or not depending whether you called get or get_mut |