stdlib: Add an inefficient implementation of ivec::pop

This commit is contained in:
Patrick Walton 2011-07-04 21:20:18 -07:00
parent 5d2c189631
commit d3a4102bc1
2 changed files with 34 additions and 1 deletions

View file

@ -104,7 +104,17 @@ fn slice_mut[T](&T[mutable?] v, uint start, uint end) -> T[mutable] {
// Mutators
// TODO
// TODO: Write this, unsafely, in a way that's not O(n).
fn pop[T](&mutable T[mutable?] v) -> T {
auto ln = len(v);
assert (ln > 0u);
ln -= 1u;
auto e = v.(ln);
v = slice(v, 0u, ln);
ret e;
}
// TODO: More.
// Appending