Demode dvec

This commit is contained in:
Tim Chevalier 2012-09-25 18:27:45 -07:00
parent ab6318803e
commit 3023bd8729
8 changed files with 16 additions and 16 deletions

View file

@ -118,7 +118,7 @@ fn concat<T>(lists: DList<DList<T>>) -> DList<T> {
}
priv impl<T> DList<T> {
pure fn new_link(-data: T) -> DListLink<T> {
pure fn new_link(+data: T) -> DListLink<T> {
Some(DListNode(@{data: move data, mut linked: true,
mut prev: None, mut next: None}))
}

View file

@ -93,7 +93,7 @@ priv impl<A> DVec<A> {
}
#[inline(always)]
fn check_out<B>(f: fn(-v: ~[A]) -> B) -> B {
fn check_out<B>(f: &fn(+v: ~[A]) -> B) -> B {
unsafe {
let mut data = cast::reinterpret_cast(&null::<()>());
data <-> self.data;
@ -126,7 +126,7 @@ impl<A> DVec<A> {
* and return a new vector to replace it with.
*/
#[inline(always)]
fn swap(f: fn(-v: ~[A]) -> ~[A]) {
fn swap(f: &fn(+v: ~[A]) -> ~[A]) {
self.check_out(|v| self.give_back(f(move v)))
}
@ -136,7 +136,7 @@ impl<A> DVec<A> {
* and return a new vector to replace it with.
*/
#[inline(always)]
fn swap_mut(f: fn(-v: ~[mut A]) -> ~[mut A]) {
fn swap_mut(f: &fn(-v: ~[mut A]) -> ~[mut A]) {
do self.swap |v| {
vec::from_mut(f(vec::to_mut(move v)))
}
@ -170,7 +170,7 @@ impl<A> DVec<A> {
}
/// Insert a single item at the front of the list
fn unshift(-t: A) {
fn unshift(+t: A) {
unsafe {
let mut data = cast::reinterpret_cast(&null::<()>());
data <-> self.data;
@ -301,7 +301,7 @@ impl<A: Copy> DVec<A> {
}
/// Overwrites the contents of the element at `idx` with `a`
fn set_elt(idx: uint, a: A) {
fn set_elt(idx: uint, +a: A) {
self.check_not_borrowed();
self.data[idx] = a;
}
@ -311,7 +311,7 @@ impl<A: Copy> DVec<A> {
* growing the vector if necessary. New elements will be initialized
* with `initval`
*/
fn grow_set_elt(idx: uint, initval: A, val: A) {
fn grow_set_elt(idx: uint, initval: A, +val: A) {
do self.swap |v| {
let mut v = move v;
vec::grow_set(v, idx, initval, val);
@ -325,11 +325,11 @@ impl<A: Copy> DVec<A> {
self.check_not_borrowed();
let length = self.len();
if length == 0u {
if length == 0 {
fail ~"attempt to retrieve the last element of an empty vector";
}
return self.data[length - 1u];
return self.data[length - 1];
}
/// Iterates over the elements in reverse order
@ -360,7 +360,7 @@ impl<A: Copy> DVec<A> {
}
impl<A:Copy> DVec<A>: Index<uint,A> {
pure fn index(&&idx: uint) -> A {
pure fn index(+idx: uint) -> A {
self.get_elt(idx)
}
}

View file

@ -77,6 +77,6 @@ trait Shr<RHS,Result> {
#[lang="index"]
trait Index<Index,Result> {
pure fn index(index: Index) -> Result;
pure fn index(+index: Index) -> Result;
}

View file

@ -556,7 +556,7 @@ pure fn land(w0: uint, w1: uint) -> uint { return w0 & w1; }
pure fn right(_w0: uint, w1: uint) -> uint { return w1; }
impl Bitv: ops::Index<uint,bool> {
pure fn index(&&i: uint) -> bool {
pure fn index(+i: uint) -> bool {
self.get(i)
}
}

View file

@ -42,7 +42,7 @@ type Doc = {data: @~[u8], start: uint, end: uint};
type TaggedDoc = {tag: uint, doc: Doc};
impl Doc: ops::Index<uint,Doc> {
pure fn index(&&tag: uint) -> Doc {
pure fn index(+tag: uint) -> Doc {
unsafe {
get_doc(self, tag)
}

View file

@ -356,7 +356,7 @@ mod chained {
}
impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V>: ops::Index<K, V> {
pure fn index(&&k: K) -> V {
pure fn index(+k: K) -> V {
unsafe {
self.get(k)
}

View file

@ -132,7 +132,7 @@ impl<V: Copy> SmallIntMap<V>: map::Map<uint, V> {
}
impl<V: Copy> SmallIntMap<V>: ops::Index<uint, V> {
pure fn index(&&key: uint) -> V {
pure fn index(+key: uint) -> V {
unsafe {
get(self, key)
}

View file

@ -25,7 +25,7 @@ impl Point : ops::Neg<Point> {
}
impl Point : ops::Index<bool,int> {
pure fn index(&&x: bool) -> int {
pure fn index(+x: bool) -> int {
if x { self.x } else { self.y }
}
}