Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef __HEADER_H__
- #define __HEADER_H__
- #include "Node.h"
- #include <iostream>
- #include <functional>
- typedef unsigned int uint;
- template <typename T>
- class Cola
- {
- public:
- T* arr;
- uint numEl;
- uint fin;
- uint ini;
- uint elmUs;
- Cola() : fin(0), ini(0), elmUs(0)
- {
- numEl = 10;
- arr = new T[numEl];
- }
- ~Cola() { delete[] arr; }
- void agregar(T elem)
- {
- if (fin == 10)
- fin = 0;
- if (elmUs < 10)
- {
- arr[fin] = elem;
- fin++;
- ++elmUs;
- }
- }
- void eliminar()
- {
- if (elmUs != 0)
- {
- ini++;
- if (ini == 10)
- ini = 0;
- elmUs--;
- }
- }
- };
- #endif
- #include "Header.h"
- int main()
- {
- Cola<int>* cl = new Cola<int>();
- cl->agregar(1);
- cl->agregar(2);
- cl->agregar(3);
- cl->agregar(4);
- cl->agregar(5);
- cl->agregar(6);
- cl->eliminar();
- cl->agregar(7);
- cl->agregar(8);
- cl->agregar(9);
- cl->agregar(10);
- cl->agregar(11);
- cl->agregar(12);
- uint pos = cl->ini;
- for (int i = 0; i < cl->elmUs; ++i, ++pos)
- {
- if (pos == 10)
- {
- pos = 0;
- }
- std::cout << cl->arr[pos] << " -> ";
- }
- delete cl;
- std::cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement