Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
找到 flann 矩阵的最频繁元素的最佳方法是什么,例如flann::Matrix<int> k_indices
flann::Matrix<int> k_indices
我建议您声明 a map<int,int> counters,然后将 Matrix 的每个元素插入到地图中,如果该元素已经存在,只需增加相对计数器:
map<int,int> counters
map<int,int> counters; ... if(counters.count(yourNumber)==0) counters[yourNumber] = 1 else counters[yourNumber]++
在得到最后一个元素的计数器之后:
return counters.rbegin()->second;
我希望它有帮助!