summaryrefslogtreecommitdiff
path: root/utils/d_ary_heap.h
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-09-23 00:10:52 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-09-23 00:10:52 +0000
commitf8915e0bd1627167b72ca350b82ad31f8cb1fdeb (patch)
treee7ca29aa771db26630cc02f2bd61c2441c475f38 /utils/d_ary_heap.h
parent46c1d1c56535cdaf71e920b12f1cbdcbd1bd9d4f (diff)
pausing earley best-first fsa work
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@656 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'utils/d_ary_heap.h')
-rw-r--r--utils/d_ary_heap.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/utils/d_ary_heap.h b/utils/d_ary_heap.h
index 3a071772..1270638a 100644
--- a/utils/d_ary_heap.h
+++ b/utils/d_ary_heap.h
@@ -283,6 +283,22 @@
return false;
}
+ distance_type best(distance_type null=0) const {
+ return empty() ? null : get(distance,data[0]);
+ }
+ distance_type second_best(distance_type null=0) const {
+ if (data.size()<2) return null;
+ int m=std::min(data.size(),Arity+1);
+// if (m>=Arity) m=Arity+1;
+ distance_type b=get(distance,data[1]);
+ for (int i=2;i<m;++i) {
+ distance_type d=get(distance,data[i]);
+ if (better(d,b))
+ b=d;
+ }
+ return b;
+ }
+
#include "warning_push.h"
#pragma GCC diagnostic ignored "-Wtype-limits"