From dc7183ed0e5da6317d7b3cc3ea25ae30e1a91bcd Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Mon, 7 Jan 2013 08:38:24 -0800 Subject: [PATCH] core: rename MutableVector to OwnedVector --- src/libcore/core.rc | 2 +- src/libcore/prelude.rs | 2 +- src/libcore/vec.rs | 45 +++++++++++++++++++++--------------------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/libcore/core.rc b/src/libcore/core.rc index b422d76e02d..f8658b8e46e 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -191,7 +191,7 @@ pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps}; pub use str::{StrSlice, Trimmable}; pub use vec::{ConstVector, CopyableVector, ImmutableVector}; pub use vec::{ImmutableEqVector, ImmutableCopyableVector}; -pub use vec::{MutableVector, MutableCopyableVector}; +pub use vec::{OwnedVector, OwnedCopyableVector}; pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter}; pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times}; diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index 3d5139a2d32..f2f6659278d 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -21,7 +21,7 @@ pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps}; pub use str::{StrSlice, Trimmable}; pub use vec::{ConstVector, CopyableVector, ImmutableVector}; pub use vec::{ImmutableEqVector, ImmutableCopyableVector}; -pub use vec::{MutableVector, MutableCopyableVector}; +pub use vec::{OwnedVector, OwnedCopyableVector}; pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter}; pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times}; diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 8cfbad4ec6b..ae72e425d20 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -1599,13 +1599,6 @@ pub trait ImmutableVector { pure fn filter_map(f: fn(t: &T) -> Option) -> ~[U]; } -pub trait ImmutableEqVector { - pure fn position(f: fn(t: &T) -> bool) -> Option; - pure fn position_elem(t: &T) -> Option; - pure fn rposition(f: fn(t: &T) -> bool) -> Option; - pure fn rposition_elem(t: &T) -> Option; -} - /// Extension methods for vectors impl &[T]: ImmutableVector { /// Return a slice that points into another slice. @@ -1671,6 +1664,13 @@ impl &[T]: ImmutableVector { } } +pub trait ImmutableEqVector { + pure fn position(f: fn(t: &T) -> bool) -> Option; + pure fn position_elem(t: &T) -> Option; + pure fn rposition(f: fn(t: &T) -> bool) -> Option; + pure fn rposition_elem(t: &T) -> Option; +} + impl &[T]: ImmutableEqVector { /** * Find the first index matching some predicate @@ -1740,7 +1740,7 @@ impl &[T]: ImmutableCopyableVector { pure fn rfind(f: fn(t: &T) -> bool) -> Option { rfind(self, f) } } -pub trait MutableVector { +pub trait OwnedVector { fn push(&mut self, t: T); fn push_all_move(&mut self, rhs: ~[T]); fn pop(&mut self) -> T; @@ -1753,18 +1753,7 @@ pub trait MutableVector { fn retain(&mut self, f: pure fn(t: &T) -> bool); } -pub trait MutableCopyableVector { - fn push_all(&mut self, rhs: &[const T]); - fn grow(&mut self, n: uint, initval: &T); - fn grow_fn(&mut self, n: uint, op: iter::InitOp); - fn grow_set(&mut self, index: uint, initval: &T, val: T); -} - -trait MutableEqVector { - fn dedup(&mut self); -} - -impl ~[T]: MutableVector { +impl ~[T]: OwnedVector { #[inline] fn push(&mut self, t: T) { push(self, t); @@ -1817,7 +1806,14 @@ impl ~[T]: MutableVector { } -impl ~[T]: MutableCopyableVector { +pub trait OwnedCopyableVector { + fn push_all(&mut self, rhs: &[const T]); + fn grow(&mut self, n: uint, initval: &T); + fn grow_fn(&mut self, n: uint, op: iter::InitOp); + fn grow_set(&mut self, index: uint, initval: &T, val: T); +} + +impl ~[T]: OwnedCopyableVector { #[inline] fn push_all(&mut self, rhs: &[const T]) { push_all(self, rhs); @@ -1839,14 +1835,17 @@ impl ~[T]: MutableCopyableVector { } } -impl ~[T]: MutableEqVector { +trait OwnedEqVector { + fn dedup(&mut self); +} + +impl ~[T]: OwnedEqVector { #[inline] fn dedup(&mut self) { dedup(self) } } - /** * Constructs a vector from an unsafe pointer to a buffer *