libmonaa  0.5.2
ans_vec.hh
1 #pragma once
2 #include <iomanip>
3 #include <iostream>
4 #include <vector>
5 
6 #include "zone.hh"
7 
17 template <class Container> class AnsContainer {
18 protected:
20  Container vec;
21 
22 public:
24  AnsContainer(const Container vec) : vec(vec) {}
26  AnsContainer() : vec() {}
32  std::size_t size() const { return vec.size(); }
38  void push_back(typename Container::value_type in) { vec.push_back(in); }
42  void clear() { vec.clear(); }
50  void reserve(std::size_t n) { vec.reserve(n); }
51 };
52 
53 template <class T> class AnsVec : public AnsContainer<std::vector<T>> {
54 public:
55  typename std::vector<T>::iterator begin() {
56  return AnsContainer<std::vector<T>>::vec.begin();
57  }
58  typename std::vector<T>::iterator end() {
60  }
61 };
62 
63 template <class T> class IntContainer {
64 private:
65  std::size_t count = 0;
66 
67 public:
68  std::size_t size() const { return count; }
69  void push_back(T) { count++; }
70  void clear() { count = 0; }
71  void reserve(std::size_t) {}
72  using value_type = T;
73 };
74 
75 template <class T> using AnsNum = AnsContainer<IntContainer<T>>;
76 
85 private:
86  std::size_t count = 0;
87  bool isQuiet = false;
88 
89 public:
95  PrintContainer(bool isQuiet) : isQuiet(isQuiet) {}
97  std::size_t size() const { return count; }
98  void push_back(const Zone &ans) {
99  count++;
100  if (!isQuiet) {
101  printf("%10lf %8s t %s %10lf\n", -ans.value(0, 1).first,
102  (ans.value(0, 1).second ? "<=" : "<"),
103  (ans.value(1, 0).second ? "<=" : "<"), ans.value(1, 0).first);
104  printf("%10lf %8s t' %s %10lf\n", -ans.value(0, 2).first,
105  (ans.value(0, 2).second ? "<=" : "<"),
106  (ans.value(2, 0).second ? "<=" : "<"), ans.value(2, 0).first);
107  printf("%10lf %8s t' - t %s %10lf\n", -ans.value(1, 2).first,
108  (ans.value(1, 2).second ? "<=" : "<"),
109  (ans.value(2, 1).second ? "<=" : "<"), ans.value(2, 1).first);
110  puts("=============================");
111  }
112  }
114  void clear() { count = 0; }
116  void reserve(std::size_t) {}
117  using value_type = Zone;
118 };
119 
Container class for the output zones.
Definition: ans_vec.hh:17
void clear()
Remove all the contained zones.
Definition: ans_vec.hh:42
std::size_t size() const
Returns the number of the contained zones.
Definition: ans_vec.hh:32
void reserve(std::size_t n)
Reserve the space to contain zones.
Definition: ans_vec.hh:50
AnsContainer(const Container vec)
Constructor.
Definition: ans_vec.hh:24
Container vec
The actual container of the zones.
Definition: ans_vec.hh:20
void push_back(typename Container::value_type in)
Append a zone to the container.
Definition: ans_vec.hh:38
AnsContainer()
Constructor.
Definition: ans_vec.hh:26
Definition: ans_vec.hh:53
Definition: ans_vec.hh:63
A pseudo-container class to print the given zone to stdout. This is given to AnsContainer.
Definition: ans_vec.hh:84
std::size_t size() const
Returns the count of output zones.
Definition: ans_vec.hh:97
void reserve(std::size_t)
Does nothing.
Definition: ans_vec.hh:116
void clear()
Resets the count of output zones.
Definition: ans_vec.hh:114
PrintContainer(bool isQuiet)
Constructor.
Definition: ans_vec.hh:95
Implementation of a zone with DBM.
Definition: zone.hh:43