TProcura
Biblioteca em C++ para testes paramétricos de algoritmos, e coleção de algoritmos de procura e otimização
Loading...
Searching...
No Matches
CListaNo.h
Go to the documentation of this file.
1#pragma once
2
4
10typedef struct SIndice {
12 int prox;
15
21class CListaNo {
22private:
23 int limite;
24 TVector<TIndice> indice;
25 TVector<int> livre;
26 bool completa;
27public:
32 CListaNo(int limite = 0) :
33 limite(limite),
34 indice(2 * limite),
35 livre(limite),
36 completa(true),
37 atual(0) {}
38 ~CListaNo();
39
40 int atual;
41
46 bool Completa() { return completa; }
47
53 int Valor(int i) {
54 TNo estado;
55 if ((estado = Estado(i)) != NULL)
56 return estado->LowerBound();
57 return INT_MAX;
58 }
59
65 int Proximo(int i = -1) {
66 if (i < 0)
67 return indice[atual].prox;
68 if (i >= 0 && i < indice.Count())
69 return indice[i].prox;
70 return -1;
71 }
72
78 int ProximoDistinto(int i = -1) {
79 if (i < 0)
80 return indice[atual].proxDistinto;
81 if (i >= 0 && i < indice.Count())
82 return indice[i].proxDistinto;
83 return -1;
84 }
85
91 TNo Estado(int i = -1) {
92 if (i < 0)
93 return indice[atual].estado;
94 if (i >= 0 && i < indice.Count())
95 return indice[i].estado;
96 return NULL;
97 }
98
105 int Inserir(TNo elemento, int id = 0);
106
111 void Inserir(TVector<TNo>& elementos);
112
113private:
119 int NovoElemento(TNo elemento);
120
122 void LibertarLista();
123
125 void LibertarSeguinte(int id);
126};
struct SIndice TIndice
Estrutura de índice para lista de estados.
Lista ordenada de nós para algoritmos de procura informada.
Definition CListaNo.h:21
bool Completa()
Indica se a lista é completa (nunca foi limpa).
Definition CListaNo.h:46
TNo Estado(int i=-1)
Retorna o estado armazenado no elemento.
Definition CListaNo.h:91
CListaNo(int limite=0)
Construtor da lista de nós.
Definition CListaNo.h:32
int atual
Índice do elemento atual a processar.
Definition CListaNo.h:40
int Inserir(TNo elemento, int id=0)
Insere um novo estado na lista, por ordem de LowerBound.
Definition CListaNo.cpp:83
~CListaNo()
Definition CListaNo.cpp:3
int ProximoDistinto(int i=-1)
Retorna o próximo elemento com custo distinto.
Definition CListaNo.h:78
int Proximo(int i=-1)
Retorna o próximo elemento na lista.
Definition CListaNo.h:65
int Valor(int i)
Retorna o valor (LowerBound) de um elemento.
Definition CListaNo.h:53
Representa um estado no espaço de estados.
int Count() const
Definition TVector.h:227
Estrutura de índice para lista de estados.
Definition CListaNo.h:10
int prox
Próximo elemento na lista (ordem por custo).
Definition CListaNo.h:12
TNo estado
Estado armazenado.
Definition CListaNo.h:11
int proxDistinto
Próximo elemento na lista com custo distinto.
Definition CListaNo.h:13