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_DNODE_H 00045 # define TPL_DNODE_H 00046 00047 # include <ahFunction.H> 00048 # include <dlink.H> 00049 00050 using namespace Aleph; 00051 namespace Aleph { 00052 00060 template <typename T> class Dnode : public Dlink 00061 { 00062 00063 private: 00064 00065 mutable T data; 00066 00067 public: 00068 00070 Dnode<T> *& get_next() { return reinterpret_cast<Dnode<T>*&>(next); } 00071 00073 Dnode<T> *& get_prev() { return reinterpret_cast<Dnode<T>*&> (prev); } 00074 00076 Dnode<T>* remove_prev() { return static_cast<Dnode<T>*>(Dlink::remove_prev()); } 00077 00079 Dnode<T>* remove_next() { return static_cast<Dnode<T>*>(Dlink::remove_next()); } 00080 Dnode() : Dlink() { /* Empty */ } 00081 00083 Dnode(const T& _data) : Dlink(), data(_data) { /* Empty */ } 00084 00086 Dnode(const Dnode & node) : Dlink(node), data(node.data) { /* empty */ } 00088 Dnode & operator = (const T & _data) 00089 { 00090 data = _data; 00091 return *this; 00092 } 00094 T & get_data() { return data; } 00096 typedef T dnode_type; 00101 struct Iterator : public Dlink::Iterator 00102 { 00104 Iterator(Dlink * head_ptr) : Dlink::Iterator(head_ptr) { /* empty */ } 00105 00107 Iterator(Dlink & head) : Dlink::Iterator(&head) { /* empty */ } 00108 00112 Iterator(Dlink * head_ptr, Dnode * curr_ptr) 00113 : Dlink::Iterator(head_ptr, curr_ptr) 00114 { 00115 // Empty 00116 } 00117 00119 Iterator(const Iterator & itor) : Dlink::Iterator(itor) 00120 { 00121 // Empty 00122 } 00123 00124 Iterator() : Dlink::Iterator() { /* empty */ } 00125 00127 Iterator & operator = (const Iterator & itor) 00128 { 00129 if (this == &itor) 00130 return *this; 00131 00132 Dlink::Iterator::operator = (itor); 00133 return *this; 00134 } 00135 00137 Iterator & operator = (Dnode * head) 00138 { 00139 Dlink::Iterator::operator = (head); 00140 00141 return *this; 00142 } 00143 00144 Dnode * get_current() 00145 { 00146 return static_cast<Dnode*>(Dlink::Iterator::get_current()); 00147 } 00148 00151 Dnode * del() { return static_cast<Dnode*>(Dlink::Iterator::del()); } 00152 }; 00153 }; 00154 00155 } 00156 00157 # endif /* TPL_DNODE_H */ 00158