rustc: Add a "smallintmap" implementation

This commit is contained in:
Patrick Walton 2011-06-03 16:14:29 -07:00
parent 088ab03fdb
commit cb4c969ba6
3 changed files with 54 additions and 0 deletions

View file

@ -163,6 +163,19 @@ fn slice[T](array[T] v, uint start, uint end) -> vec[T] {
ret result;
}
// FIXME: Should go away eventually.
fn slice_mut[T](array[T] v, uint start, uint end) -> vec[mutable T] {
assert (start <= end);
assert (end <= len[T](v));
auto result = alloc_mut[T](end - start);
let uint i = start;
while (i < end) {
result += [mutable v.(i)];
i += 1u;
}
ret result;
}
fn shift[T](&mutable array[T] v) -> T {
auto ln = len[T](v);
assert (ln > 0u);