CMR  1.3.0
nested_minor_sequence.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 #include <cassert>
5 #include <cstring>
6 
7 namespace tu
8 {
9 
16  {
17  public:
18 
24  {
26  ONE_ROW = -2,
32  };
33 
39 
44  virtual ~nested_minor_sequence();
45 
52  void push(extension_type type);
53 
61  static size_t get_extension_height(extension_type type);
62 
70  static size_t get_extension_width(extension_type type);
71 
79  extension_type get_extension(size_t index) const
80  {
81  return extensions_[index];
82  }
83 
91  size_t get_extension_height(size_t index) const
92  {
93  return get_extension_height(get_extension(index));
94  }
95 
103  size_t get_extension_width(size_t index) const
104  {
105  return get_extension_width(get_extension(index));
106  }
107 
112  size_t height() const
113  {
114  return height_;
115  }
116 
121  size_t width() const
122  {
123  return width_;
124  }
125 
130  size_t size() const
131  {
132  return extensions_.size();
133  }
134 
135  void resize(size_t new_size)
136  {
137  assert(new_size <= extensions_.size() && new_size > 0);
138  extensions_.resize(new_size);
139  }
140 
141  private:
142 
143  std::vector<extension_type> extensions_;
144  size_t height_;
145  size_t width_;
146  };
147 
152  template <typename NestedMinorSequenceType>
154  {
155  public:
162  nested_minor_sequence_transposed(NestedMinorSequenceType& sequence) :
163  sequence_(sequence)
164  {
165 
166  }
167 
175  sequence_(other.sequence_)
176  {
177 
178  }
179 
185  {
186 
187  }
188 
196  {
197  sequence_.push(nested_minor_sequence::extension_type(-int(type)));
198  }
199 
208  {
209  return nested_minor_sequence::extension_type(-int(sequence_.get_extension(index)));
210  }
211 
219  size_t get_extension_height(size_t index) const
220  {
221  return sequence_.get_extension_width(index);
222  }
223 
231  size_t get_extension_width(size_t index) const
232  {
233  return sequence_.get_extension_height(index);
234  }
235 
240  size_t height() const
241  {
242  return sequence_.width();
243  }
244 
249  size_t width() const
250  {
251  return sequence_.height();
252  }
253 
258  size_t size() const
259  {
260  return sequence_.size();
261  }
262 
263  private:
264  NestedMinorSequenceType& sequence_;
265  };
266 
274  template <typename NestedMinorSequenceType>
276  NestedMinorSequenceType& sequence)
277  {
279  }
280 
281 } /* namespace tu */
Definition: nested_minor_sequence.hpp:154
void push(nested_minor_sequence::extension_type type)
Definition: nested_minor_sequence.hpp:195
size_t width() const
Definition: nested_minor_sequence.hpp:249
virtual ~nested_minor_sequence_transposed()
Definition: nested_minor_sequence.hpp:184
nested_minor_sequence::extension_type get_extension(size_t index) const
Definition: nested_minor_sequence.hpp:207
size_t height() const
Definition: nested_minor_sequence.hpp:240
nested_minor_sequence_transposed(NestedMinorSequenceType &sequence)
Definition: nested_minor_sequence.hpp:162
size_t get_extension_height(size_t index) const
Definition: nested_minor_sequence.hpp:219
size_t get_extension_width(size_t index) const
Definition: nested_minor_sequence.hpp:231
nested_minor_sequence_transposed(const nested_minor_sequence_transposed< NestedMinorSequenceType > &other)
Definition: nested_minor_sequence.hpp:174
size_t size() const
Definition: nested_minor_sequence.hpp:258
Definition: nested_minor_sequence.hpp:16
static size_t get_extension_height(extension_type type)
Definition: nested_minor_sequence.cpp:32
size_t width() const
Definition: nested_minor_sequence.hpp:121
extension_type get_extension(size_t index) const
Definition: nested_minor_sequence.hpp:79
size_t get_extension_width(size_t index) const
Definition: nested_minor_sequence.hpp:103
nested_minor_sequence()
Definition: nested_minor_sequence.cpp:10
size_t get_extension_height(size_t index) const
Definition: nested_minor_sequence.hpp:91
extension_type
Definition: nested_minor_sequence.hpp:24
@ ONE_ROW_ONE_COLUMN
Definition: nested_minor_sequence.hpp:28
@ ONE_ROW
Definition: nested_minor_sequence.hpp:26
@ TWO_ROWS_ONE_COLUMN
Definition: nested_minor_sequence.hpp:29
@ FIRST_EXTENSION_TYPE
Definition: nested_minor_sequence.hpp:25
@ BEYOND_EXTENSION_TYPE
Definition: nested_minor_sequence.hpp:31
@ ONE_COLUMN
Definition: nested_minor_sequence.hpp:30
@ ONE_ROW_TWO_COLUMNS
Definition: nested_minor_sequence.hpp:27
size_t size() const
Definition: nested_minor_sequence.hpp:130
size_t height() const
Definition: nested_minor_sequence.hpp:112
void resize(size_t new_size)
Definition: nested_minor_sequence.hpp:135
void push(extension_type type)
Definition: nested_minor_sequence.cpp:61
virtual ~nested_minor_sequence()
Definition: nested_minor_sequence.cpp:20
static size_t get_extension_width(extension_type type)
Definition: nested_minor_sequence.cpp:47
Definition: algorithm.hpp:14
nested_minor_sequence_transposed< NestedMinorSequenceType > make_transposed_nested_minor_sequence(NestedMinorSequenceType &sequence)
Definition: nested_minor_sequence.hpp:275