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.
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.
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/>.
18 * @file BackInsertionSequenceToStackAdapter.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
24 * Implementation of inline methods defined in BackInsertionSequenceToStackAdapter.h
26 * This file is part of the DGtal library.
30 //////////////////////////////////////////////////////////////////////////////
32 //////////////////////////////////////////////////////////////////////////////
34 ///////////////////////////////////////////////////////////////////////////////
35 // IMPLEMENTATION of inline methods.
36 ///////////////////////////////////////////////////////////////////////////////
38 ///////////////////////////////////////////////////////////////////////////////
39 // ----------------------------------------------------------------------------
40 template <typename TSequence>
42 DGtal::BackInsertionSequenceToStackAdapter<TSequence>::
43 BackInsertionSequenceToStackAdapter(Alias<Container> aContainer)
44 : myContainerPtr(&aContainer)
48 // ----------------------------------------------------------------------------
49 template <typename TSequence>
51 typename DGtal::BackInsertionSequenceToStackAdapter<TSequence>::Size
52 DGtal::BackInsertionSequenceToStackAdapter<TSequence>::size() const
54 return myContainerPtr->size();
57 // ----------------------------------------------------------------------------
58 template <typename TSequence>
61 DGtal::BackInsertionSequenceToStackAdapter<TSequence>::empty() const
63 return myContainerPtr->empty();
66 // ----------------------------------------------------------------------------
67 template <typename TSequence>
69 typename DGtal::BackInsertionSequenceToStackAdapter<TSequence>::Value&
70 DGtal::BackInsertionSequenceToStackAdapter<TSequence>::top()
72 return myContainerPtr->back();
75 // ----------------------------------------------------------------------------
76 template <typename TSequence>
78 const typename DGtal::BackInsertionSequenceToStackAdapter<TSequence>::Value&
79 DGtal::BackInsertionSequenceToStackAdapter<TSequence>::top() const
81 return myContainerPtr->back();
84 // ----------------------------------------------------------------------------
85 template <typename TSequence>
88 DGtal::BackInsertionSequenceToStackAdapter<TSequence>::push(const Value& aValue)
90 myContainerPtr->push_back(aValue);
93 // ----------------------------------------------------------------------------
94 template <typename TSequence>
97 DGtal::BackInsertionSequenceToStackAdapter<TSequence>::pop()
99 myContainerPtr->pop_back();
102 // ----------------------------------------------------------------------------
103 template <typename TSequence>
106 DGtal::BackInsertionSequenceToStackAdapter<TSequence>::selfDisplay ( std::ostream & out ) const
108 out << "[BackInsertionSequenceToStackAdapter]";
111 // ----------------------------------------------------------------------------
112 template <typename TSequence>
115 DGtal::BackInsertionSequenceToStackAdapter<TSequence>::isValid() const
117 return (myContainerPtr != 0);
122 ///////////////////////////////////////////////////////////////////////////////
123 // Implementation of inline functions //
125 template <typename TSequence>
128 DGtal::operator<< ( std::ostream & out,
129 const BackInsertionSequenceToStackAdapter<TSequence> & object )
131 object.selfDisplay( out );
136 template <typename TSequence>
138 DGtal::BackInsertionSequenceToStackAdapter<TSequence>
139 DGtal::backStack ( TSequence& aSequence )
141 return BackInsertionSequenceToStackAdapter<TSequence>( aSequence );
144 ///////////////////////////////////////////////////////////////////////////////