refactor: move searching to static library
This commit is contained in:
parent
8ed4b9ac71
commit
32a1cd7533
11 changed files with 20 additions and 2 deletions
12
lib_vector_search/include/finder.h
Normal file
12
lib_vector_search/include/finder.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using std::string, std::string_view, std::vector;
|
||||
|
||||
class Finder {
|
||||
public:
|
||||
virtual ~Finder() = default;
|
||||
virtual vector<const string *> find_prefix(string_view search_term) const = 0;
|
||||
};
|
12
lib_vector_search/include/linear_finder.h
Normal file
12
lib_vector_search/include/linear_finder.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include "finder.h"
|
||||
|
||||
class LinearFinder : public Finder {
|
||||
private:
|
||||
const vector<string> &word_list_;
|
||||
|
||||
public:
|
||||
LinearFinder(const vector<string> &word_list);
|
||||
vector<const string *> find_prefix(string_view search_term) const override;
|
||||
};
|
13
lib_vector_search/include/parallel_finder.h
Normal file
13
lib_vector_search/include/parallel_finder.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "finder.h"
|
||||
|
||||
class ParallelFinder : public Finder {
|
||||
private:
|
||||
const size_t thread_count_;
|
||||
const vector<string> &word_list_;
|
||||
|
||||
public:
|
||||
ParallelFinder(const vector<string> &word_list, size_t thread_count);
|
||||
vector<const string *> find_prefix(string_view search_term) const override;
|
||||
};
|
16
lib_vector_search/include/timer.h
Normal file
16
lib_vector_search/include/timer.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
|
||||
class Timer {
|
||||
private:
|
||||
std::string name_;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> start_;
|
||||
|
||||
public:
|
||||
Timer(std::string_view name);
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
};
|
12
lib_vector_search/include/word_list_generator.h
Normal file
12
lib_vector_search/include/word_list_generator.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class WordListGenerator {
|
||||
private:
|
||||
static const std::string charset_;
|
||||
|
||||
public:
|
||||
std::vector<std::string> generate();
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue