pub struct GapBuffer<T> { /* private fields */ }
Expand description
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.
Implementations§
Source§impl<T> GapBuffer<T>
impl<T> GapBuffer<T>
Sourcepub fn with_capacity(n: usize) -> GapBuffer<T>
pub fn with_capacity(n: usize) -> GapBuffer<T>
Constructs a GapBuffer with a given initial capacity.
Sourcepub fn get_mut(&mut self, i: usize) -> Option<&mut T>
pub fn get_mut(&mut self, i: usize) -> Option<&mut T>
Get a mutable reference to the element at the index.
Sourcepub fn swap(&mut self, i: usize, j: usize)
pub 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.
Sourcepub fn reserve(&mut self, additional: usize)
pub 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.
Trait Implementations§
Source§impl<A> Extend<A> for GapBuffer<A>
impl<A> Extend<A> for GapBuffer<A>
Source§fn extend<T: IntoIterator<Item = A>>(&mut self, iterator: T)
fn extend<T: IntoIterator<Item = A>>(&mut self, iterator: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<A> FromIterator<A> for GapBuffer<A>
impl<A> FromIterator<A> for GapBuffer<A>
Source§impl<A> Ord for GapBuffer<A>where
A: Ord,
impl<A> Ord for GapBuffer<A>where
A: Ord,
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<A> PartialOrd for GapBuffer<A>where
A: PartialOrd,
impl<A> PartialOrd for GapBuffer<A>where
A: PartialOrd,
impl<A> Eq for GapBuffer<A>where
A: Eq,
Auto Trait Implementations§
impl<T> Freeze for GapBuffer<T>
impl<T> RefUnwindSafe for GapBuffer<T>where
T: RefUnwindSafe,
impl<T> Send for GapBuffer<T>where
T: Send,
impl<T> Sync for GapBuffer<T>where
T: Sync,
impl<T> Unpin for GapBuffer<T>where
T: Unpin,
impl<T> UnwindSafe for GapBuffer<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more