Added member function for retrieving nbest list items without sorting.

This commit is contained in:
Ulrich Germann 2015-06-05 16:21:09 +01:00
parent 5a56a5b496
commit 5cb1d95e09

View File

@ -1,3 +1,4 @@
// -*- mode: c++; tab-width: 2; indent-tabs-mode:nil; -*-
#ifndef __n_best_list_h
#define __n_best_list_h
#include <algorithm>
@ -27,6 +28,7 @@ public:
NBestList(size_t const max_size);
bool add(THINGY const& item);
THINGY const& operator[](int i) const;
THINGY const& get_unsorted(int i) const;
size_t size() const {
return m_heap.size();
}
@ -81,5 +83,15 @@ operator[](int i) const
return m_list[m_order.at(i)];
}
template<typename THINGY, typename CMP>
THINGY const&
NBestList<THINGY,CMP>::
get_unsorted(int i) const
{
if (i < 0) i += m_heap.size();
return m_list[m_heap.at(i)];
}
}
#endif