-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata_iterators.hh
74 lines (57 loc) · 1.67 KB
/
data_iterators.hh
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
64
65
66
67
68
69
70
71
72
73
74
#ifndef __DATA_ITERATORS_HH
#define __DATA_ITERATORS_HH
#include <iterator>
/*template<typename _Container,typename _InputIterator>
class conditional_iterator
: public _Container::iterator
{
};*/
//! TBD
template<typename _Container,typename _InputIterator>
class conditional_back_insert_iterator
: public std::iterator<std::output_iterator_tag, void, void, void, void>
{
protected:
_Container* container; //!< TBD
_InputIterator cond_iterator; //!< TBD
public:
//! TBD
typedef _Container container_type;
//! TBD
conditional_back_insert_iterator(_Container& __x,const _InputIterator& __i, int __prealloc=0)
: container(&__x), cond_iterator(__i)
{
if( __prealloc > 0 )
__x.reserve( __x.size()+__prealloc);
}
/*conditional_back_insert_iterator( const conditional_back_insert_iterator& __it )
: container( __it.container ), cond_iterator( __it.cond_iterator )
{ }*/
//! TBD
conditional_back_insert_iterator&
operator=( typename _Container::const_reference __value )
{
if( *cond_iterator )
container->push_back(__value);
++cond_iterator;
return *this;
}
//! TBD
conditional_back_insert_iterator&
operator*()
{ return *this; }
//! TBD
conditional_back_insert_iterator&
operator++()
{ return *this; }
//! TBD
conditional_back_insert_iterator&
operator++(int)
{ return *this; }
};
//! TBD
template<typename _Container, typename _InputIterator>
inline conditional_back_insert_iterator<_Container, _InputIterator>
conditional_back_inserter(_Container& __x, const _InputIterator& __i, int __prealloc=0)
{ return conditional_back_insert_iterator<_Container,_InputIterator>(__x,__i,__prealloc); }
#endif