2 Copyright 2008 Intel Corporation
4 Use, modification and distribution are subject to the Boost Software License,
5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt).
8 #ifndef BOOST_POLYGON_ITERATOR_COMPACT_TO_POINTS_HPP
9 #define BOOST_POLYGON_ITERATOR_COMPACT_TO_POINTS_HPP
10 namespace boost { namespace polygon{
11 template <typename iterator_type, typename point_type>
12 class iterator_compact_to_points {
15 iterator_type iter_end_;
17 typename point_traits<point_type>::coordinate_type firstX_;
18 orientation_2d orient_;
20 typedef std::forward_iterator_tag iterator_category;
21 typedef point_type value_type;
22 typedef std::ptrdiff_t difference_type;
23 typedef const point_type* pointer; //immutable
24 typedef const point_type& reference; //immutable
26 inline iterator_compact_to_points() : iter_(), iter_end_(), pt_(), firstX_(), orient_() {}
27 inline iterator_compact_to_points(iterator_type iter, iterator_type iter_end) :
28 iter_(iter), iter_end_(iter_end), pt_(), firstX_(), orient_(HORIZONTAL) {
29 if(iter_ != iter_end_) {
33 if(iter_ != iter_end_) {
38 //use bitwise copy and assign provided by the compiler
39 inline iterator_compact_to_points& operator++() {
40 iterator_type prev_iter = iter_;
42 if(iter_ == iter_end_) {
43 if(x(pt_) != firstX_) {
48 set(pt_, orient_, *iter_);
53 inline const iterator_compact_to_points operator++(int) {
54 iterator_compact_to_points tmp(*this);
58 inline bool operator==(const iterator_compact_to_points& that) const {
59 if (iter_ == iter_end_) {
60 return iter_ == that.iter_;
62 return (iter_ == that.iter_) && (x(pt_) == x(that.pt_));
64 inline bool operator!=(const iterator_compact_to_points& that) const {
65 if (iter_ == iter_end_) {
66 return iter_ != that.iter_;
68 return (iter_ != that.iter_) || (x(pt_) != x(that.pt_));
70 inline reference operator*() const { return pt_; }