@@ -45,7 +45,7 @@ ThreadPool::~ThreadPool() {
4545}
4646
4747template <class F , class ... Args>
48- auto ThreadPool::enqueue (F&& f, Args&&... args) -> std::future<typename std::result_of<F(Args...)>::type> {
48+ auto ThreadPool::enqueue (F&& f, Args&&... args) const -> std::future<typename std::result_of<F(Args...)>::type> {
4949 using return_type = typename std::result_of<F (Args...)>::type;
5050
5151 auto task = std::make_shared<std::packaged_task<return_type ()>>(
@@ -169,9 +169,9 @@ void RTree<T>::query_recursive(const RTreeNode<T>* node, const geometry::Rectang
169169 }
170170
171171 if (node->is_leaf ) {
172- for (const auto & [object, bbox] : node->entries ) {
173- if (bbox .intersects (range)) {
174- result.push_back (object );
172+ for (const auto & entry : node->entries ) {
173+ if (entry. second .intersects (range)) {
174+ result.push_back (entry. first );
175175 }
176176 }
177177 } else {
@@ -201,7 +201,7 @@ void RTree<T>::clear() {
201201}
202202
203203template <typename T>
204- bool RTree<T>::remove(const T& object, const geometry::Rectangle& bbox) {
204+ bool RTree<T>::remove(const T& /* object*/ , const geometry::Rectangle& /* bbox*/ ) {
205205 // Implementation of removal is complex and would require rebalancing
206206 // For now, we'll implement a simple version
207207 // In production, you'd want a more sophisticated removal algorithm
@@ -233,6 +233,8 @@ void HierarchicalSpatialIndex<T>::create_block_index(const std::string& block_na
233233 // This assumes T has a bounding_box() method or is itself a Rectangle
234234 if constexpr (std::is_same_v<T, geometry::Rectangle>) {
235235 return obj;
236+ } else if constexpr (std::is_same_v<T, geometry::Point>) {
237+ return geometry::Rectangle (obj.x , obj.y , 0.0 , 0.0 );
236238 } else {
237239 return obj.bounding_box ();
238240 }
@@ -265,12 +267,22 @@ IPBlock* HierarchicalSpatialIndex<T>::find_block(const std::string& name) const
265267 return search (root_block.get (), name);
266268}
267269
270+ template <typename T>
271+ std::string HierarchicalSpatialIndex<T>::find_optimal_block(const geometry::Rectangle& /* bbox*/ ) const {
272+ // For now, simply return "root". In a real implementation, you would:
273+ // 1. Traverse the hierarchy to find the best-fitting block
274+ // 2. Consider load balancing across blocks
275+ // 3. Check spatial locality
276+ return " root" ;
277+ }
278+
268279template <typename T>
269280std::vector<std::pair<T, T>> HierarchicalSpatialIndex<T>::parallel_find_intersections() const {
270281 std::vector<std::future<std::vector<std::pair<T, T>>>> futures;
271282
272283 // Dispatch intersection finding to different threads for each block
273- for (const auto & [block_name, index] : block_indices) {
284+ for (const auto & block_pair : block_indices) {
285+ const auto & index = block_pair.second ;
274286 auto future = thread_pool.enqueue ([&index]() {
275287 return index->find_potential_intersections ();
276288 });
@@ -293,7 +305,9 @@ std::vector<std::future<std::vector<T>>> HierarchicalSpatialIndex<T>::dispatch_p
293305
294306 std::vector<std::future<std::vector<T>>> futures;
295307
296- for (const auto & [block_name, index] : block_indices) {
308+ for (const auto & block_pair : block_indices) {
309+ const auto & block_name = block_pair.first ;
310+ const auto & index = block_pair.second ;
297311 // Check if block intersects with query range
298312 IPBlock* block = find_block (block_name);
299313 if (block && block->intersects (range)) {
@@ -377,6 +391,15 @@ typename HierarchicalSpatialIndex<T>::Statistics HierarchicalSpatialIndex<T>::ge
377391 return stats;
378392}
379393
394+ template <typename T>
395+ void HierarchicalSpatialIndex<T>::partition_objects_by_zorder(const std::vector<std::pair<T, geometry::Rectangle>>& objects) {
396+ // Simple implementation: bucket objects by Z-order curve
397+ for (const auto & obj_pair : objects) {
398+ uint64_t z_order = ZOrderCurve::encode_point (obj_pair.second .center (), world_bounds);
399+ zorder_buckets[z_order].push_back (obj_pair.first );
400+ }
401+ }
402+
380403template <typename T>
381404void HierarchicalSpatialIndex<T>::optimize_for_query_pattern(
382405 const std::vector<geometry::Rectangle>& query_patterns) {
@@ -387,7 +410,8 @@ void HierarchicalSpatialIndex<T>::optimize_for_query_pattern(
387410 std::unordered_map<std::string, int > block_access_count;
388411
389412 for (const auto & query_rect : query_patterns) {
390- for (const auto & [block_name, index] : block_indices) {
413+ for (const auto & block_pair : block_indices) {
414+ const auto & block_name = block_pair.first ;
391415 IPBlock* block = find_block (block_name);
392416 if (block && block->intersects (query_rect)) {
393417 block_access_count[block_name]++;
@@ -410,5 +434,4 @@ template class HierarchicalSpatialIndex<geometry::Rectangle>;
410434template class HierarchicalSpatialIndex <geometry::Point>;
411435
412436} // namespace spatial
413- } // namespace zlayout
414- ```
437+ } // namespace zlayout
0 commit comments