diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2012-08-07 04:05:41 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-02-12 06:49:40 -0500 |
commit | 8a1bb2c0f2dcaf6f1e5a1d63c5656ce14923e9ae (patch) | |
tree | 5502bd3fc1cedeed62e7e0569c7a0497e30199c1 /native | |
parent | 4d45e06a55ad463247edd949e6d0c98a69fcf332 (diff) |
Allow VarMapper to start at index other than 0
This is in preparation of merged LPs.
Diffstat (limited to 'native')
-rw-r--r-- | native/include/lp_common.h | 15 |
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 | |||
22 | class VarMapper { | 22 | class VarMapper { |
23 | private: | 23 | private: |
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 | ||
43 | public: | 46 | public: |
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 | ||
65 | void set_blocking_objective( | 76 | void set_blocking_objective( |