Struct bytes::str::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]

Returns a Rope consisting of the supplied Bytes as a single segment.

Trait Implementations

impl ByteStr for Rope
[src]

Returns a read-only Buf for accessing the byte contents of the ByteStr. Read more

Returns a new Bytes value representing the concatenation of self with the given Bytes. Read more

Returns the number of bytes in the ByteStr

Returns a new ByteStr value containing the byte range between begin (inclusive) and end (exclusive) Read more

Returns true if the length of the ByteStr is 0

Returns a new ByteStr value containing the byte range starting from begin (inclusive) to the end of the byte str. Read more

Returns a new ByteStr value containing the byte range from the start up to end (exclusive). Read more

Divides the value into two Bytes at the given index. Read more

impl ToBytes for Rope
[src]

Consumes the value and returns a Bytes instance containing identical bytes Read more

impl Index<usize> for Rope
[src]

The returned type after indexing

The method for the indexing (container[index]) operation

impl Clone for Rope
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a> Source for &'a Rope
[src]

impl<B: ByteStr> PartialEq<B> for Rope
[src]

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

This method tests for !=.