Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Really switch to sparsetable instead of segment tree

  • Loading branch information...
commit 9dea4f3d3e383986f89cfb447e8b02d056382ec8 1 parent 679abff
@dhruvbird dhruvbird authored
Showing with 16 additions and 10 deletions.
  1. +3 −3 include/suggest.hpp
  2. +7 −6 src/main.cpp
  3. +6 −1 tests/containers.cpp
View
6 include/suggest.hpp
@@ -41,7 +41,7 @@ typedef std::priority_queue<PhraseRange> pqpr_t;
vp_t
-suggest(PhraseMap &pm, SegmentTree &st, std::string prefix, uint_t n = 16) {
+suggest(PhraseMap &pm, RMQ &st, std::string prefix, uint_t n = 16) {
pvpi_t phrases = pm.query(prefix);
// cerr<<"Got "<<phrases.second - phrases.first<<" candidate phrases from PhraseMap"<<endl;
@@ -94,7 +94,7 @@ suggest(PhraseMap &pm, SegmentTree &st, std::string prefix, uint_t n = 16) {
}
vp_t
-naive_suggest(PhraseMap &pm, SegmentTree &st, std::string prefix, uint_t n = 16) {
+naive_suggest(PhraseMap& pm, RMQ& st, std::string prefix, uint_t n = 16) {
pvpi_t phrases = pm.query(prefix);
std::vector<uint_t> indexes;
vp_t ret;
@@ -134,7 +134,7 @@ namespace _suggest {
pm.finalize();
- SegmentTree st;
+ RMQ st;
vui_t weights;
for (size_t i = 0; i < pm.repr.size(); ++i) {
weights.push_back(pm.repr[i].weight);
View
13 src/main.cpp
@@ -5,6 +5,12 @@
#include <unistd.h>
#include <time.h>
+#if !defined RMQ
+// #define RMQ SegmentTree
+#define RMQ SparseTable
+#endif
+
+
// Custom-includes
#include "mongoose.h"
#include <include/segtree.hpp>
@@ -35,16 +41,11 @@
// Undefine the macro below to use C-style I/O routines.
// #define USE_CXX_IO
-#if !defined RMQ
-// #define RMQ SegmentTree
-#define RMQ SparseTable
-#endif
-
PhraseMap pm;
-SegmentTree st;
+RMQ st;
bool building = false;
unsigned long long nreq = 0;
time_t started_at;
View
7 tests/containers.cpp
@@ -1,7 +1,12 @@
+#if !defined RMQ
+// #define RMQ SegmentTree
+#define RMQ SparseTable
+#endif
+
+#include <include/sparsetable.hpp>
#include <include/segtree.hpp>
#include <include/phrase_map.hpp>
#include <include/suggest.hpp>
-#include <include/sparsetable.hpp>
int
main() {
Please sign in to comment.
Something went wrong with that request. Please try again.