4141///
4242/// However, creating an r-tree is time consuming
4343/// and runs in `O(n * log(n))`. Thus, r-trees are suited best if many queries and only few
44- /// insertions are made. rstar also supports [bulk loading](RTree::bulk_load),
44+ /// insertions are made. ` rstar` also supports [bulk loading](RTree::bulk_load),
4545/// which cuts down the constant factors when creating an r-tree significantly compared to
4646/// sequential insertions.
4747///
@@ -53,16 +53,13 @@ where
5353/// on fast insertion operations, the resulting r-trees were often suboptimally structured. Another
5454/// heuristic, called `R*-tree` (r-star-tree), was proposed to improve the tree structure at the cost of
5555/// longer insertion operations and is currently the crate's only implemented
56- /// [insertion strategy].
57- ///
58- /// ## Further reading
59- /// For more information refer to the [wikipedia article](https://en.wikipedia.org/wiki/R-tree).
56+ /// [InsertionStrategy].
6057///
6158/// # Usage
6259/// The items inserted into an r-tree must implement the [RTreeObject]
6360/// trait. To support nearest neighbor queries, implement the [PointDistance]
6461/// trait. Some useful geometric primitives that implement the above traits can be found in the
65- /// [crate::primitives]x module. Several primitives in the [`geo-types`](https://docs.rs/geo-types/) crate also
62+ /// [crate::primitives] module. Several primitives in the [`geo-types`](https://docs.rs/geo-types/) crate also
6663/// implement these traits.
6764///
6865/// ## Example
@@ -89,39 +86,21 @@ where
8986/// All types implementing the [Point] trait can be used as underlying point type.
9087/// By default, fixed size arrays can be used as points.
9188///
92- /// ## Type Parameters
93- /// * `T`: The type of objects stored in the r-tree.
94- /// * `Params`: Compile time parameters that change the r-tree's internal layout. Refer to the
95- /// [RTreeParams] trait for more information.
96- ///
97- /// ## Defining methods generic over r-trees
98- /// If a library defines a method that should be generic over the r-tree type signature, make
99- /// sure to include both type parameters like this:
100- /// ```
101- /// # use rstar::{RTree,RTreeObject, RTreeParams};
102- /// pub fn generic_rtree_function<T, Params>(tree: &mut RTree<T, Params>)
103- /// where
104- /// T: RTreeObject,
105- /// Params: RTreeParams
106- /// {
107- /// // ...
108- /// }
109- /// ```
110- /// Otherwise, any user of `generic_rtree_function` would be forced to use
111- /// a tree with default parameters.
89+ /// # Associating Data with Geometries
90+ /// Users wishing to store associated data with geometries can use [crate::primitives::GeomWithData].
11291///
11392/// # Runtime and Performance
11493/// The runtime of query operations (e.g. `nearest neighbor` or `contains`) is usually
11594/// `O(log(n))`, where `n` refers to the number of elements contained in the r-tree.
11695/// A naive sequential algorithm would take `O(n)` time. However, r-trees incur higher
11796/// build up times: inserting an element into an r-tree costs `O(log(n))` time.
11897///
119- /// ## Bulk loading
98+ /// # Bulk loading
12099/// In many scenarios, insertion is only carried out once for many points. In this case,
121100/// [RTree::bulk_load] will be considerably faster. Its total run time
122- /// is still `O(log(n))`.
101+ /// is still `O(log(n))`. **Note the performance caveat related to the computation of the envelope**.
123102///
124- /// ## Element distribution
103+ /// # Element distribution
125104/// The tree's performance heavily relies on the spatial distribution of its elements.
126105/// Best performance is achieved if:
127106/// * No element is inserted more than once
@@ -131,9 +110,33 @@ where
131110/// For the edge case that all elements are overlapping (e.g, one and the same element
132111/// is contained `n` times), the performance of most operations usually degrades to `O(n)`.
133112///
113+ /// # Type Parameters
114+ /// * `T`: The type of objects stored in the r-tree.
115+ /// * `Params`: Compile time parameters that change the r-tree's internal layout. Refer to the
116+ /// [RTreeParams] trait for more information.
117+ ///
118+ /// # Defining methods generic over r-trees
119+ /// If a library defines a method that should be generic over the r-tree type signature, make
120+ /// sure to include both type parameters like this:
121+ /// ```
122+ /// # use rstar::{RTree,RTreeObject, RTreeParams};
123+ /// pub fn generic_rtree_function<T, Params>(tree: &mut RTree<T, Params>)
124+ /// where
125+ /// T: RTreeObject,
126+ /// Params: RTreeParams
127+ /// {
128+ /// // ...
129+ /// }
130+ /// ```
131+ /// Otherwise, any user of `generic_rtree_function` would be forced to use
132+ /// a tree with default parameters.
133+ ///
134134/// # (De)Serialization
135135/// Enable the `serde` feature for [Serde](https://crates.io/crates/serde) support.
136136///
137+ /// ## Further reading
138+ /// For more information refer to the [wikipedia article](https://en.wikipedia.org/wiki/R-tree).
139+ ///
137140#[ derive( Clone ) ]
138141#[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
139142#[ cfg_attr(
@@ -209,8 +212,9 @@ where
209212 /// Bulk loading runs in `O(n * log(n))`, where `n` is the number of loaded
210213 /// elements.
211214 ///
212- /// Note that the envelope of each element will be accessed many times,
213- /// so if that computation is expensive, consider memoizing it using [`CachedEnvelope`][crate::primitives::CachedEnvelope].
215+ /// # Note
216+ /// The envelope of each element will be accessed many times during loading. If that computation
217+ /// is expensive, **consider memoizing it** using [`CachedEnvelope`][crate::primitives::CachedEnvelope].
214218 pub fn bulk_load ( elements : Vec < T > ) -> Self {
215219 Self :: bulk_load_with_params ( elements)
216220 }
0 commit comments