31 #ifndef OPENCV_FLANN_HEAP_H_
32 #define OPENCV_FLANN_HEAP_H_
39 #include <unordered_map>
48 bool operator()(
const T&
x,
const T&
y)
const
75 Heap(
const int capacity)
97 return (
int)heap.
size();
132 void reserve(
const int capacity)
148 if (
size() == capacity()) {
187 template <
typename HashableT>
189 const HashableT& poolId,
const int capacity,
int iterThreshold = 0)
194 struct HeapMapValueType {
200 static HeapMapType heapsPool;
201 typename HeapMapType::iterator heapIt = heapsPool.
find(poolId);
203 if (heapIt == heapsPool.end())
206 HeapMapValueType heapAndTimePair = {cv::makePtr<Heap<T>>(capacity), 0};
208 CV_CheckEQ(
static_cast<int>(emplaceResult.second), 1,
"Failed to insert the heap into its memory pool");
209 heapIt = emplaceResult.first;
213 CV_CheckEQ(heapIt->second.heapPtr.use_count(), 1,
"Cannot modify a heap that is currently accessed by another caller");
214 heapIt->second.heapPtr->clear();
215 heapIt->second.heapPtr->reserve(capacity);
216 heapIt->second.iterCounter = 0;
219 if (iterThreshold <= 1) {
224 typename HeapMapType::iterator cleanupIt = heapsPool.begin();
225 while (cleanupIt != heapsPool.end())
227 if (cleanupIt->second.iterCounter++ > iterThreshold)
230 cleanupIt = heapsPool.erase(cleanupIt);
236 return heapIt->second.heapPtr;
InputArrayOfArrays InputArrayOfArrays InputOutputArray InputOutputArray InputOutputArray InputOutputArray Size InputOutputArray InputOutputArray T
Definition: calib3d.hpp:1867
int CvScalar value
Definition: core_c.h:720
CvSize size
Definition: core_c.h:112
const CvArr CvArr * x
Definition: core_c.h:1195
const CvArr * y
Definition: core_c.h:1187
CV_EXPORTS_W int getNumThreads()
Returns the number of threads used by OpenCV for parallel regions.
#define CV_Assert(expr)
Checks a condition at runtime and throws exception if it fails.
Definition: base.hpp:342
Definition: cvstd_wrapper.hpp:74