Struct two_sided_vec::TwoSidedVec [] [src]

pub struct TwoSidedVec<T> { /* fields omitted */ }

A simple 'two sided' vector, that can grow both forwards and backwards.

The front and the back can be viewed as seperate and independent vectors, with negative indexing accessing the back and positive indexing accessing the front. This allows you to append to the back without modifying positive indexes. Unless you actually need pushing to the back to appear to shift the front forward, like VecDeque does, this negative index system will probably be better for your situation.

Internally this allows a much simpler and faster implementation, since there's only a single pointer to the middle that grows up and down. Internally, we have to reallocate the buffer if we run out of capacity in either the negative or positive difes grow separately and Although bounds checks are slightly slower since they involve two comparisons, the access itself should be just as fast.

Methods

impl<T> TwoSidedVec<T>
[src]

[src]

[src]

[src]

Take a slice of the front of this queue

[src]

Take a slice of the back of this queue

[src]

Take a mutable slice of the front of this queue

[src]

Take a mutable slice of the back of this queue

[src]

Take seperate slices of the back and the front of the vector respectively.

[src]

Take seperate mutable slices of the back and front of the vector respectively.

[src]

[src]

[src]

[src]

Push the specified value into the front of this queue, without modifying its end or touching the front of the queue.

This effectively preserves all positive indexes, which may or may not be useful for your situation.

[src]

[src]

[src]

[src]

[src]

Return the length of the entire vector, which is the sum of the lengths of the front and back parts.

The length isn't where the vector ends, since it could have elements in the back with negative indexes. Use vec.start() and vec.end() if you want to know the start and end indexes. The total length is exactly equivalent to vec.len_back() + vec.len_front()

[src]

[src]

Return the length of the back of the vector.

[src]

Return the length of the front of the vector

[src]

Give the (inclusive) start of the queue's elements. which may be negative if the queue's back isn't empty

This is exactly equivelant to -vec.back().len().

[src]

Give the (exclusive) end of the queue's elements, which may be less than the length if the queue's back contains some elements.

This is exactly equivalent to vec.front().len()

[src]

Return the [start, end) range of the element indices, equivalent to a tuple of (queue.start(), queue.end()).

[src]

Iterate over the entire vector, including both the back and front.

[src]

[src]

[src]

[src]

[src]

Give a raw pointer to the start of the elements

[src]

Give a raw pointer to the middle of the elements

[src]

[src]

[src]

Important traits for SignedEnumerate<I>
[src]

Enumerate the indices and values of the elements in the back of the vector.

The primary advantage over regular enumeration is that it gives proper negative indices since the elements are in the back.

Important traits for SignedEnumerate<I>
[src]

Enumerate the indices and values of the elements in the front of the vector.

The only possible advantage over regular enumeration is that it gives positive isize indices for consistency with enumeration over the back.

Important traits for SignedEnumerate<I>
[src]

Enumerate the indices and values of each element in the front and back.

The primary advantage over regular enumeration is that it gives proper negative indices for elements that are in the back.

Important traits for SignedEnumerate<I>
[src]

Mutably enumerate the indices and values of each element in the front and back.

The primary advantage over regular enumeration is that it gives proper negative indices for elements that are in the back.

[src]

[src]

Trait Implementations

impl<T> TwoSidedExtend<T> for TwoSidedVec<T>
[src]

[src]

[src]

impl<'a, T: Copy + 'a> TwoSidedExtend<&'a T> for TwoSidedVec<T>
[src]

[src]

[src]

impl<T: Clone> Clone for TwoSidedVec<T>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T> Default for TwoSidedVec<T>
[src]

[src]

Returns the "default value" for a type. Read more

impl<T: Debug> Debug for TwoSidedVec<T>
[src]

[src]

Formats the value using the given formatter. Read more

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

[src]

Executes the destructor for this type. Read more

impl<T, I: TwoSidedIndex<T>> Index<I> for TwoSidedVec<T>
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl<T, I: TwoSidedIndex<T>> IndexMut<I> for TwoSidedVec<T>
[src]

[src]

Performs the mutable indexing (container[index]) operation.

impl<T> From<Vec<T>> for TwoSidedVec<T>
[src]

[src]

Performs the conversion.

impl<T: PartialEq<U>, U> PartialEq<TwoSidedVec<U>> for TwoSidedVec<T>
[src]

[src]

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

1.0.0
[src]

This method tests for !=.

impl<T: Eq> Eq for TwoSidedVec<T>
[src]

impl<T: Hash> Hash for TwoSidedVec<T>
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

impl<T> !Send for TwoSidedVec<T>

impl<T> !Sync for TwoSidedVec<T>