Struct ropey::Rope [] [src]

pub struct Rope { /* fields omitted */ }

A rope data structure for storing text in a format that is efficient for insertion and removal even for extremely large strings.

Methods

impl Rope
[src]

Creates a new empty rope

Creates a new rope from a string slice

Creates a new rope from a string, consuming the string

Returns the number of graphemes between char indices pos_a and pos_b. This is not as simple as a subtraction of char_index_to_grapheme_index() calls, because the char indices may split graphemes. Runs in O(log N) time.

Returns the index of the grapheme that the given char index is a part of.

Returns the beginning char index of the given grapheme index.

Returns the index of the line that the given char index is on.

Returns the char index at the start of the given line index.

Inserts the given text at the given char index. For small lengths of 'text' runs in O(log N) time. For large lengths of 'text', dunno. But it seems to perform sub-linearly, at least.

Removes the text between the given char indices. For small distances between pos_a and pos_b runs in O(log N) time. For large distances, dunno. If it becomes a performance bottleneck, can special-case that to two splits and an append, which are all sublinear.

Splits a rope into two pieces from the given char index. The first piece remains in this rope, the second piece is returned as a new rope. I think this runs in O(log N) time, but this needs more analysis to be sure. It is at least sublinear.

Appends another rope to the end of this one, consuming the other rope. Runs in O(log N) time.

Makes a copy of the rope as a string. Runs in O(N) time.

Creates a chunk iterator for the rope

Creates a chunk iter starting at the chunk containing the given char index. Returns the chunk iter and its starting char index.

Creates an iterator at the first char of the rope

Creates an iterator starting at the given char index

Creates an iterator that starts at pos_a and stops just before pos_b.

Creates an iterator at the first grapheme of the rope

Creates an iterator at the given grapheme index

Creates an iterator that starts a pos_a and stops just before pos_b.

Creates an iterator over the lines in the rope.

Creates an iterator over the lines in the rope, starting at the given line index.

Trait Implementations

impl Debug for Rope
[src]

Formats the value using the given formatter.