DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
OpInSTLContainers.h
1
16
17
#pragma once
18
34
35
#if defined(OpInSTLContainers_RECURSES)
36
#error Recursive header files inclusion detected in OpInSTLContainers.h
37
#else
// defined(OpInSTLContainers_RECURSES)
39
#define OpInSTLContainers_RECURSES
40
41
#if !defined OpInSTLContainers_h
43
#define OpInSTLContainers_h
44
46
// Inclusions
47
#include <list>
49
50
namespace
DGtal
51
{
52
54
// generic classes for operations in STL containers
55
// that cannot be performed with a reverse_iterator type
56
58
75
76
//default (iterator type)
77
template
<
typename
Container,
typename
Iterator>
78
struct
OpInSTLContainers
79
{
80
static
Iterator
erase
(Container& aContainer,
Iterator
& anIterator)
81
{
82
return
aContainer.erase(anIterator);
83
}
84
85
static
Iterator
insert
(Container& aContainer,
Iterator
& anIterator)
86
{
87
return
aContainer.insert(anIterator);
88
}
89
90
};
91
92
//specialisation for reverse_iterator type
93
template
<
typename
Container>
94
struct
OpInSTLContainers
<
95
Container,
96
std
::reverse_iterator<typename Container::iterator> >
97
{
98
typedef
typename
Container::iterator
Iterator
;
99
typedef
std::reverse_iterator<typename Container::iterator>
ReverseIterator
;
100
101
static
ReverseIterator
erase
(
102
Container& aContainer,
103
ReverseIterator
& anIterator)
104
{
105
//base iterator pointing to the same element
106
Iterator
base = (++anIterator).base();
107
//base iterator pointing to the element that
108
//followed the erased element
109
base = aContainer.erase(base);
110
//reverse iterator pointing to the element that
111
//preceded the erased element
112
return
ReverseIterator
(base);
113
}
114
115
static
ReverseIterator
insert
(
116
Container& aContainer,
117
ReverseIterator
& anIterator,
118
const
typename
Container::value_type& aValue)
119
{
120
Iterator
base = aContainer.insert(anIterator.base(), aValue);
121
return
ReverseIterator
(base);
122
}
123
};
124
125
}
// namespace DGtal
126
127
// //
129
130
#endif
// !defined OpInSTLContainers_h
131
132
#undef OpInSTLContainers_RECURSES
133
#endif
// else defined(OpInSTLContainers_RECURSES)
DGtal::Iterator
DGtal::ReverseIterator::ReverseIterator
ReverseIterator()
Definition
ReverseIterator.h:81
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
std
STL namespace.
DGtal::OpInSTLContainers< Container, std::reverse_iterator< typename Container::iterator > >::ReverseIterator
std::reverse_iterator< typename Container::iterator > ReverseIterator
Definition
OpInSTLContainers.h:99
DGtal::OpInSTLContainers< Container, std::reverse_iterator< typename Container::iterator > >::Iterator
Container::iterator Iterator
Definition
OpInSTLContainers.h:98
DGtal::OpInSTLContainers< Container, std::reverse_iterator< typename Container::iterator > >::erase
static ReverseIterator erase(Container &aContainer, ReverseIterator &anIterator)
Definition
OpInSTLContainers.h:101
DGtal::OpInSTLContainers< Container, std::reverse_iterator< typename Container::iterator > >::insert
static ReverseIterator insert(Container &aContainer, ReverseIterator &anIterator, const typename Container::value_type &aValue)
Definition
OpInSTLContainers.h:115
DGtal::OpInSTLContainers
Definition
OpInSTLContainers.h:79
DGtal::OpInSTLContainers::insert
static Iterator insert(Container &aContainer, Iterator &anIterator)
Definition
OpInSTLContainers.h:85
DGtal::OpInSTLContainers::erase
static Iterator erase(Container &aContainer, Iterator &anIterator)
Definition
OpInSTLContainers.h:80
src
DGtal
base
OpInSTLContainers.h
Generated on
for DGtal by
1.18.0