@@ -42,7 +42,7 @@ use std::{cmp::PartialEq, iter::FromIterator};
4242/// }
4343///
4444/// // Construct map with a compactor that automatically combines
45- /// // cells with the same save value.
45+ /// // cells with the same value.
4646/// let mut monaco = HexTreeMap::with_compactor(EqCompactor);
4747///
4848/// // Now extend the map with cells and a region value.
@@ -66,7 +66,7 @@ use std::{cmp::PartialEq, iter::FromIterator};
6666pub struct HexTreeMap < V , C = NullCompactor > {
6767 /// All h3 0 base cell indices in the tree
6868 pub ( crate ) nodes : Box < [ Option < Box < Node < V > > > ] > ,
69- /// User-provided compator . Defaults to the null compactor.
69+ /// User-provided compactor . Defaults to the null compactor.
7070 compactor : C ,
7171}
7272
@@ -121,7 +121,7 @@ impl<V, C> HexTreeMap<V, C> {
121121 /// `self`.
122122 ///
123123 /// This method is useful if you want to use one compaction
124- /// strategy for creating an initial, then another one for updates
124+ /// strategy for creating an initial tree , then another one for updates
125125 /// later.
126126 pub fn replace_compactor < NewC > ( self , new_compactor : NewC ) -> HexTreeMap < V , NewC > {
127127 HexTreeMap {
@@ -130,12 +130,11 @@ impl<V, C> HexTreeMap<V, C> {
130130 }
131131 }
132132
133- /// Returns the number of H3 cells in the set .
133+ /// Returns the number of H3 cells in the map .
134134 ///
135- /// This method only considers complete, or leaf, cells in the
136- /// set. Due to automatic compaction, this number may be
137- /// significantly smaller than the number of source cells used to
138- /// create the set.
135+ /// This method only counts leaf cells (complete entries) in the
136+ /// map. Due to automatic compaction, this number may be
137+ /// significantly smaller than the number of cells originally inserted.
139138 pub fn len ( & self ) -> usize {
140139 self . nodes . iter ( ) . flatten ( ) . map ( |node| node. len ( ) ) . sum ( )
141140 }
@@ -145,17 +144,15 @@ impl<V, C> HexTreeMap<V, C> {
145144 self . len ( ) == 0
146145 }
147146
148- /// Returns `true` if the set fully contains `cell`.
147+ /// Returns `true` if the map fully contains `cell`.
149148 ///
150- /// This method will return `true` if any of the following are
151- /// true:
149+ /// This method returns `true` if any of the following are true:
152150 ///
153- /// 1. There was an earlier [insert][Self::insert] call with
154- /// precisely this target cell.
155- /// 2. Several previously inserted cells coalesced into
156- /// precisely this target cell.
157- /// 3. The set contains a complete (leaf) parent of this target
158- /// cell due to 1 or 2.
151+ /// 1. This exact cell was previously inserted.
152+ /// 2. Several previously inserted cells were compacted into
153+ /// this cell as their parent.
154+ /// 3. The map contains a parent of this cell (due to 1 or 2),
155+ /// meaning this cell inherits its parent's value.
159156 pub fn contains ( & self , cell : Cell ) -> bool {
160157 let base_cell = cell. base ( ) ;
161158 match self . nodes [ base_cell as usize ] . as_ref ( ) {
@@ -167,11 +164,11 @@ impl<V, C> HexTreeMap<V, C> {
167164 }
168165 }
169166
170- /// Returns a reference to the value corresponding to the given
171- /// target cell or one of its parents.
167+ /// Returns a reference to the value for the given cell or its nearest parent.
172168 ///
173- /// Note that this method also returns a Cell, which may be a
174- /// parent of the target cell provided.
169+ /// Returns `Some((cell, value))` where `cell` is either the queried cell
170+ /// or a parent cell that contains it. Returns `None` if no matching cell
171+ /// or parent is found.
175172 #[ inline]
176173 pub fn get ( & self , cell : Cell ) -> Option < ( Cell , & V ) > {
177174 match self . get_raw ( cell) {
@@ -192,11 +189,11 @@ impl<V, C> HexTreeMap<V, C> {
192189 }
193190 }
194191
195- /// Returns a mutable reference to the value corresponding to the
196- /// given target cell or one of its parents.
192+ /// Returns a mutable reference to the value for the given cell or its nearest parent.
197193 ///
198- /// Note that this method also returns a Cell, which may be a
199- /// parent of the target cell provided.
194+ /// Returns `Some((cell, value))` where `cell` is either the queried cell
195+ /// or a parent cell that contains it. Returns `None` if no matching cell
196+ /// or parent is found.
200197 #[ inline]
201198 pub fn get_mut ( & mut self , cell : Cell ) -> Option < ( Cell , & mut V ) > {
202199 match self . get_raw_mut ( cell) {
@@ -242,7 +239,7 @@ impl<V, C> HexTreeMap<V, C> {
242239 crate :: iteration:: IterMut :: new ( & mut self . nodes , CellStack :: new ( ) )
243240 }
244241
245- /// An iterator visiting the specified cell or its children
242+ /// An iterator visiting the specified cell or its children with
246243 /// references to the values.
247244 pub fn descendants ( & self , cell : Cell ) -> impl Iterator < Item = ( Cell , & V ) > {
248245 let base_cell = cell. base ( ) ;
0 commit comments