Skip to content

Commit

Permalink
Add capacity() to VecMap
Browse files Browse the repository at this point in the history
Changed capacity() tag to unstable and fixed doc assert
  • Loading branch information
aliblong committed Dec 4, 2014
1 parent 3a325c6 commit 0d3c415
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/libcollections/vec_map.rs
Expand Up @@ -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"]
Expand Down

0 comments on commit 0d3c415

Please sign in to comment.