88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11- /*!
12- * A simple map based on a vector for small integer keys. Space requirements
13- * are O(highest integer key).
14- */
11+ //! A simple map based on a vector for small integer keys. Space requirements
12+ //! are O(highest integer key).
1513
1614#![ allow( missing_doc) ]
1715
@@ -32,12 +30,12 @@ pub struct SmallIntMap<T> {
3230}
3331
3432impl < V > Collection for SmallIntMap < V > {
35- /// Return the number of elements in the map
33+ /// Return the number of elements in the map.
3634 fn len ( & self ) -> uint {
3735 self . v . iter ( ) . filter ( |elt| elt. is_some ( ) ) . count ( )
3836 }
3937
40- /// Return true if there are no elements in the map
38+ /// Return ` true` if there are no elements in the map.
4139 fn is_empty ( & self ) -> bool {
4240 self . v . iter ( ) . all ( |elt| elt. is_none ( ) )
4341 }
@@ -49,7 +47,7 @@ impl<V> Mutable for SmallIntMap<V> {
4947}
5048
5149impl < V > Map < uint , V > for SmallIntMap < V > {
52- /// Return a reference to the value corresponding to the key
50+ /// Return a reference to the value corresponding to the key.
5351 fn find < ' a > ( & ' a self , key : & uint ) -> Option < & ' a V > {
5452 if * key < self . v . len ( ) {
5553 match * self . v . get ( * key) {
@@ -63,7 +61,7 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
6361}
6462
6563impl < V > MutableMap < uint , V > for SmallIntMap < V > {
66- /// Return a mutable reference to the value corresponding to the key
64+ /// Return a mutable reference to the value corresponding to the key.
6765 fn find_mut < ' a > ( & ' a mut self , key : & uint ) -> Option < & ' a mut V > {
6866 if * key < self . v . len ( ) {
6967 match * self . v . get_mut ( * key) {
@@ -76,7 +74,7 @@ impl<V> MutableMap<uint, V> for SmallIntMap<V> {
7674 }
7775
7876 /// Insert a key-value pair into the map. An existing value for a
79- /// key is replaced by the new value. Return true if the key did
77+ /// key is replaced by the new value. Return ` true` if the key did
8078 /// not already exist in the map.
8179 fn insert ( & mut self , key : uint , value : V ) -> bool {
8280 let exists = self . contains_key ( & key) ;
@@ -88,14 +86,14 @@ impl<V> MutableMap<uint, V> for SmallIntMap<V> {
8886 !exists
8987 }
9088
91- /// Remove a key-value pair from the map. Return true if the key
92- /// was present in the map, otherwise false.
89+ /// Remove a key-value pair from the map. Return ` true` if the key
90+ /// was present in the map, otherwise ` false` .
9391 fn remove ( & mut self , key : & uint ) -> bool {
9492 self . pop ( key) . is_some ( )
9593 }
9694
9795 /// Insert a key-value pair from the map. If the key already had a value
98- /// present in the map, that value is returned. Otherwise None is returned.
96+ /// present in the map, that value is returned. Otherwise ` None` is returned.
9997 fn swap ( & mut self , key : uint , value : V ) -> Option < V > {
10098 match self . find_mut ( & key) {
10199 Some ( loc) => { return Some ( replace ( loc, value) ) ; }
@@ -121,10 +119,10 @@ impl<V> Default for SmallIntMap<V> {
121119}
122120
123121impl < V > SmallIntMap < V > {
124- /// Create an empty SmallIntMap
122+ /// Create an empty SmallIntMap.
125123 pub fn new ( ) -> SmallIntMap < V > { SmallIntMap { v : vec ! ( ) } }
126124
127- /// Create an empty SmallIntMap with capacity `capacity`
125+ /// Create an empty SmallIntMap with capacity `capacity`.
128126 pub fn with_capacity ( capacity : uint ) -> SmallIntMap < V > {
129127 SmallIntMap { v : Vec :: with_capacity ( capacity) }
130128 }
@@ -134,7 +132,7 @@ impl<V> SmallIntMap<V> {
134132 }
135133
136134 /// An iterator visiting all key-value pairs in ascending order by the keys.
137- /// Iterator element type is (uint, &'r V)
135+ /// Iterator element type is ` (uint, &'r V)`.
138136 pub fn iter < ' r > ( & ' r self ) -> Entries < ' r , V > {
139137 Entries {
140138 front : 0 ,
@@ -145,7 +143,7 @@ impl<V> SmallIntMap<V> {
145143
146144 /// An iterator visiting all key-value pairs in ascending order by the keys,
147145 /// with mutable references to the values
148- /// Iterator element type is (uint, &'r mut V)
146+ /// Iterator element type is ` (uint, &'r mut V)`.
149147 pub fn mut_iter < ' r > ( & ' r mut self ) -> MutEntries < ' r , V > {
150148 MutEntries {
151149 front : 0 ,
@@ -154,7 +152,7 @@ impl<V> SmallIntMap<V> {
154152 }
155153 }
156154
157- /// Empties the hash map, moving all values into the specified closure
155+ /// Empties the hash map, moving all values into the specified closure.
158156 pub fn move_iter ( & mut self )
159157 -> FilterMap < ( uint , Option < V > ) , ( uint , V ) ,
160158 Enumerate < vec:: MoveItems < Option < V > > > >
0 commit comments