diff options
Diffstat (limited to 'src/libcore/slice.rs')
| -rw-r--r-- | src/libcore/slice.rs | 61 |
1 files changed, 58 insertions, 3 deletions
diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 475c2e94ec7..5a70cd8c847 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -996,9 +996,6 @@ impl<'a, T> Default for &'a [T] { fn default() -> &'a [T] { &[] } } - - - // // Iterators // @@ -1128,7 +1125,16 @@ impl<'a, T> ExactSize<&'a mut T> for MutItems<'a, T> {} /// An iterator over the slices of a vector separated by elements that /// match a predicate function. +#[cfg(not(stage0))] #[experimental = "needs review"] +pub struct Splits<'a, T:'a> { + v: &'a [T], + pred: |t: &T|: 'a -> bool, + finished: bool +} + +/// Dox. +#[cfg(stage0)] pub struct Splits<'a, T> { v: &'a [T], pred: |t: &T|: 'a -> bool, @@ -1186,7 +1192,16 @@ impl<'a, T> DoubleEndedIterator<&'a [T]> for Splits<'a, T> { /// An iterator over the subslices of the vector which are separated /// by elements that match `pred`. +#[cfg(not(stage0))] #[experimental = "needs review"] +pub struct MutSplits<'a, T:'a> { + v: &'a mut [T], + pred: |t: &T|: 'a -> bool, + finished: bool +} + +/// Dox +#[cfg(stage0)] pub struct MutSplits<'a, T> { v: &'a mut [T], pred: |t: &T|: 'a -> bool, @@ -1255,7 +1270,16 @@ impl<'a, T> DoubleEndedIterator<&'a mut [T]> for MutSplits<'a, T> { /// An iterator over the slices of a vector separated by elements that /// match a predicate function, splitting at most a fixed number of times. +#[cfg(not(stage0))] #[experimental = "needs review"] +pub struct SplitsN<'a, T:'a> { + iter: Splits<'a, T>, + count: uint, + invert: bool +} + +/// Dox. +#[cfg(stage0)] pub struct SplitsN<'a, T> { iter: Splits<'a, T>, count: uint, @@ -1291,6 +1315,7 @@ impl<'a, T> Iterator<&'a [T]> for SplitsN<'a, T> { /// An iterator over the (overlapping) slices of length `size` within /// a vector. +#[cfg(stage0)] #[deriving(Clone)] #[experimental = "needs review"] pub struct Windows<'a, T> { @@ -1298,7 +1323,16 @@ pub struct Windows<'a, T> { size: uint } +/// An iterator over the (overlapping) slices of length `size` within +/// a vector. +#[cfg(not(stage0))] +#[deriving(Clone)] #[experimental = "needs review"] +pub struct Windows<'a, T:'a> { + v: &'a [T], + size: uint +} + impl<'a, T> Iterator<&'a [T]> for Windows<'a, T> { #[inline] fn next(&mut self) -> Option<&'a [T]> { @@ -1327,6 +1361,7 @@ impl<'a, T> Iterator<&'a [T]> for Windows<'a, T> { /// /// When the vector len is not evenly divided by the chunk size, /// the last slice of the iteration will be the remainder. +#[cfg(stage0)] #[deriving(Clone)] #[experimental = "needs review"] pub struct Chunks<'a, T> { @@ -1334,6 +1369,18 @@ pub struct Chunks<'a, T> { size: uint } +/// An iterator over a vector in (non-overlapping) chunks (`size` +/// elements at a time). +/// +/// When the vector len is not evenly divided by the chunk size, +/// the last slice of the iteration will be the remainder. +#[cfg(not(stage0))] +#[deriving(Clone)] +pub struct Chunks<'a, T:'a> { + v: &'a [T], + size: uint +} + #[experimental = "needs review"] impl<'a, T> Iterator<&'a [T]> for Chunks<'a, T> { #[inline] @@ -1400,7 +1447,15 @@ impl<'a, T> RandomAccessIterator<&'a [T]> for Chunks<'a, T> { /// An iterator over a vector in (non-overlapping) mutable chunks (`size` elements at a time). When /// the vector len is not evenly divided by the chunk size, the last slice of the iteration will be /// the remainder. +#[cfg(not(stage0))] #[experimental = "needs review"] +pub struct MutChunks<'a, T:'a> { + v: &'a mut [T], + chunk_size: uint +} + +/// Dox. +#[cfg(stage0)] pub struct MutChunks<'a, T> { v: &'a mut [T], chunk_size: uint |
