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

pure 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

pure 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(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