Skip to content

Renaming of the Iter types as in RFC #344 #20056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/libcollections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ impl<T: Ord> BinaryHeap<T> {
/// }
/// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn iter(&self) -> Items<T> {
Items { iter: self.data.iter() }
pub fn iter(&self) -> Iter<T> {
Iter { iter: self.data.iter() }
}

/// Creates a consuming iterator, that is, one that moves each value out of
Expand All @@ -260,8 +260,8 @@ impl<T: Ord> BinaryHeap<T> {
/// }
/// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn into_iter(self) -> MoveItems<T> {
MoveItems { iter: self.data.into_iter() }
pub fn into_iter(self) -> IntoIter<T> {
IntoIter { iter: self.data.into_iter() }
}

/// Returns the greatest item in a queue, or `None` if it is empty.
Expand Down Expand Up @@ -571,44 +571,44 @@ impl<T: Ord> BinaryHeap<T> {
}

/// `BinaryHeap` iterator.
pub struct Items<'a, T: 'a> {
iter: slice::Items<'a, T>,
pub struct Iter <'a, T: 'a> {
iter: slice::Iter<'a, T>,
}

impl<'a, T> Iterator<&'a T> for Items<'a, T> {
impl<'a, T> Iterator<&'a T> for Iter<'a, T> {
#[inline]
fn next(&mut self) -> Option<&'a T> { self.iter.next() }

#[inline]
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
}

impl<'a, T> DoubleEndedIterator<&'a T> for Items<'a, T> {
impl<'a, T> DoubleEndedIterator<&'a T> for Iter<'a, T> {
#[inline]
fn next_back(&mut self) -> Option<&'a T> { self.iter.next_back() }
}

impl<'a, T> ExactSizeIterator<&'a T> for Items<'a, T> {}
impl<'a, T> ExactSizeIterator<&'a T> for Iter<'a, T> {}

/// An iterator that moves out of a `BinaryHeap`.
pub struct MoveItems<T> {
iter: vec::MoveItems<T>,
pub struct IntoIter<T> {
iter: vec::IntoIter<T>,
}

impl<T> Iterator<T> for MoveItems<T> {
impl<T> Iterator<T> for IntoIter<T> {
#[inline]
fn next(&mut self) -> Option<T> { self.iter.next() }

#[inline]
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
}

impl<T> DoubleEndedIterator<T> for MoveItems<T> {
impl<T> DoubleEndedIterator<T> for IntoIter<T> {
#[inline]
fn next_back(&mut self) -> Option<T> { self.iter.next_back() }
}

impl<T> ExactSizeIterator<T> for MoveItems<T> {}
impl<T> ExactSizeIterator<T> for IntoIter<T> {}

/// An iterator that drains a `BinaryHeap`.
pub struct Drain<'a, T: 'a> {
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/bit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl Index<uint,bool> for Bitv {
}

struct MaskWords<'a> {
iter: slice::Items<'a, u32>,
iter: slice::Iter<'a, u32>,
next_word: Option<&'a u32>,
last_word_mask: u32,
offset: uint
Expand Down
58 changes: 29 additions & 29 deletions src/libcollections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,36 +88,36 @@ pub struct BTreeMap<K, V> {
}

/// An abstract base over-which all other BTree iterators are built.
struct AbsEntries<T> {
struct AbsIter<T> {
lca: T,
left: RingBuf<T>,
right: RingBuf<T>,
size: uint,
}

/// An iterator over a BTreeMap's entries.
pub struct Entries<'a, K: 'a, V: 'a> {
inner: AbsEntries<Traversal<'a, K, V>>
pub struct Iter<'a, K: 'a, V: 'a> {
inner: AbsIter<Traversal<'a, K, V>>
}

/// A mutable iterator over a BTreeMap's entries.
pub struct MutEntries<'a, K: 'a, V: 'a> {
inner: AbsEntries<MutTraversal<'a, K, V>>
pub struct IterMut<'a, K: 'a, V: 'a> {
inner: AbsIter<MutTraversal<'a, K, V>>
}

/// An owning iterator over a BTreeMap's entries.
pub struct MoveEntries<K, V> {
inner: AbsEntries<MoveTraversal<K, V>>
pub struct IntoIter<K, V> {
inner: AbsIter<MoveTraversal<K, V>>
}

/// An iterator over a BTreeMap's keys.
pub struct Keys<'a, K: 'a, V: 'a> {
inner: Map<(&'a K, &'a V), &'a K, Entries<'a, K, V>, fn((&'a K, &'a V)) -> &'a K>
inner: Map<(&'a K, &'a V), &'a K, Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a K>
}

/// An iterator over a BTreeMap's values.
pub struct Values<'a, K: 'a, V: 'a> {
inner: Map<(&'a K, &'a V), &'a V, Entries<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>
inner: Map<(&'a K, &'a V), &'a V, Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>
}

/// A view into a single entry in a map, which may either be vacant or occupied.
Expand Down Expand Up @@ -929,7 +929,7 @@ enum StackOp<T> {
}

impl<K, V, E, T: Traverse<E> + DoubleEndedIterator<TraversalItem<K, V, E>>>
Iterator<(K, V)> for AbsEntries<T> {
Iterator<(K, V)> for AbsIter<T> {
// This function is pretty long, but only because there's a lot of cases to consider.
// Our iterator represents two search paths, left and right, to the smallest and largest
// elements we have yet to yield. lca represents the least common ancestor of these two paths,
Expand Down Expand Up @@ -995,7 +995,7 @@ impl<K, V, E, T: Traverse<E> + DoubleEndedIterator<TraversalItem<K, V, E>>>
}

impl<K, V, E, T: Traverse<E> + DoubleEndedIterator<TraversalItem<K, V, E>>>
DoubleEndedIterator<(K, V)> for AbsEntries<T> {
DoubleEndedIterator<(K, V)> for AbsIter<T> {
// next_back is totally symmetric to next
fn next_back(&mut self) -> Option<(K, V)> {
loop {
Expand Down Expand Up @@ -1032,34 +1032,34 @@ impl<K, V, E, T: Traverse<E> + DoubleEndedIterator<TraversalItem<K, V, E>>>
}
}

impl<'a, K, V> Iterator<(&'a K, &'a V)> for Entries<'a, K, V> {
impl<'a, K, V> Iterator<(&'a K, &'a V)> for Iter<'a, K, V> {
fn next(&mut self) -> Option<(&'a K, &'a V)> { self.inner.next() }
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
}
impl<'a, K, V> DoubleEndedIterator<(&'a K, &'a V)> for Entries<'a, K, V> {
impl<'a, K, V> DoubleEndedIterator<(&'a K, &'a V)> for Iter<'a, K, V> {
fn next_back(&mut self) -> Option<(&'a K, &'a V)> { self.inner.next_back() }
}
impl<'a, K, V> ExactSizeIterator<(&'a K, &'a V)> for Entries<'a, K, V> {}
impl<'a, K, V> ExactSizeIterator<(&'a K, &'a V)> for Iter<'a, K, V> {}


impl<'a, K, V> Iterator<(&'a K, &'a mut V)> for MutEntries<'a, K, V> {
impl<'a, K, V> Iterator<(&'a K, &'a mut V)> for IterMut<'a, K, V> {
fn next(&mut self) -> Option<(&'a K, &'a mut V)> { self.inner.next() }
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
}
impl<'a, K, V> DoubleEndedIterator<(&'a K, &'a mut V)> for MutEntries<'a, K, V> {
impl<'a, K, V> DoubleEndedIterator<(&'a K, &'a mut V)> for IterMut<'a, K, V> {
fn next_back(&mut self) -> Option<(&'a K, &'a mut V)> { self.inner.next_back() }
}
impl<'a, K, V> ExactSizeIterator<(&'a K, &'a mut V)> for MutEntries<'a, K, V> {}
impl<'a, K, V> ExactSizeIterator<(&'a K, &'a mut V)> for IterMut<'a, K, V> {}


impl<K, V> Iterator<(K, V)> for MoveEntries<K, V> {
impl<K, V> Iterator<(K, V)> for IntoIter<K, V> {
fn next(&mut self) -> Option<(K, V)> { self.inner.next() }
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
}
impl<K, V> DoubleEndedIterator<(K, V)> for MoveEntries<K, V> {
impl<K, V> DoubleEndedIterator<(K, V)> for IntoIter<K, V> {
fn next_back(&mut self) -> Option<(K, V)> { self.inner.next_back() }
}
impl<K, V> ExactSizeIterator<(K, V)> for MoveEntries<K, V> {}
impl<K, V> ExactSizeIterator<(K, V)> for IntoIter<K, V> {}


impl<'a, K, V> Iterator<&'a K> for Keys<'a, K, V> {
Expand Down Expand Up @@ -1140,10 +1140,10 @@ impl<K, V> BTreeMap<K, V> {
/// assert_eq!((*first_key, *first_value), (1u, "a"));
/// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn iter<'a>(&'a self) -> Entries<'a, K, V> {
pub fn iter<'a>(&'a self) -> Iter<'a, K, V> {
let len = self.len();
Entries {
inner: AbsEntries {
Iter {
inner: AbsIter {
lca: Traverse::traverse(&self.root),
left: RingBuf::new(),
right: RingBuf::new(),
Expand Down Expand Up @@ -1172,10 +1172,10 @@ impl<K, V> BTreeMap<K, V> {
/// }
/// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn iter_mut<'a>(&'a mut self) -> MutEntries<'a, K, V> {
pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, K, V> {
let len = self.len();
MutEntries {
inner: AbsEntries {
IterMut {
inner: AbsIter {
lca: Traverse::traverse(&mut self.root),
left: RingBuf::new(),
right: RingBuf::new(),
Expand All @@ -1201,10 +1201,10 @@ impl<K, V> BTreeMap<K, V> {
/// }
/// ```
#[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn into_iter(self) -> MoveEntries<K, V> {
pub fn into_iter(self) -> IntoIter<K, V> {
let len = self.len();
MoveEntries {
inner: AbsEntries {
IntoIter {
inner: AbsIter {
lca: Traverse::traverse(self.root),
left: RingBuf::new(),
right: RingBuf::new(),
Expand Down
12 changes: 6 additions & 6 deletions src/libcollections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1382,14 +1382,14 @@ pub enum TraversalItem<K, V, E> {
}

/// A traversal over a node's entries and edges
pub type Traversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Items<'a, K>,
slice::Items<'a, V>>,
slice::Items<'a, Node<K, V>>>>;
pub type Traversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Iter<'a, K>,
slice::Iter<'a, V>>,
slice::Iter<'a, Node<K, V>>>>;

/// A mutable traversal over a node's entries and edges
pub type MutTraversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Items<'a, K>,
slice::MutItems<'a, V>>,
slice::MutItems<'a, Node<K, V>>>>;
pub type MutTraversal<'a, K, V> = AbsTraversal<ElemsAndEdges<Zip<slice::Iter<'a, K>,
slice::IterMut<'a, V>>,
slice::IterMut<'a, Node<K, V>>>>;

/// An owning traversal over a node's entries and edges
pub type MoveTraversal<K, V> = AbsTraversal<MoveTraversalImpl<K, V>>;
Expand Down
Loading