27 # ifndef TPL_DYN_SLIST_NC_H 28 # define TPL_DYN_SLIST_NC_H 30 # include <tpl_snode_nc.H> 53 typedef Snode_Nc <T> Node;
65 delete Node::remove_next();
81 T &
insert(
const T & data)
throw(std::exception, std::bad_alloc)
83 Node * p =
new Node(data);
102 T &
append(
const T & data)
throw(std::exception, std::bad_alloc)
104 assert(head not_eq
nullptr);
105 Node * p =
new Node(data);
110 return p->get_data();
117 throw std::underflow_error(
"List is empty");
119 return this->
get_next()->get_data();
126 throw std::underflow_error(
"List is empty");
128 return head->get_data();
140 throw std::underflow_error(
"List is empty");
142 Node * p = Node::remove_next();
143 T ret_val = p->get_data();
145 if (--num_items == 0)
171 const size_t & size()
const {
return num_items; }
173 class Iterator :
public Node::Iterator
185 T & get_curr_n()
const noexcept
187 return Node::Iterator::get_curr()->get_data();
190 T & get_curr()
const {
return Dyn_Slist_Nc::Iterator::get_curr(); }
203 for (Iterator it(const_cast <Dyn_Slist_Nc &>(l));
204 it.has_curr(); it.next_ne())
230 for (Iterator it(const_cast<Dyn_Slist_Nc &>(list));
231 it.has_curr(); it.next_ne())
237 T & operator [] (
const size_t & n)
240 for (
int i = 0; i < n and it.has_curr(); ++i, it.next_ne());
242 return it.get_curr();
Definition: tpl_dyn_slist_nc.H:50
T pop()
Si this es una pila, entonces elimina el tope.
Definition: tpl_dyn_slist_nc.H:166
void empty()
VacÃa totalmente a la lista.
Definition: tpl_dyn_slist_nc.H:62
Dyn_Slist_Nc(const Dyn_Slist_Nc &l)
Constructor de copia.
Definition: tpl_dyn_slist_nc.H:201
bool is_empty() const
Retorna true si this está vacÃo (apunta a nullptr)
Definition: slink_nc.H:76
Dyn_Slist_Nc()
Constructor vacÃo.
Definition: tpl_dyn_slist_nc.H:195
T & top() const
Si this es una pila, entonces retorna el tope.
Definition: tpl_dyn_slist_nc.H:169
T & put(const T &item)
Si this es una cola, entonces mete el elemento item.
Definition: tpl_dyn_slist_nc.H:151
T & get_last()
Retorna una referencia al último elemento de la lista.
Definition: tpl_dyn_slist_nc.H:123
T & insert(const T &data)
Definition: tpl_dyn_slist_nc.H:81
T remove_first()
Definition: tpl_dyn_slist_nc.H:137
T & push(const T &item)
Si this es una pila, entonces inserta item.
Definition: tpl_dyn_slist_nc.H:163
T & rear()
Si this e suna cola, entonces retorna el elemento más joven.
Definition: tpl_dyn_slist_nc.H:157
Slink_Nc *& get_next()
Retorna el siguiente enlace.
Definition: slink_nc.H:83
void reset()
Reinicia enlace a que apunte a nullptr.
Definition: slink_nc.H:69
Dyn_Slist_Nc & operator=(const Dyn_Slist_Nc &list)
Definition: tpl_dyn_slist_nc.H:221
T & get_first()
Retorna una referencia al primer elemento de la lista.
Definition: tpl_dyn_slist_nc.H:114
T & front()
Si this e suna cola, entonces retorna el elemento más antiguo.
Definition: tpl_dyn_slist_nc.H:160
T & append(const T &data)
Definition: tpl_dyn_slist_nc.H:102