From 16ca40c21a4b2dcff30fe1b94c67bf3f58aeaba5 Mon Sep 17 00:00:00 2001 From: graehl Date: Sat, 24 Jul 2010 07:35:40 +0000 Subject: minor - disable hash sparse_vector for now git-svn-id: https://ws10smt.googlecode.com/svn/trunk@396 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/small_vector.h | 1 - decoder/sparse_vector.h | 24 ++++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'decoder') diff --git a/decoder/small_vector.h b/decoder/small_vector.h index b5d86231..4183cde2 100644 --- a/decoder/small_vector.h +++ b/decoder/small_vector.h @@ -168,7 +168,6 @@ public: ptr_to_small(); } - void compact() { compact(size_); } diff --git a/decoder/sparse_vector.h b/decoder/sparse_vector.h index 1733a4bd..e58485c0 100644 --- a/decoder/sparse_vector.h +++ b/decoder/sparse_vector.h @@ -370,10 +370,26 @@ private: MapType values_; }; +//like a pair but can live in a union, because it lacks default+copy ctors, dtor. +template +struct feature_val { + int fid; + T val; +}; + +template +inline feature_val featval(int fid,T const &val) { + feature_val f; + f.fid=fid; + f.val=val; + return f; +} + + // doesn't support fast indexing directly template class SparseVectorList { - typedef typename std::pair Pair; + typedef feature_val Pair; typedef SmallVector List; typedef typename List::const_iterator const_iterator; SparseVectorList() { } @@ -383,7 +399,7 @@ class SparseVectorList { int c=0; for (;i *to) const { for (int i=0;iset_value(p[i].first,p[i].second); + to->set_value(p[i].fid,p[i].val); } void copy_to(SparseVector *to) const { to->clear(); -- cgit v1.2.3