-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistaenlazada.cpp
57 lines (47 loc) · 1.19 KB
/
listaenlazada.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//#include "listaenlazada.h"
/*template <typename T>
ListaEnlazada<T>::ListaEnlazada()
{
this->cabeza = nullptr;
}
template <typename T>
void ListaEnlazada<T>::Agregar(T valorAgregar){
Nodo<T>* nuevoNodo = new Nodo<T>();
nuevoNodo->dato = valorAgregar;
nuevoNodo->siguiente = this->cabeza;
cabeza = nuevoNodo;
}
template <typename T>
bool ListaEnlazada<T>::Existe(T item){
bool existeItem = false;
Nodo<T>* iterador = this->cabeza;
while(iterador != nullptr){
if(iterador->dato == item){
existeItem = true;
break;
}
iterador = iterador->siguiente;
}
return existeItem;
}
template <typename T>
T ListaEnlazada<T>::Existe(T item, std::function<bool(T,T)> comp){
Nodo<T>* iterador = this->cabeza;
while(iterador != nullptr){
if(comp(iterador->dato, item)){
return iterador;
}
iterador = iterador->siguiente;
}
return nullptr;
}
template <typename T>
T ListaEnlazada<T>::ObtenerInicial(){
return this->cabeza;
}
template <typename T>
void ListaEnlazada<T>::EliminarInicial(){
Nodo<T>* prim = this->cabeza->siguiente;
this->cabeza = nullptr;
cabeza = prim;
}*/