提交 57425b57 编写于 作者: D David Rajchenbach-Teller 提交者: Brian Anderson

[Docfix + Renaming] lib/rope.rs: Applied review suggestions, mostly docfixes.

上级 f9a0d03c
......@@ -298,22 +298,78 @@ fn cmp(left: rope, right: rope) -> int {
}
}
/*
Function: eq
Returns:
`true` if both ropes have the same content (regardless of their structure),
`false` otherwise
*/
fn eq(left: rope, right: rope) -> bool {
ret cmp(left, right) == 0;
}
fn leq(left: rope, right: rope) -> bool {
/*
Function: le
Parameters
left - an arbitrary rope
right - an arbitrary rope
Returns:
`true` if `left <= right` in lexicographical order (regardless of their
structure), `false` otherwise
*/
fn le(left: rope, right: rope) -> bool {
ret cmp(left, right) <= 0;
}
/*
Function: lt
Parameters
left - an arbitrary rope
right - an arbitrary rope
Returns:
`true` if `left < right` in lexicographical order (regardless of their
structure), `false` otherwise
*/
fn lt(left: rope, right: rope) -> bool {
ret cmp(left, right) < 0;
}
fn geq(left: rope, right: rope) -> bool {
/*
Function: ge
Parameters
left - an arbitrary rope
right - an arbitrary rope
Returns:
`true` if `left >= right` in lexicographical order (regardless of their
structure), `false` otherwise
*/
fn ge(left: rope, right: rope) -> bool {
ret cmp(left, right) >= 0;
}
/*
Function: gt
Parameters
left - an arbitrary rope
right - an arbitrary rope
Returns:
`true` if `left > right` in lexicographical order (regardless of their
structure), `false` otherwise
*/
fn gt(left: rope, right: rope) -> bool {
ret cmp(left, right) > 0;
}
......@@ -349,6 +405,16 @@ fn loop_chars(rope: rope, it: block(char) -> bool) -> bool {
node::content(x) { ret node::loop_chars(x, it) }
}
}
/*
Function: iter_chars
Loop through a rope, char by char, until the end.
Parameters:
rope - A rope to traverse. It may be empty.
it - A block to execute with each consecutive character of the rope.
*/
fn iter_chars(rope: rope, it: block(char)) {
loop_chars(rope) {|x|
it(x);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册