collections: Add missing Default impls
Add Default impls for TreeMap, TreeSet, SmallIntMap, BitvSet, DList, PriorityQueue, RingBuf, TrieMap, and TrieSet.
This commit is contained in:
parent
810ddfd611
commit
d6a39419db
@ -13,6 +13,7 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use core::cmp;
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::iter::{Enumerate, Repeat, Map, Zip};
|
||||
use core::ops;
|
||||
@ -698,6 +699,11 @@ pub struct BitvSet {
|
||||
bitv: BigBitv
|
||||
}
|
||||
|
||||
impl Default for BitvSet {
|
||||
#[inline]
|
||||
fn default() -> BitvSet { BitvSet::new() }
|
||||
}
|
||||
|
||||
impl BitvSet {
|
||||
/// Creates a new bit vector set with initially no contents
|
||||
pub fn new() -> BitvSet {
|
||||
|
@ -24,6 +24,7 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use alloc::owned::Box;
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::iter;
|
||||
use core::mem;
|
||||
@ -262,6 +263,11 @@ impl<T> Deque<T> for DList<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Default for DList<T> {
|
||||
#[inline]
|
||||
fn default() -> DList<T> { DList::new() }
|
||||
}
|
||||
|
||||
impl<T> DList<T> {
|
||||
/// Create an empty DList
|
||||
#[inline]
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use core::default::Default;
|
||||
use core::mem::{zeroed, replace, swap};
|
||||
use core::ptr;
|
||||
|
||||
@ -37,6 +38,11 @@ impl<T: Ord> Mutable for PriorityQueue<T> {
|
||||
fn clear(&mut self) { self.data.truncate(0) }
|
||||
}
|
||||
|
||||
impl<T: Ord> Default for PriorityQueue<T> {
|
||||
#[inline]
|
||||
fn default() -> PriorityQueue<T> { PriorityQueue::new() }
|
||||
}
|
||||
|
||||
impl<T: Ord> PriorityQueue<T> {
|
||||
/// An iterator visiting all values in underlying vector, in
|
||||
/// arbitrary order.
|
||||
|
@ -16,6 +16,7 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use core::cmp;
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::iter::RandomAccessIterator;
|
||||
|
||||
@ -112,6 +113,11 @@ impl<T> Deque<T> for RingBuf<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Default for RingBuf<T> {
|
||||
#[inline]
|
||||
fn default() -> RingBuf<T> { RingBuf::new() }
|
||||
}
|
||||
|
||||
impl<T> RingBuf<T> {
|
||||
/// Create an empty RingBuf
|
||||
pub fn new() -> RingBuf<T> {
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::iter::{Enumerate, FilterMap};
|
||||
use core::mem::replace;
|
||||
@ -114,6 +115,11 @@ impl<V> MutableMap<uint, V> for SmallIntMap<V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<V> Default for SmallIntMap<V> {
|
||||
#[inline]
|
||||
fn default() -> SmallIntMap<V> { SmallIntMap::new() }
|
||||
}
|
||||
|
||||
impl<V> SmallIntMap<V> {
|
||||
/// Create an empty SmallIntMap
|
||||
pub fn new() -> SmallIntMap<V> { SmallIntMap{v: vec!()} }
|
||||
|
@ -15,6 +15,7 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use alloc::owned::Box;
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::fmt::Show;
|
||||
use core::iter::Peekable;
|
||||
@ -135,6 +136,11 @@ impl<K: Ord, V> MutableMap<K, V> for TreeMap<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Ord, V> Default for TreeMap<K,V> {
|
||||
#[inline]
|
||||
fn default() -> TreeMap<K, V> { TreeMap::new() }
|
||||
}
|
||||
|
||||
impl<K: Ord, V> TreeMap<K, V> {
|
||||
/// Create an empty TreeMap
|
||||
pub fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} }
|
||||
@ -633,6 +639,11 @@ impl<T: Ord> MutableSet<T> for TreeSet<T> {
|
||||
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
|
||||
}
|
||||
|
||||
impl<T: Ord> Default for TreeSet<T> {
|
||||
#[inline]
|
||||
fn default() -> TreeSet<T> { TreeSet::new() }
|
||||
}
|
||||
|
||||
impl<T: Ord> TreeSet<T> {
|
||||
/// Create an empty TreeSet
|
||||
#[inline]
|
||||
|
@ -13,6 +13,7 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use alloc::owned::Box;
|
||||
use core::default::Default;
|
||||
use core::mem::zeroed;
|
||||
use core::mem;
|
||||
use core::uint;
|
||||
@ -105,6 +106,11 @@ impl<T> MutableMap<uint, T> for TrieMap<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Default for TrieMap<T> {
|
||||
#[inline]
|
||||
fn default() -> TrieMap<T> { TrieMap::new() }
|
||||
}
|
||||
|
||||
impl<T> TrieMap<T> {
|
||||
/// Create an empty TrieMap
|
||||
#[inline]
|
||||
@ -332,6 +338,11 @@ impl MutableSet<uint> for TrieSet {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for TrieSet {
|
||||
#[inline]
|
||||
fn default() -> TrieSet { TrieSet::new() }
|
||||
}
|
||||
|
||||
impl TrieSet {
|
||||
/// Create an empty TrieSet
|
||||
#[inline]
|
||||
|
Loading…
Reference in New Issue
Block a user