Struct gapbuffer::GapBuffer
[−]
[src]
pub struct GapBuffer<T> { /* fields omitted */ }
A GapBuffer is a dynamic array which implements methods to shift the empty portion of the array around so that modifications can occur at any point in the array. It is optimized for data structures in which insertions and deletions tend to occur in sequence within the same area of the array, such as a buffer for a text editor.
Methods
impl<T> GapBuffer<T>
[src]
fn new() -> GapBuffer<T>
Constructs an empty GapBuffer.
fn with_capacity(n: usize) -> GapBuffer<T>
Constructs a GapBuffer with a given initial capacity.
fn get(&self, i: usize) -> Option<&T>
Get a reference to the element at the index.
fn get_mut(&mut self, i: usize) -> Option<&mut T>
Get a mutable reference to the element at the index.
fn swap(&mut self, i: usize, j: usize)
Swap the elements at the index. i and j may be equal.
Panics if there is no element with either index.
fn capacity(&self) -> usize
Get the capacity of the GapBuffer without expanding.
fn reserve(&mut self, additional: usize)
Reserve at least this much additional space for the GapBuffer. The collection may reserve more space to avoid frequent reallocations.
Panics if the new capacity overflows uint.
fn iter(&self) -> Items<T>
Get an iterator of this GapBuffer.
fn len(&self) -> usize
Get the length of the GapBuffer.
fn is_empty(&self) -> bool
Is the GapBuffer empty?
fn clear(&mut self)
Clears the buffer, removing all values.
fn insert(&mut self, i: usize, t: T)
Insert a new T at a given index (the gap will be shifted to that index).
Panics if i is greater than VecDeque's length.
fn remove(&mut self, i: usize) -> Option<T>
Removes and returns the element at position i from the gap buffer. The gap will be shifted to just before the index. Returns None if i is out of bounds.
Trait Implementations
impl<T: Clone> Clone for GapBuffer<T>
[src]
fn clone(&self) -> GapBuffer<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T: Default> Default for GapBuffer<T>
[src]
impl<A, B> PartialEq<GapBuffer<B>> for GapBuffer<A> where
A: PartialEq<B>,
[src]
A: PartialEq<B>,
fn eq(&self, other: &GapBuffer<B>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<A> Eq for GapBuffer<A> where
A: Eq,
[src]
A: Eq,
impl<A> PartialOrd for GapBuffer<A> where
A: PartialOrd,
[src]
A: PartialOrd,
fn partial_cmp(&self, other: &GapBuffer<A>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<A> Ord for GapBuffer<A> where
A: Ord,
[src]
A: Ord,
fn cmp(&self, other: &GapBuffer<A>) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl<A> FromIterator<A> for GapBuffer<A>
[src]
fn from_iter<I: IntoIterator<Item = A>>(iterator: I) -> GapBuffer<A>
Creates a value from an iterator. Read more
impl<A> Extend<A> for GapBuffer<A>
[src]
fn extend<T: IntoIterator<Item = A>>(&mut self, iterator: T)
Extends a collection with the contents of an iterator. Read more
impl<T> Debug for GapBuffer<T> where
T: Debug,
[src]
T: Debug,
impl<T> Index<usize> for GapBuffer<T>
[src]
type Output = T
The returned type after indexing
fn index<'a>(&'a self, index: usize) -> &'a T
The method for the indexing (container[index]
) operation