aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--native/include/lp_common.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/native/include/lp_common.h b/native/include/lp_common.h
index 06519d1..d5a8a60 100644
--- a/native/include/lp_common.h
+++ b/native/include/lp_common.h
@@ -22,10 +22,13 @@ enum blocking_type
22class VarMapper { 22class VarMapper {
23private: 23private:
24 hashmap<uint64_t, unsigned int> map; 24 hashmap<uint64_t, unsigned int> map;
25 unsigned int next_var;
25 26
26 void insert(uint64_t key) 27 void insert(uint64_t key)
27 { 28 {
28 unsigned int idx = map.size(); 29 assert(next_var < UINT_MAX);
30
31 unsigned int idx = next_var++;
29 map[key] = idx; 32 map[key] = idx;
30 } 33 }
31 34
@@ -41,6 +44,9 @@ private:
41 } 44 }
42 45
43public: 46public:
47 VarMapper(unsigned int start_var = 0)
48 : next_var(start_var)
49 {}
44 50
45 unsigned int lookup(unsigned int task_id, unsigned int res_id, unsigned int req_id, 51 unsigned int lookup(unsigned int task_id, unsigned int res_id, unsigned int req_id,
46 blocking_type type) 52 blocking_type type)
@@ -56,10 +62,15 @@ public:
56 map.clear(); 62 map.clear();
57 } 63 }
58 64
59 unsigned int get_num_vars() 65 unsigned int get_num_vars() const
60 { 66 {
61 return map.size(); 67 return map.size();
62 } 68 }
69
70 unsigned int get_next_var() const
71 {
72 return next_var;
73 }
63}; 74};
64 75
65void set_blocking_objective( 76void set_blocking_objective(