xref: /trunk/main/autodoc/source/inc/estack.hxx (revision 1c78a5d6)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef ARY_ESTACK_HXX
25 #define ARY_ESTACK_HXX
26 
27 
28 
29 // USED SERVICES
30 	// BASE CLASSES
31 #include <slist>
32 	// COMPONENTS
33 	// PARAMETERS
34 
35 
36 
37 template <class ELEM>
38 class EStack : private std::slist<ELEM>
39 {
40   private:
41     typedef std::slist<ELEM>    base;
42     const base &        Base() const            { return *this; }
43     base &              Base()                  { return *this; }
44 
45   public:
46     typedef ELEM                                    value_type;
47     typedef typename std::slist<ELEM>::size_type    size_type;
48 
49     // LIFECYCLE
50 						EStack() 				{}
51 						EStack(
52 							const EStack &      i_rStack )
53 												: 	base( (const base &)(i_rStack) ) {}
54 						~EStack() 				{}
55     // OPERATORS
56     EStack &            operator=(
57                             const EStack &      i_rStack )
58                                                 { base::operator=( i_rStack.Base() );
59                                                   return *this; }
60     bool                operator==(
61                             const EStack<ELEM> &
62                                                 i_r2 ) const
63                                                 { return std::operator==( Base(), this->i_rStack.Base() ); }
64     bool                operator<(
65                             const EStack<ELEM> &
66                                                 i_r2 ) const
67                                                 { return std::operator<( Base(), this->i_rStack.Base() ); }
68     // OPERATIONS
69     void                push(
70                             const value_type &  i_rElem )
71                                                 { base::push_front(i_rElem); }
72     void                pop()                   { base::pop_front(); }
73     void                erase_all()             { while (NOT empty()) pop(); }
74 
75     // INQUIRY
76     const value_type &  top() const             { return base::front(); }
77     size_type           size() const            { return base::size(); }
78     bool                empty() const           { return base::empty(); }
79 
80     // ACCESS
81     value_type &        top()                   { return base::front(); }
82 };
83 
84 
85 
86 // IMPLEMENTATION
87 
88 
89 #endif
90 
91