]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry Index |
2 | // | |
3 | // Insert iterator | |
4 | // | |
5 | // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. | |
6 | // | |
7 | // Use, modification and distribution is subject to the Boost Software License, | |
8 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
9 | // http://www.boost.org/LICENSE_1_0.txt) | |
10 | ||
11 | #ifndef BOOST_GEOMETRY_INDEX_INSERTER_HPP | |
12 | #define BOOST_GEOMETRY_INDEX_INSERTER_HPP | |
13 | ||
14 | #include <iterator> | |
15 | ||
16 | /*! | |
17 | \defgroup inserters Inserters (boost::geometry::index::) | |
18 | */ | |
19 | ||
20 | namespace boost { namespace geometry { namespace index { | |
21 | ||
22 | template <class Container> | |
23 | class insert_iterator : | |
24 | public std::iterator<std::output_iterator_tag, void, void, void, void> | |
25 | { | |
26 | public: | |
27 | typedef Container container_type; | |
28 | ||
29 | inline explicit insert_iterator(Container & c) | |
30 | : container(&c) | |
31 | {} | |
32 | ||
33 | insert_iterator & operator=(typename Container::value_type const& value) | |
34 | { | |
35 | container->insert(value); | |
36 | return *this; | |
37 | } | |
38 | ||
39 | insert_iterator & operator* () | |
40 | { | |
41 | return *this; | |
42 | } | |
43 | ||
44 | insert_iterator & operator++ () | |
45 | { | |
46 | return *this; | |
47 | } | |
48 | ||
49 | insert_iterator operator++(int) | |
50 | { | |
51 | return *this; | |
52 | } | |
53 | ||
54 | private: | |
55 | Container * container; | |
56 | }; | |
57 | ||
58 | /*! | |
59 | \brief Insert iterator generator. | |
60 | ||
61 | Returns insert iterator capable to insert values to the container | |
62 | (spatial index) which has member function insert(value_type const&) defined. | |
63 | ||
64 | \ingroup inserters | |
65 | ||
66 | \param c The reference to the container (spatial index) to which values will be inserted. | |
67 | ||
68 | \return The insert iterator inserting values to the container. | |
69 | */ | |
70 | template <typename Container> | |
71 | insert_iterator<Container> inserter(Container & c) | |
72 | { | |
73 | return insert_iterator<Container>(c); | |
74 | } | |
75 | ||
76 | }}} // namespace boost::geometry::index | |
77 | ||
78 | #endif // BOOST_GEOMETRY_INDEX_INSERTER_HPP |