Reorder std::vec so the documentation renders better

Put all types first, then predicates, then functions
This commit is contained in:
Brian Anderson 2011-10-27 17:03:38 -07:00
parent 2b85817af8
commit 506ae934f8

View File

@ -19,6 +19,41 @@ native "c-stack-cdecl" mod rustrt {
count: uint) -> [T];
}
/*
Type: init_op
A function used to initialize the elements of a vector.
*/
type init_op<T> = block(uint) -> T;
/*
Predicate: is_empty
Returns true if a vector contains no elements.
*/
pure fn is_empty<T>(v: [mutable? T]) -> bool {
// FIXME: This would be easier if we could just call len
for t: T in v { ret false; }
ret true;
}
/*
Predicate: is_not_empty
Returns true if a vector contains some elements.
*/
pure fn is_not_empty<T>(v: [mutable? T]) -> bool { ret !is_empty(v); }
/*
Predicate: same_length
Returns true if two vectors have the same length
*/
pure fn same_length<T, U>(xs: [T], ys: [U]) -> bool {
vec::len(xs) == vec::len(ys)
}
/*
Function: reserve
@ -43,13 +78,6 @@ Returns the length of a vector
*/
pure fn len<T>(v: [mutable? T]) -> uint { unchecked { rusti::vec_len(v) } }
/*
Type: init_op
A function used to initialize the elements of a vector.
*/
type init_op<T> = block(uint) -> T;
/*
Function: init_fn
@ -141,24 +169,6 @@ fn from_mut<T>(v: [mutable T]) -> [T] {
ret vres;
}
/*
Predicate: is_empty
Returns true if a vector contains no elements.
*/
pure fn is_empty<T>(v: [mutable? T]) -> bool {
// FIXME: This would be easier if we could just call len
for t: T in v { ret false; }
ret true;
}
/*
Predicate: is_not_empty
Returns true if a vector contains some elements.
*/
pure fn is_not_empty<T>(v: [mutable? T]) -> bool { ret !is_empty(v); }
// Accessors
/*
@ -519,15 +529,6 @@ fn position_pred<T>(f: block(T) -> bool, v: [T]) -> option::t<uint> {
ret none;
}
/*
Predicate: same_length
Returns true if two vectors have the same length
*/
pure fn same_length<T, U>(xs: [T], ys: [U]) -> bool {
vec::len(xs) == vec::len(ys)
}
// FIXME: if issue #586 gets implemented, could have a postcondition
// saying the two result lists have the same length -- or, could
// return a nominal record with a constraint saying that, instead of