Add capacity() to VecMap

Changed capacity() tag to unstable and fixed doc assert
This commit is contained in:
Aaron Liblong 2014-12-04 12:14:06 -05:00
parent 3a325c666d
commit 0d3c415617

View file

@ -115,6 +115,22 @@ impl<V> VecMap<V> {
VecMap { v: Vec::with_capacity(capacity) }
}
/// Returns the number of elements the `VecMap` can hold without
/// reallocating.
///
/// # Example
///
/// ```
/// use std::collections::VecMap;
/// let map: VecMap<String> = VecMap::with_capacity(10);
/// assert!(map.capacity() >= 10);
/// ```
#[inline]
#[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn capacity(&self) -> uint {
self.v.capacity()
}
/// Returns an iterator visiting all keys in ascending order by the keys.
/// The iterator's element type is `uint`.
#[unstable = "matches collection reform specification, waiting for dust to settle"]