Project: finder, src: TrMatrix.h


転置インデックスを表すクラス
#ifndef TRMATRIX_H_
#define TRMATRIX_H_

#include "BPTree.h"
#include "DocumentList.h"
#include "NGram.h"
#include "ucs4.h"
#if defined(NO_UNORDERED_MAP)
#include "unordered_map.h"
#else
#include <unordered_map>
#endif

class TrMatrix {
 private:
  std::unordered_map<NGram, DocumentList, NGram> matrix;
  std::size_t quantity;

 public:
  TrMatrix() : matrix(), quantity(0) {}
  void analyze(unsigned long long id, const char *utf8, int len8);
  void save2BPTree(BPTree &bptree);
  void clear() {
    matrix.clear();
    quantity = 0;
  }
  std::size_t size() const {
    return quantity;
  }
};

#endif //TRMATRIX_H_