knncolle
Collection of KNN methods in C++
Loading...
Searching...
No Matches
Searcher.hpp
Go to the documentation of this file.
1#ifndef KNNCOLLE_SEARCHER_HPP
2#define KNNCOLLE_SEARCHER_HPP
3
4#include <vector>
5#include <stdexcept>
6
13namespace knncolle {
14
27template<typename Index_, typename Float_>
28class Searcher {
29public:
33 virtual ~Searcher() = default;
56 virtual void search(Index_ i, Index_ k, std::vector<Index_>* output_indices, std::vector<Float_>* output_distances) = 0;
57
72 virtual void search(const Float_* query, Index_ k, std::vector<Index_>* output_indices, std::vector<Float_>* output_distances) = 0;
73
74public:
80 virtual bool can_search_all() const {
81 return false;
82 }
83
101 virtual Index_ search_all([[maybe_unused]] Index_ i, [[maybe_unused]] Float_ distance, [[maybe_unused]] std::vector<Index_>* output_indices, [[maybe_unused]] std::vector<Float_>* output_distances) {
102 throw std::runtime_error("distance-based searches not supported");
103 return 0;
104 }
105
121 virtual Index_ search_all([[maybe_unused]] const Float_* query, [[maybe_unused]] Float_ distance, [[maybe_unused]] std::vector<Index_>* output_indices, [[maybe_unused]] std::vector<Float_>* output_distances) {
122 throw std::runtime_error("distance-based searches not supported");
123 return 0;
124 }
125};
126
127}
128
129#endif
Interface for searching nearest-neighbor search indices.
Definition Searcher.hpp:28
virtual void search(Index_ i, Index_ k, std::vector< Index_ > *output_indices, std::vector< Float_ > *output_distances)=0
virtual bool can_search_all() const
Definition Searcher.hpp:80
virtual void search(const Float_ *query, Index_ k, std::vector< Index_ > *output_indices, std::vector< Float_ > *output_distances)=0
virtual Index_ search_all(const Float_ *query, Float_ distance, std::vector< Index_ > *output_indices, std::vector< Float_ > *output_distances)
Definition Searcher.hpp:121
virtual Index_ search_all(Index_ i, Float_ distance, std::vector< Index_ > *output_indices, std::vector< Float_ > *output_distances)
Definition Searcher.hpp:101
Collection of KNN algorithms.
Definition Bruteforce.hpp:22