summaryrefslogtreecommitdiff
path: root/klm/alone/graph.hh
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2012-10-22 14:04:27 +0100
committerKenneth Heafield <github@kheafield.com>2012-10-22 14:04:27 +0100
commit0ff82d648446645df245decc1e9eafad304eb327 (patch)
tree0806d429e4f12b672fd6d0461ba8165679bf424d /klm/alone/graph.hh
parent5f98fe5c4f2a2090eeb9d30c030305a70a8347d1 (diff)
Update search, make it compile
Diffstat (limited to 'klm/alone/graph.hh')
-rw-r--r--klm/alone/graph.hh87
1 files changed, 0 insertions, 87 deletions
diff --git a/klm/alone/graph.hh b/klm/alone/graph.hh
deleted file mode 100644
index 788352c9..00000000
--- a/klm/alone/graph.hh
+++ /dev/null
@@ -1,87 +0,0 @@
-#ifndef ALONE_GRAPH__
-#define ALONE_GRAPH__
-
-#include "alone/labeled_edge.hh"
-#include "search/rule.hh"
-#include "search/types.hh"
-#include "search/vertex.hh"
-#include "util/exception.hh"
-
-#include <boost/noncopyable.hpp>
-#include <boost/pool/object_pool.hpp>
-#include <boost/scoped_array.hpp>
-
-namespace alone {
-
-template <class T> class FixedAllocator : boost::noncopyable {
- public:
- FixedAllocator() : current_(NULL), end_(NULL) {}
-
- void Init(std::size_t count) {
- assert(!current_);
- array_.reset(new T[count]);
- current_ = array_.get();
- end_ = current_ + count;
- }
-
- T &operator[](std::size_t idx) {
- return array_.get()[idx];
- }
-
- T *New() {
- T *ret = current_++;
- UTIL_THROW_IF(ret >= end_, util::Exception, "Allocating past end");
- return ret;
- }
-
- std::size_t Size() const {
- return end_ - array_.get();
- }
-
- private:
- boost::scoped_array<T> array_;
- T *current_, *end_;
-};
-
-class Graph : boost::noncopyable {
- public:
- typedef LabeledEdge Edge;
- typedef search::Vertex Vertex;
-
- Graph() {}
-
- void SetCounts(std::size_t vertices, std::size_t edges) {
- vertices_.Init(vertices);
- edges_.Init(edges);
- }
-
- Vertex *NewVertex() {
- return vertices_.New();
- }
-
- std::size_t VertexSize() const { return vertices_.Size(); }
-
- Vertex &MutableVertex(std::size_t index) {
- return vertices_[index];
- }
-
- Edge *NewEdge() {
- return edges_.New();
- }
-
- std::size_t EdgeSize() const { return edges_.Size(); }
-
- void SetRoot(Vertex *root) { root_ = root; }
-
- Vertex &Root() { return *root_; }
-
- private:
- FixedAllocator<Vertex> vertices_;
- FixedAllocator<Edge> edges_;
-
- Vertex *root_;
-};
-
-} // namespace alone
-
-#endif // ALONE_GRAPH__