Skip to content
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

core: Rename container to collections. Closes #12543 #14333

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion src/libcollections/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ impl cmp::Eq for BitvSet {
fn ne(&self, other: &BitvSet) -> bool { !self.eq(other) }
}

impl Container for BitvSet {
impl Collection for BitvSet {
#[inline]
fn len(&self) -> uint { self.size }
}
Expand Down
4 changes: 1 addition & 3 deletions src/libcollections/deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

//! Container traits for collections

use std::container::Mutable;

/// A double-ended sequence that allows querying, insertion and deletion at both ends.
pub trait Deque<T> : Mutable {
/// Provide a reference to the front element, or None if the sequence is empty
Expand Down Expand Up @@ -43,7 +41,7 @@ pub trait Deque<T> : Mutable {
pub mod bench {
extern crate test;
use self::test::Bencher;
use std::container::MutableMap;
use std::collections::MutableMap;
use rand;
use rand::Rng;

Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn link_with_prev<T>(mut next: Box<Node<T>>, prev: Rawlink<Node<T>>)
Some(next)
}

impl<T> Container for DList<T> {
impl<T> Collection for DList<T> {
/// O(1)
#[inline]
fn is_empty(&self) -> bool {
Expand Down
7 changes: 3 additions & 4 deletions src/libcollections/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

//! Unordered containers, implemented as hash-tables (`HashSet` and `HashMap` types)

use std::container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
use std::clone::Clone;
use std::cmp::{Eq, TotalEq, Equiv, max};
use std::default::Default;
Expand Down Expand Up @@ -925,7 +924,7 @@ impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
}
}

impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> Container for HashMap<K, V, H> {
impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> Collection for HashMap<K, V, H> {
/// Return the number of elements in the map
fn len(&self) -> uint { self.table.size() }
}
Expand Down Expand Up @@ -1494,7 +1493,7 @@ impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Eq for HashSet<T, H> {
}
}

impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Container for HashSet<T, H> {
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Collection for HashSet<T, H> {
fn len(&self) -> uint { self.map.len() }
}

Expand Down Expand Up @@ -2079,7 +2078,7 @@ mod test_map {
#[cfg(test)]
mod test_set {
use super::HashSet;
use std::container::Container;
use std::collections::Collection;
use std::slice::ImmutableEqVector;

#[test]
Expand Down
3 changes: 1 addition & 2 deletions src/libcollections/lru_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
//! assert!(cache.get(&2).is_none());
//! ```

use std::container::Container;
use std::hash::Hash;
use std::fmt;
use std::mem;
Expand Down Expand Up @@ -222,7 +221,7 @@ impl<A: fmt::Show + Hash + TotalEq, B: fmt::Show> fmt::Show for LruCache<A, B> {
}
}

impl<K: Hash + TotalEq, V> Container for LruCache<K, V> {
impl<K: Hash + TotalEq, V> Collection for LruCache<K, V> {
/// Return the number of key-value pairs in the cache.
fn len(&self) -> uint {
self.map.len()
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct PriorityQueue<T> {
data: Vec<T>,
}

impl<T: TotalOrd> Container for PriorityQueue<T> {
impl<T: TotalOrd> Collection for PriorityQueue<T> {
/// Returns the length of the queue
fn len(&self) -> uint { self.data.len() }
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct RingBuf<T> {
elts: Vec<Option<T>>
}

impl<T> Container for RingBuf<T> {
impl<T> Collection for RingBuf<T> {
/// Return the number of elements in the RingBuf
fn len(&self) -> uint { self.nelts }
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/smallintmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct SmallIntMap<T> {
v: Vec<Option<T>>,
}

impl<V> Container for SmallIntMap<V> {
impl<V> Collection for SmallIntMap<V> {
/// Return the number of elements in the map
fn len(&self) -> uint {
self.v.iter().count(|elt| elt.is_some())
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<K: Ord + TotalOrd, V: Ord> Ord for TreeMap<K, V> {
fn lt(&self, other: &TreeMap<K, V>) -> bool { lt(self, other) }
}

impl<K: TotalOrd, V> Container for TreeMap<K, V> {
impl<K: TotalOrd, V> Collection for TreeMap<K, V> {
fn len(&self) -> uint { self.length }
}

Expand Down Expand Up @@ -547,7 +547,7 @@ impl<T: Ord + TotalOrd> Ord for TreeSet<T> {
fn lt(&self, other: &TreeSet<T>) -> bool { self.map < other.map }
}

impl<T: TotalOrd> Container for TreeSet<T> {
impl<T: TotalOrd> Collection for TreeSet<T> {
#[inline]
fn len(&self) -> uint { self.map.len() }
}
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct TrieMap<T> {
length: uint
}

impl<T> Container for TrieMap<T> {
impl<T> Collection for TrieMap<T> {
/// Return the number of elements in the map
#[inline]
fn len(&self) -> uint { self.length }
Expand Down Expand Up @@ -281,7 +281,7 @@ pub struct TrieSet {
map: TrieMap<()>
}

impl Container for TrieSet {
impl Collection for TrieSet {
/// Return the number of elements in the set
#[inline]
fn len(&self) -> uint { self.map.len() }
Expand Down
10 changes: 5 additions & 5 deletions src/libcore/container.rs → src/libcore/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Traits for generic containers (including `Map` and `Set`)
//! Traits for generic collections (including `Map` and `Set`)

use option::Option;

/// A trait to represent the abstract idea of a container. The only concrete
/// knowledge known is the number of elements contained within.
pub trait Container {
pub trait Collection {
/// Return the number of elements in the container
fn len(&self) -> uint;

Expand All @@ -26,14 +26,14 @@ pub trait Container {
}

/// A trait to represent mutable containers
pub trait Mutable: Container {
pub trait Mutable: Collection {
/// Clear the container, removing all values.
fn clear(&mut self);
}

/// A map is a key-value store where values may be looked up by their keys. This
/// trait provides basic operations to operate on these stores.
pub trait Map<K, V>: Container {
pub trait Map<K, V>: Collection {
/// Return a reference to the value corresponding to the key
fn find<'a>(&'a self, key: &K) -> Option<&'a V>;

Expand Down Expand Up @@ -76,7 +76,7 @@ pub trait MutableMap<K, V>: Map<K, V> + Mutable {
/// A set is a group of objects which are each distinct from one another. This
/// trait represents actions which can be performed on sets to iterate over
/// them.
pub trait Set<T>: Container {
pub trait Set<T>: Collection {
/// Return true if the set contains a value
fn contains(&self, value: &T) -> bool;

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/fmt/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#![allow(missing_doc)]

use char;
use container::Container;
use collections::Collection;
use fmt;
use iter::{Iterator, range, DoubleEndedIterator};
use num::{Float, FPNaN, FPInfinite, ToPrimitive, Primitive};
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use any;
use cell::Cell;
use char::Char;
use container::Container;
use collections::Collection;
use iter::{Iterator, range};
use kinds::Copy;
use mem;
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#![allow(unsigned_negate)]

use container::Container;
use collections::Collection;
use fmt;
use iter::{Iterator, DoubleEndedIterator};
use num::{Int, cast, zero};
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub mod ptr;
#[cfg(not(test))] pub mod cmp;
pub mod clone;
pub mod default;
pub mod container;
pub mod collections;

/* Core types and methods on primitives */

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub use mem::drop;
pub use char::Char;
pub use clone::Clone;
pub use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater, Equiv};
pub use container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
pub use collections::{Collection, Mutable, Map, MutableMap, Set, MutableSet};
pub use iter::{FromIterator, Extendable};
pub use iter::{Iterator, DoubleEndedIterator, RandomAccessIterator, CloneableIterator};
pub use iter::{OrdIterator, MutableDoubleEndedIterator, ExactSize};
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/should_not_exist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

use char::Char;
use clone::Clone;
use container::Container;
use collections::Collection;
use default::Default;
use finally::try_finally;
use intrinsics;
Expand Down
10 changes: 5 additions & 5 deletions src/libcore/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use mem::transmute;
use clone::Clone;
use container::Container;
use collections::Collection;
use cmp::{Eq, TotalOrd, Ordering, Less, Equal, Greater};
use cmp;
use default::Default;
Expand Down Expand Up @@ -251,7 +251,7 @@ pub mod traits {

use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Equiv};
use iter::{order, Iterator};
use container::Container;
use collections::Collection;

impl<'a,T:Eq> Eq for &'a [T] {
fn eq(&self, other: & &'a [T]) -> bool {
Expand Down Expand Up @@ -345,15 +345,15 @@ impl<T> Vector<T> for ~[T] {
fn as_slice<'a>(&'a self) -> &'a [T] { let v: &'a [T] = *self; v }
}

impl<'a, T> Container for &'a [T] {
impl<'a, T> Collection for &'a [T] {
/// Returns the length of a vector
#[inline]
fn len(&self) -> uint {
self.repr().len
}
}

impl<T> Container for ~[T] {
impl<T> Collection for ~[T] {
/// Returns the length of a vector
#[inline]
fn len(&self) -> uint {
Expand Down Expand Up @@ -1235,7 +1235,7 @@ pub mod raw {

/// Operations on `[u8]`.
pub mod bytes {
use container::Container;
use collections::Collection;
use ptr;
use slice::MutableVector;

Expand Down
10 changes: 5 additions & 5 deletions src/libcore/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use char;
use clone::Clone;
use cmp;
use cmp::{Eq, TotalEq};
use container::Container;
use collections::Collection;
use default::Default;
use iter::{Filter, Map, Iterator};
use iter::{Rev, DoubleEndedIterator, ExactSize};
Expand Down Expand Up @@ -890,7 +890,7 @@ static TAG_CONT_U8: u8 = 128u8;
/// Unsafe operations
pub mod raw {
use mem;
use container::Container;
use collections::Collection;
use iter::Iterator;
use ptr::RawPtr;
use raw::Slice;
Expand Down Expand Up @@ -955,7 +955,7 @@ Section: Trait implementations
#[cfg(not(test))]
#[allow(missing_doc)]
pub mod traits {
use container::Container;
use collections::Collection;
use cmp::{TotalOrd, Ordering, Less, Equal, Greater, Eq, Ord, Equiv, TotalEq};
use iter::Iterator;
use option::{Some, None};
Expand Down Expand Up @@ -1041,14 +1041,14 @@ impl<'a> Str for ~str {
fn as_slice<'a>(&'a self) -> &'a str { let s: &'a str = *self; s }
}

impl<'a> Container for &'a str {
impl<'a> Collection for &'a str {
#[inline]
fn len(&self) -> uint {
self.repr().len
}
}

impl Container for ~str {
impl Collection for ~str {
#[inline]
fn len(&self) -> uint { self.as_slice().len() }
}
Expand Down
2 changes: 1 addition & 1 deletion src/libregex/re.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ impl<'t> Captures<'t> {
}
}

impl<'t> Container for Captures<'t> {
impl<'t> Collection for Captures<'t> {
/// Returns the number of captured groups.
#[inline]
fn len(&self) -> uint {
Expand Down
1 change: 0 additions & 1 deletion src/librustc/middle/trans/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@

#![allow(unsigned_negate)]

use std::container::Map;
use libc::c_ulonglong;
use std::num::{Bitwise};
use std::rc::Rc;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

//! Operations on ASCII strings and characters

use container::Container;
use collections::Collection;
use fmt;
use iter::Iterator;
use mem;
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn main() {

use clone::Clone;
use cmp::Eq;
use container::Container;
use collections::Collection;
use iter::{Iterator, range};
use kinds::marker;
use libc;
Expand Down Expand Up @@ -236,7 +236,7 @@ impl Drop for CString {
}
}

impl Container for CString {
impl Collection for CString {
/// Return the number of bytes in the CString (not including the NUL terminator).
///
/// # Failure
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/c_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
//! handled correctly, i.e. that allocated memory is eventually freed
//! if necessary.

use container::Container;
use collections::Collection;
use kinds::Send;
use mem;
use ops::Drop;
Expand Down Expand Up @@ -149,7 +149,7 @@ impl<T> CVec<T> {
}
}

impl<T> Container for CVec<T> {
impl<T> Collection for CVec<T> {
fn len(&self) -> uint { self.len }
}

Expand Down
Loading