DGtal 1.4.0
Loading...
Searching...
No Matches
FrontInsertionSequenceToStackAdapter.ih
1/**
2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU Lesser General Public License as
4 * published by the Free Software Foundation, either version 3 of the
5 * License, or (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *
15 **/
16
17/**
18 * @file FrontInsertionSequenceToStackAdapter.ih
19 * @author Tristan Roussillon (\c tristan.roussillon@liris.cnrs.fr )
20 * Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
21 *
22 * @date 2013/12/07
23 *
24 * Implementation of inline methods defined in FrontInsertionSequenceToStackAdapter.h
25 *
26 * This file is part of the DGtal library.
27 */
28
29
30//////////////////////////////////////////////////////////////////////////////
31#include <cstdlib>
32//////////////////////////////////////////////////////////////////////////////
33
34///////////////////////////////////////////////////////////////////////////////
35// IMPLEMENTATION of inline methods.
36///////////////////////////////////////////////////////////////////////////////
37
38///////////////////////////////////////////////////////////////////////////////
39// ----------------------------------------------------------------------------
40template <typename TSequence>
41inline
42DGtal::FrontInsertionSequenceToStackAdapter<TSequence>::
43FrontInsertionSequenceToStackAdapter(Alias<Container> aContainer)
44 : myContainerPtr(&aContainer)
45{
46}
47
48// ----------------------------------------------------------------------------
49template <typename TSequence>
50inline
51typename DGtal::FrontInsertionSequenceToStackAdapter<TSequence>::Size
52DGtal::FrontInsertionSequenceToStackAdapter<TSequence>::size() const
53{
54 return myContainerPtr->size();
55}
56
57// ----------------------------------------------------------------------------
58template <typename TSequence>
59inline
60bool
61DGtal::FrontInsertionSequenceToStackAdapter<TSequence>::empty() const
62{
63 return myContainerPtr->empty();
64}
65
66// ----------------------------------------------------------------------------
67template <typename TSequence>
68inline
69typename DGtal::FrontInsertionSequenceToStackAdapter<TSequence>::Value&
70DGtal::FrontInsertionSequenceToStackAdapter<TSequence>::top()
71{
72 return myContainerPtr->front();
73}
74
75// ----------------------------------------------------------------------------
76template <typename TSequence>
77inline
78const typename DGtal::FrontInsertionSequenceToStackAdapter<TSequence>::Value&
79DGtal::FrontInsertionSequenceToStackAdapter<TSequence>::top() const
80{
81 return myContainerPtr->front();
82}
83
84// ----------------------------------------------------------------------------
85template <typename TSequence>
86inline
87void
88DGtal::FrontInsertionSequenceToStackAdapter<TSequence>::push(const Value& aValue)
89{
90 myContainerPtr->push_front(aValue);
91}
92
93// ----------------------------------------------------------------------------
94template <typename TSequence>
95inline
96void
97DGtal::FrontInsertionSequenceToStackAdapter<TSequence>::pop()
98{
99 myContainerPtr->pop_front();
100}
101
102// ----------------------------------------------------------------------------
103template <typename TSequence>
104inline
105void
106DGtal::FrontInsertionSequenceToStackAdapter<TSequence>::selfDisplay ( std::ostream & out ) const
107{
108 out << "[FrontInsertionSequenceToStackAdapter]";
109}
110
111// ----------------------------------------------------------------------------
112template <typename TSequence>
113inline
114bool
115DGtal::FrontInsertionSequenceToStackAdapter<TSequence>::isValid() const
116{
117 return (myContainerPtr != 0);
118}
119
120
121
122///////////////////////////////////////////////////////////////////////////////
123// Implementation of inline functions //
124
125template <typename TSequence>
126inline
127std::ostream&
128DGtal::operator<< ( std::ostream & out,
129 const FrontInsertionSequenceToStackAdapter<TSequence> & object )
130{
131 object.selfDisplay( out );
132 return out;
133}
134
135
136template <typename TSequence>
137inline
138DGtal::FrontInsertionSequenceToStackAdapter<TSequence>
139DGtal::frontStack ( TSequence& aSequence )
140{
141 return FrontInsertionSequenceToStackAdapter<TSequence>( aSequence );
142}
143// //
144///////////////////////////////////////////////////////////////////////////////
145
146