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; Base() const42 const base & Base() const { return *this; } Base()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 EStack()50 EStack() {} EStack(const EStack & i_rStack)51 EStack( 52 const EStack & i_rStack ) 53 : base( (const base &)(i_rStack) ) {} ~EStack()54 ~EStack() {} 55 // OPERATORS operator =(const EStack & i_rStack)56 EStack & operator=( 57 const EStack & i_rStack ) 58 { base::operator=( i_rStack.Base() ); 59 return *this; } operator ==(const EStack<ELEM> & i_r2) const60 bool operator==( 61 const EStack<ELEM> & 62 i_r2 ) const 63 { return std::operator==( Base(), this->i_rStack.Base() ); } operator <(const EStack<ELEM> & i_r2) const64 bool operator<( 65 const EStack<ELEM> & 66 i_r2 ) const 67 { return std::operator<( Base(), this->i_rStack.Base() ); } 68 // OPERATIONS push(const value_type & i_rElem)69 void push( 70 const value_type & i_rElem ) 71 { base::push_front(i_rElem); } pop()72 void pop() { base::pop_front(); } erase_all()73 void erase_all() { while (NOT empty()) pop(); } 74 75 // INQUIRY top() const76 const value_type & top() const { return base::front(); } empty() const77 bool empty() const { return base::empty(); } 78 79 // ACCESS top()80 value_type & top() { return base::front(); } 81 }; 82 83 84 85 // IMPLEMENTATION 86 87 88 #endif 89 90