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
3#define _CRT_SECURE_NO_WARNINGS
4
6
12typedef struct SIndice {
14 int prox;
17
23class CListaNo {
24private:
25 int limite;
26 TVector<TIndice> indice;
27 TVector<int> livre;
28 bool completa;
29public:
34 CListaNo(int limite = 0) :
36 indice(2 * limite),
37 livre(limite),
38 completa(true),
39 atual(0) {}
40 ~CListaNo();
41
42 int atual;
43
48 bool Completa() { return completa; }
49
55 int Valor(int i) {
56 TNo estado;
57 if ((estado = Estado(i)) != NULL)
58 return estado->LowerBound();
59 return INT_MAX;
60 }
61
67 int Proximo(int i = -1) {
68 if (i < 0)
69 return indice[atual].prox;
70 if (i >= 0 && i < indice.Count())
71 return indice[i].prox;
72 return -1;
73 }
74
80 int ProximoDistinto(int i = -1) {
81 if (i < 0)
82 return indice[atual].proxDistinto;
83 if (i >= 0 && i < indice.Count())
84 return indice[i].proxDistinto;
85 return -1;
86 }
87
93 TNo Estado(int i = -1) {
94 if (i < 0)
95 return indice[atual].estado;
96 if (i >= 0 && i < indice.Count())
97 return indice[i].estado;
98 return NULL;
99 }
100
107 int Inserir(TNo elemento, int id = 0);
108
113 void Inserir(TVector<TNo>& elementos);
114
115private:
121 int NovoElemento(TNo elemento);
122
124 void LibertarLista();
125
127 void LibertarSeguinte(int id);
128};
struct SIndice TIndice
Estrutura de índice para lista de estados.
@ limite
Valor dependente do algoritmo. Exemplo: Profundidade limitada.
Lista ordenada de nós para algoritmos de procura informada.
Definition CListaNo.h:23
bool Completa()
Indica se a lista é completa (nunca foi limpa).
Definition CListaNo.h:48
TNo Estado(int i=-1)
Retorna o estado armazenado no elemento.
Definition CListaNo.h:93
CListaNo(int limite=0)
Construtor da lista de nós.
Definition CListaNo.h:34
int atual
Índice do elemento atual a processar.
Definition CListaNo.h:42
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:80
int Proximo(int i=-1)
Retorna o próximo elemento na lista.
Definition CListaNo.h:67
int Valor(int i)
Retorna o valor (LowerBound) de um elemento.
Definition CListaNo.h:55
Representa um estado no espaço de estados.
int Count() const
Definition TVector.h:160
Estrutura de índice para lista de estados.
Definition CListaNo.h:12
int prox
Próximo elemento na lista (ordem por custo).
Definition CListaNo.h:14
TNo estado
Estado armazenado.
Definition CListaNo.h:13
int proxDistinto
Próximo elemento na lista com custo distinto.
Definition CListaNo.h:15