Const hint_max_leaf_char_len

uint

The maximal number of chars that should be permitted in a single node

This is not a strict value

Const hint_max_node_height

uint

The maximal height that should be permitted in a tree.

This is not a strict value

Type Concat

type Concat = {left: @Node, right: @Node, char_len: uint, byte_len: uint, height: uint,}

A node obtained from the concatenation of two other nodes

Fields

Type Leaf

type Leaf = {byte_offset: uint, byte_len: uint, char_len: uint, content: @~str,}

A text component in a rope.

This is actually a slice in a rope, so as to ensure maximal sharing.

Fields

Enum Node

Variants

Enum Root

Implementation of type rope

Variants

Function bal

fn bal(node: @Node) -> Option<@Node>

Balance a node.

Algorithm

Return value

Function byte_len

fn byte_len(node: @Node) -> uint

Function char_at

fn char_at(node: @Node, pos: uint) -> char

Arguments

Return value

The character at position pos

Safety notes

The function will fail if pos is not a valid position in the rope.

Performance note: This function executes in a time proportional to the height of the rope + the (bounded) length of the largest leaf.

Function char_len

fn char_len(node: @Node) -> uint

Function cmp

fn cmp(a: @Node, b: @Node) -> int

Function concat2

fn concat2(left: @Node, right: @Node) -> @Node

Function flatten

fn flatten(node: @Node) -> @Node

Replace a subtree by a single leaf with the same contents.

This function executes in linear time.

Function height

fn height(node: @Node) -> uint

Function loop_chars

fn loop_chars(node: @Node, it: fn&(c: char) -> bool) -> bool

Function loop_leaves

fn loop_leaves(node: @Node, it: fn&(Leaf) -> bool) -> bool

Loop through a node, leaf by leaf

Arguments

Arguments

true If execution proceeded correctly, false if it was interrupted, that is if it returned false at any point.

Function of_str

fn of_str(str: @~str) -> @Node

Adopt a string as a node.

If the string is longer than max_leaf_char_len, it is logically split between as many leaves as necessary. Regardless, the string itself is not copied.

Performance note: The complexity of this function is linear in the length of str.

Function of_substr

fn of_substr(str: @~str, byte_start: uint, byte_len: uint) -> @Node

Adopt a slice of a string as a node.

If the slice is longer than max_leaf_char_len, it is logically split between as many leaves as necessary. Regardless, the string itself is not copied

Arguments

Safety note

Behavior is undefined if byte_start or byte_len do not represent valid positions in str

Function of_substr_unsafer

fn of_substr_unsafer(str: @~str, byte_start: uint, byte_len: uint,
                     char_len: uint) -> @Node

Adopt a slice of a string as a node.

If the slice is longer than max_leaf_char_len, it is logically split between as many leaves as necessary. Regardless, the string itself is not copied

Arguments

Safety notes

Function serialize_node

fn serialize_node(node: @Node) -> ~str

Function sub_bytes

fn sub_bytes(node: @Node, byte_offset: uint, byte_len: uint) -> @Node

Compute the subnode of a node.

Arguments

Performance notes

Safety notes

This function fails if byte_offset or byte_len do not represent valid positions in node.

Function sub_chars

fn sub_chars(node: @Node, char_offset: uint, char_len: uint) -> @Node

Compute the subnode of a node.

Arguments

Performance notes

Safety notes

This function fails if char_offset or char_len do not represent valid positions in node.

Function tree_from_forest_destructive

fn tree_from_forest_destructive(forest: & [mut @Node]) -> @Node

Concatenate a forest of nodes into one tree.

Arguments