00001 00002 /* 00003 This file is part of Aleph system 00004 00005 Copyright (c) 2002, 2003, 2004, 2005, 2006 00006 UNIVERSITY LOS ANDES (ULA) Merida - REPÚBLICA BOLIVARIANA DE VENEZUELA 00007 00008 - Center of Studies in Microelectronics & Distributed Systems (CEMISID) 00009 - ULA Computer Science Department 00010 - FUNDACITE Mérida - Ministerio de Ciencia y Tecnología 00011 00012 PERMISSION TO USE, COPY, MODIFY AND DISTRIBUTE THIS SOFTWARE AND ITS 00013 DOCUMENTATION IS HEREBY GRANTED, PROVIDED THAT BOTH THE COPYRIGHT 00014 NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES OF THE 00015 SOFTWARE, DERIVATIVE WORKS OR MODIFIED VERSIONS, AND ANY PORTIONS 00016 THEREOF, AND THAT BOTH NOTICES APPEAR IN SUPPORTING DOCUMENTATION. 00017 00018 Aleph is distributed in the hope that it will be useful, but WITHOUT 00019 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00020 or FITNESS FOR A PARTICULAR PURPOSE. 00021 00022 UNIVERSIDAD DE LOS ANDES requests users of this software to return to 00023 00024 Leandro Leon 00025 CEMISID 00026 Ed La Hechicera 00027 3er piso, ala sur 00028 Facultad de Ingenieria 00029 Universidad de Los Andes 00030 Merida - REPÚBLICA BOLIVARIANA DE VENEZUELA or 00031 00032 lrleon@ula.ve 00033 00034 any improvements or extensions that they make and grant Universidad 00035 de Los Andes (ULA) the rights to redistribute these changes. 00036 00037 Aleph is (or was) granted by: 00038 - Consejo de Desarrollo Cientifico, Humanistico, Tecnico de la ULA 00039 (CDCHT) 00040 - Fundacite Mérida 00041 */ 00042 00043 00044 # ifndef TPL_DYNLISTSTACK_H 00045 # define TPL_DYNLISTSTACK_H 00046 00047 # include <tpl_listStack.H> 00048 00049 namespace Aleph { 00050 00061 template <typename T> 00062 class DynListStack : public ListStack<T> 00063 { 00064 00065 public: 00066 00075 T & top() const throw(std::exception, std::underflow_error) 00076 { 00077 return ListStack<T>::top()->get_data(); 00078 } 00089 T & push(const T & __data) throw(std::exception, std::bad_alloc) 00090 { 00091 typename ListStack<T>::Node *ptr = new typename ListStack<T>::Node (__data); 00092 00093 ListStack<T>::push(ptr); 00094 00095 return ptr->get_data(); 00096 } 00105 T pop() throw(std::exception, std::underflow_error) 00106 { 00107 typename ListStack<T>::Node* ptr = ListStack<T>::pop(); 00108 00109 T retVal = ptr->get_data(); 00110 delete ptr; 00111 00112 return retVal; 00113 } 00115 virtual ~DynListStack() 00116 { 00117 while (not this->is_empty()) 00118 pop(); 00119 } 00120 }; 00121 00122 } // end namespace Aleph 00123 # endif /* TPL_DYNLISTSTACK_H */ 00124