summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-31 01:56:56 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-31 01:56:56 +0000
commitd8fa7f3e9b8127911996c36f477bcae3831f7708 (patch)
treea217daf9c2f7ad02bdc0b2e17e258754b19eec30 /utils
parent2af5a445f3905c69c42be5c758c52a2f21b17446 (diff)
l2r bugfixes
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@635 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'utils')
-rwxr-xr-xutils/agenda.h1
-rw-r--r--utils/d_ary_heap.h12
2 files changed, 8 insertions, 5 deletions
diff --git a/utils/agenda.h b/utils/agenda.h
index 1937ad1a..a4940a00 100755
--- a/utils/agenda.h
+++ b/utils/agenda.h
@@ -64,6 +64,7 @@ struct Less {
};
// LocMap and PrioMap are boost property maps put(locmap,key,size_t), Better(get(priomap,k1),get(priomap,k2)) means k1 should be above k2 (be popped first). Locmap and PrioMap may have state; the rest are assumed stateless functors
+// make sure the (default) location is not -1 for anything you add, or else an assertion may trigger
template <class Item,class Better=Less, /* intern_pool args */ class KeyF=get_key<Item>,class HashKey=boost::hash<typename KeyF::result_type>,class EqKey=std::equal_to<typename KeyF::result_type>, class Pool=boost::object_pool<Item> >
struct Agenda : intern_pool<Item,KeyF,HashKey,EqKey,Pool> {
typedef intern_pool<Item,KeyF,HashKey,EqKey,Pool> Intern; // inherited because I want to use construct()
diff --git a/utils/d_ary_heap.h b/utils/d_ary_heap.h
index eee8efe0..20cdab95 100644
--- a/utils/d_ary_heap.h
+++ b/utils/d_ary_heap.h
@@ -12,6 +12,9 @@
#define D_ARY_VERIFY_HEAP 1
// This is a very expensive test so it should be disabled even when NDEBUG is not defined
+# undef D_ARY_HEAP_NULL_INDEX
+# define D_ARY_HEAP_NULL_INDEX (-1) // if you want to test contains before adding, init location to this.
+
/* adapted from boost/graph/detail/d_ary_heap.hpp
local modifications:
@@ -112,8 +115,6 @@
typename Equal = std::equal_to<Value> >
class d_ary_heap_indirect {
BOOST_STATIC_ASSERT (Arity >= 2);
-# undef D_ARY_HEAP_NULL_INDEX
-# define D_ARY_HEAP_NULL_INDEX ((size_type)(-1))
public:
typedef Container container_type;
typedef Size size_type;
@@ -285,9 +286,10 @@
#pragma GCC diagnostic ignored "-Wtype-limits"
// because maybe size_type is signed or unsigned
inline bool contains(const Value &v,size_type i) const {
- return D_ARY_TRACK_OUT_OF_HEAP ?
- (i != D_ARY_HEAP_NULL_INDEX) :
- i>=0 && i<data.size() && equal(v,data[i]); // note: size_type may be signed (don't recommend it, though) - thus i>=0 check to catch uninit. data
+ if (D_ARY_TRACK_OUT_OF_HEAP)
+ return i != D_ARY_HEAP_NULL_INDEX;
+ size_type sz=data.size();
+ return i>=0 && i<sz && equal(v,data[i]); // note: size_type may be signed (don't recommend it, though) - thus i>=0 check to catch uninit. data
}
#include "warning_pop.h"