summaryrefslogtreecommitdiff
path: root/klm/search/final.hh
blob: 50e62cf2ede64485deb5e51b5b42f7cf59b4850c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef SEARCH_FINAL__
#define SEARCH_FINAL__

#include "search/header.hh"
#include "util/pool.hh"

namespace search {

// A full hypothesis with pointers to children.
class Final : public Header {
  public:
    Final() {}

    Final(util::Pool &pool, Score score, Arity arity, Note note) 
      : Header(pool.Allocate(Size(arity)), arity) {
      SetScore(score);
      SetNote(note);
    }

    // These are arrays of length GetArity().
    Final *Children() {
      return reinterpret_cast<Final*>(After());
    }
    const Final *Children() const {
      return reinterpret_cast<const Final*>(After());
    }

  private:
    static std::size_t Size(Arity arity) {
      return kHeaderSize + arity * sizeof(const Final);
    }
};

} // namespace search

#endif // SEARCH_FINAL__