vector<Persistivel*> PersisteMemoriaPessoa::carregarCadastros(const int id) { vector<Persistivel*> vLista; Lista<Persistivel*>* lista = Sistema::getListaPessoas()->getLista(); if (lista->tamanho() > 0) { Persistivel_local* persistivel_local = new Persistivel_local(); Lista<Persistivel*>::Iterator it; it = lista->begin(); while(it != lista->end()) { persistivel_local = static_cast<Persistivel_local*>( *it ); if (id > 0 && persistivel_local->getId() == id) { vLista.push_back( static_cast<Persistivel*>(persistivel_local) ); return vLista; } else if (id < 0) { vLista.push_back(persistivel_local); } it++; } } return vLista; }
int main() { cout << "Iniciando leitura do arquivo de dados... "; Lista<int> listaAOrdenar = readFile("arquivo.dat"); cout << "CONCLUÍDO!" << endl; cout << "Iniciando ordenação da lista de inteiros... "; clock_t begin = clock(); listaAOrdenar.ordenar(integerCmp); clock_t end = clock(); double elapsed_time = double(end-begin) / CLOCKS_PER_SEC; cout << "CONCLUÍDO!" << endl; cout << "Tempo necessário para ordenar a lista: " << elapsed_time << " s" << endl << endl; cout << "Pressione uma tecla para exibir a lista ordenada" << endl; getchar(); for (int i = 0; i < listaAOrdenar.tamanho(); i++) { cout << i << ": " << listaAOrdenar.elementoNaPosicao(i) << endl; } return 0; }
void imprimeLista() { for (int i = 0; i < l.tamanho(); i++) { printf("%8d\t%8d\n", i, l.elementoNaPosicao(i)); } }