Struct bitmaptrie::Trie [] [src]

pub struct Trie<T> {
    // some fields omitted
}

Path-cached bitmap trie.

Caveats for *_with_cache() functions: - no way to prevent a PathCache being used with the wrong MultiCacheTrie instance: safety fail - structure-modifying writes are more expensive due to cache invalidation

Methods

impl<T> Trie<T>
[src]

fn new() -> Trie<T>

Instantiate a new Trie, indexed by a usize integer and storing values of type T.

fn set(&mut self, index: usize, value: T) -> &mut T

Set an entry to a value, moving the new value into the trie. Updates the internal path cache to point at this index.

fn get_default_mut<F>(&mut self, index: usize, default: F) -> &mut T where F: Fn() -> T

Retrieve a mutable reference to the value at the given index. If the index does not have an associated value, call the default function to generate a value for that index and return the reference to it. Updates the internal path cache to point at this index.

fn get_mut(&mut self, index: usize) -> Option<&mut T>

Retrieve a mutable reference to the value at the given index. Updates the internal path cache to point at this index.

fn get(&self, index: usize) -> Option<&T>

Retrieve a reference to the value at the given index. Updates the internal path cache to point at this index.

fn remove(&mut self, index: usize) -> Option<T>

Remove an entry, returning the associated value. Invalidates the internal path cache from the depth of tree modification out to the leaf if anything was removed.

fn retain_if<F>(&mut self, f: F) where F: FnMut(usize, &mut T) -> bool

Retains only the elements specified by the predicate. Invalidates the cache entirely.

fn iter(&self) -> Iter<T>

Create an iterator over immutable data

fn iter_mut(&mut self) -> IterMut<T>

Create an iterator over mutable data

impl<T: Send> Trie<T>
[src]

fn borrow_split(&mut self, n: usize) -> BorrowSplit<T>

Split the trie into at minimum n nodes (by doing a breadth-first search for the depth with at least that many interior nodes) and return an guard type that provides an iterator to iterate over the nodes. There is no upper bound on the number of nodes returned and less than n may be returned. The guard type, BorrowSplit, guards the lifetime of the mutable borrow, making this suitable for use in a scoped threading context. Invalidates the cache entirely.

fn prune(&mut self)

Cleans up any empty nodes that may be left dangling. This is only useful in conjunction with borrow_split() where sub-tries may be left empty but not deleted themselves and is entirely optional.

impl<T: Send + Sync> Trie<T>
[src]

fn borrow_sync(&mut self) -> BorrowSync<T>

Create a mutable borrow that gives a subset of functions that can be accessed across threads if T is Sync. Suitable only for a scoped thread as the lifetime of the BorrowSync instance is not 'static but the same duration as the borrow. Each borrow contains it's own path cache.

Trait Implementations

impl<T: Send> Send for Trie<T>
[src]

impl<T> Drop for Trie<T>
[src]

fn drop(&mut self)

A method called when the value goes out of scope. Read more

impl<T> Index<usize> for Trie<T>
[src]

type Output = T

The returned type after indexing

fn index(&self, index: usize) -> &T

The method for the indexing (Foo[Bar]) operation

impl<T> IndexMut<usize> for Trie<T>
[src]

fn index_mut(&mut self, index: usize) -> &mut T

The method for the indexing (Foo[Bar]) operation