2011-06-15 11:19:50 -07:00
|
|
|
|
2011-05-19 16:43:46 -07:00
|
|
|
use std;
|
|
|
|
import std::vec;
|
|
|
|
|
|
|
|
fn main() {
|
2011-07-27 14:19:39 +02:00
|
|
|
let v: vec[mutable int] = [mutable 10, 20];
|
2011-06-15 11:19:50 -07:00
|
|
|
assert (v.(0) == 10);
|
|
|
|
assert (v.(1) == 20);
|
|
|
|
vec::reverse(v);
|
|
|
|
assert (v.(0) == 20);
|
|
|
|
assert (v.(1) == 10);
|
2011-07-27 14:19:39 +02:00
|
|
|
let v2 = vec::reversed[int]([10, 20]);
|
2011-06-15 11:19:50 -07:00
|
|
|
assert (v2.(0) == 20);
|
|
|
|
assert (v2.(1) == 10);
|
|
|
|
v.(0) = 30;
|
|
|
|
assert (v2.(0) == 20);
|
|
|
|
// Make sure they work with 0-length vectors too.
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
let v4 = vec::reversed[int]([]);
|
|
|
|
let v3: vec[mutable int] = vec::empty_mut();
|
2011-06-15 11:19:50 -07:00
|
|
|
vec::reverse[int](v3);
|
|
|
|
}
|