Struct indexlist::Index[][src]

pub struct Index { /* fields omitted */ }

A reference to an element in the list.

If you have an Index, you can get or remove the item at that position in the list.

Generational indexes

Index employs a "generational index" scheme. A "generation" is a counter, saved by the IndexList<T>. This counter increases whenever an item is removed from the list. Each item in the list keeps track of the generation it was inserted in.

An Index also keeps track of a generation. When you attempt to manipulate an item in the list via an Index, the generations are compared. If the Index's generation is older than the item at that position, it is stale, and so that item will not be returned or removed.

This scheme lets us re-use removed slots in the list, while ensuring that you won't see bad data.

Examples

You can get an Index by inserting something into the list:

extern crate indexlist;
 
use indexlist::IndexList;
 
let mut list = IndexList::new();
 
// this is an Index
let index = list.push_back(5);

You can also get one with index_of:

extern crate indexlist;
 
use indexlist::IndexList;
 
let mut list = IndexList::new();
 
let five = list.push_back(5);
 
let index = list.index_of(&5);
 
assert_eq!(Some(five), index);

Trait Implementations

impl Debug for Index
[src]

Formats the value using the given formatter. Read more

impl Copy for Index
[src]

impl Clone for Index
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for Index
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

impl Send for Index

impl Sync for Index