Struct bytes::Rope
[−]
[src]
pub struct Rope { /* fields omitted */ }
An immutable sequence of bytes formed by concatenation of other ByteStr
values, without copying the data in the pieces. The concatenation is
represented as a tree whose leaf nodes are each a Bytes
value.
Most of the operation here is inspired by the now-famous paper Ropes: an Alternative to Strings. hans-j. boehm, russ atkinson and michael plass.
Fundamentally the Rope algorithm represents the collection of pieces as a binary tree. BAP95 uses a Fibonacci bound relating depth to a minimum sequence length, sequences that are too short relative to their depth cause a tree rebalance. More precisely, a tree of depth d is "balanced" in the terminology of BAP95 if its length is at least F(d+2), where F(n) is the n-the Fibonacci number. Thus for depths 0, 1, 2, 3, 4, 5,... we have minimum lengths 1, 2, 3, 5, 8, 13,...
Methods
impl Rope
[src]
fn from_slice(bytes: &[u8]) -> Rope
fn of<B: ByteStr + 'static>(bytes: B) -> Rope
Returns a Rope consisting of the supplied Bytes as a single segment.
fn len(&self) -> usize
fn is_empty(&self) -> bool
Trait Implementations
impl ByteStr for Rope
[src]
type Buf = RopeBuf
fn buf(&self) -> RopeBuf
Returns a read-only Buf
for accessing the byte contents of the ByteStr
. Read more
fn concat<B: ByteStr + 'static>(&self, other: &B) -> Bytes
Returns a new Bytes
value representing the concatenation of self
with the given Bytes
. Read more
fn len(&self) -> usize
Returns the number of bytes in the ByteStr
fn slice(&self, begin: usize, end: usize) -> Bytes
Returns a new ByteStr value containing the byte range between begin
(inclusive) and end
(exclusive) Read more
fn is_empty(&self) -> bool
Returns true if the length of the ByteStr
is 0
fn slice_from(&self, begin: usize) -> Bytes
Returns a new ByteStr value containing the byte range starting from begin
(inclusive) to the end of the byte str. Read more
fn slice_to(&self, end: usize) -> Bytes
Returns a new ByteStr value containing the byte range from the start up to end
(exclusive). Read more
fn split_at(&self, mid: usize) -> (Bytes, Bytes)
Divides the value into two Bytes
at the given index. Read more
impl ToBytes for Rope
[src]
fn to_bytes(self) -> Bytes
Consumes the value and returns a Bytes
instance containing identical bytes Read more
impl Index<usize> for Rope
[src]
type Output = u8
The returned type after indexing
fn index(&self, index: usize) -> &u8
The method for the indexing (container[index]
) operation
impl Clone for Rope
[src]
fn clone(&self) -> Rope
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