-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc.h
63 lines (60 loc) · 1.36 KB
/
misc.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include <vector>
#include <map>
#include <iostream>
#include <cstddef>
template<typename T>
std::ostream& operator<<( std::ostream& os, const std::vector<T>& s ) {
if( s.empty() )
os << "Ø";
else {
auto x = s.begin();
os << "[" << (*x);
while( (++x) != s.end() )
os << "," << (*x);
os << "]";
}
return os;
}
template<typename T, typename U>
std::ostream& operator<<( std::ostream& os, const std::map<T,U>& s ) {
if( s.empty() )
os << "Ø";
else {
auto x = s.begin();
os << "{" << x->first << " -> " << x->second;
while( (++x) != s.end() )
os << "," << x->first << " -> " << x->second;
os << "}";
}
return os;
}
class all_ordered_tuples {
int _n;
int _r;
public:
class iterator {
int _n;
int _r;
std::vector<int> _tuple;
public:
typedef iterator self_type;
typedef std::vector<int> value_type;
typedef std::vector<int>& reference;
typedef std::vector<int>* pointer;
typedef std::forward_iterator_tag iterator_category;
typedef size_t difference_type;
iterator( int n, int r );
iterator( const self_type& other );
self_type& operator++();
self_type operator++(int);
reference operator*();
pointer operator->();
bool operator==(const self_type& rhs);
bool operator!=(const self_type& rhs);
};
iterator begin() const;
iterator end() const;
size_t size() const;
all_ordered_tuples( int n, int r );
};