-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsequence_pair.h
47 lines (39 loc) · 1.26 KB
/
sequence_pair.h
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
37
38
39
40
41
42
43
44
45
46
47
#ifndef SEQUENCE_PAIR_H
#define SEQUENCE_PAIR_H
#include <list>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include "common.h"
#include "packing.h"
class packing;
class sequence_pair
{
private:
std::vector<pos> place_dimension(dimension dim, const packing & pack) const;
public:
std::list<size_t> positive_locus, negative_locus;
sequence_pair () = default;
/**
* Creates a new sequence pair of the form ((1, 2, ..., n), (1, 2, ..., n)).
* @param length The length of the sequence pair, n in the example above.
*/
explicit sequence_pair (size_t length):
positive_locus(length),
negative_locus(length)
{
std::iota(positive_locus.begin(), positive_locus.end(), 0);
std::iota(negative_locus.begin(), negative_locus.end(), 0);
}
/**
* Places rectangles according to this sequence pair. The placment will might be incomplete if
* it is impossible to place the rectangles this way in the given area.
* @param pack The packing which will be modified.
* @return True if this was succesful, false if rectangles were out of bounds.
*/
bool apply_to(packing &pack) const;
};
std::ostream &operator<<(std::ostream &out, const sequence_pair &);
#endif // !SEQUENCE_PAIR_H