-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36a255a
commit b8239a1
Showing
8 changed files
with
157 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "MultiSketchIndex.h" | ||
|
||
MultiSketchIndex::MultiSketchIndex() { | ||
// Constructor | ||
} | ||
|
||
MultiSketchIndex::~MultiSketchIndex() { | ||
// Destructor | ||
} | ||
|
||
|
||
void MultiSketchIndex::add_hash(hash_t hash_value, std::vector<int> sketch_indices) { | ||
// Add the hash value to the index | ||
if (multi_sketch_index.find(hash_value) == multi_sketch_index.end()) { | ||
multi_sketch_index[hash_value] = sketch_indices; | ||
return; | ||
} | ||
|
||
for (int i = 0; i < sketch_indices.size(); i++) { | ||
add_hash(hash_value, sketch_indices[i]); | ||
} | ||
} | ||
|
||
|
||
void MultiSketchIndex::add_hash(hash_t hash_value, int sketch_index) { | ||
// Add the hash value to the index | ||
if (multi_sketch_index.find(hash_value) == multi_sketch_index.end()) { | ||
multi_sketch_index[hash_value] = std::vector<int>(); | ||
} | ||
multi_sketch_index[hash_value].push_back(sketch_index); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
const std::vector<int>& MultiSketchIndex::get_sketch_indices(hash_t hash_value) { | ||
// Get the sketch indices for the hash value | ||
if (multi_sketch_index.find(hash_value) == multi_sketch_index.end()) { | ||
return std::vector<int>(); | ||
} | ||
return multi_sketch_index[hash_value]; | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#ifndef SKETCH_H | ||
#define SKETCH_H | ||
|
||
#include <iostream> | ||
#include <vector> | ||
|
||
|
||
#ifndef HASH_T | ||
#define HASH_T | ||
typedef unsigned long long int hash_t; | ||
#endif | ||
|
||
|
||
/** | ||
* @brief MultiSketchIndex class, which is used to store the index of many sketches. | ||
* | ||
*/ | ||
class MultiSketchIndex { | ||
public: | ||
MultiSketchIndex(); | ||
~MultiSketchIndex(); | ||
|
||
/** | ||
* @brief Add a hash value to the index. | ||
* | ||
* @param hash_value The hash value to add. | ||
* @param sketch_index The index of the sketch in which this hash value appears. | ||
*/ | ||
void add_hash(hash_t hash_value, int sketch_index); | ||
|
||
|
||
|
||
/** | ||
* @brief Add a hash value to the index. | ||
* | ||
* @param hash_value The hash value to add. | ||
* @param sketch_indices Indices of the sketches in which this hash value appears. | ||
*/ | ||
void add_hash(hash_t hash_value, std::vector<int> sketch_indices); | ||
|
||
|
||
|
||
/** | ||
* @brief Get the sketch indices for a hash value. | ||
* | ||
* @param hash_value The hash value to get the sketch indices for. | ||
* @return const std::vector<int>& The sketch indices in which the hash value appears. | ||
*/ | ||
const std::vector<int>& get_sketch_indices(hash_t hash_value); | ||
|
||
|
||
/** | ||
* @brief Check if a hash value exists in the index. | ||
* | ||
* @param hash_value The hash value to check. | ||
* @return true If the hash value exists in the index. | ||
* @return false If the hash value does not exist in the index. | ||
*/ | ||
bool hash_exists(hash_t hash_value) { | ||
return multi_sketch_index.find(hash_value) != multi_sketch_index.end(); | ||
} | ||
|
||
|
||
private: | ||
std::unordered_map<hash_t, std::vector<int>> multi_sketch_index; | ||
|
||
}; | ||
|
||
#endif |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters