Home | Develop | Download | Contact
Todo Estructuras de Datos Namespaces Funciones Variables typedefs Enumeraciones Valores de enumeraciones Amigas Grupos Páginas
Grid.hpp
1/*
2 * Grid.hpp
3 *
4 * Copyright 2018 Fernando Pujaico Rivera <fernando.pujaico.rivera@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301, USA.
20 *
21 */
22
32#ifndef __PDS_GRID_HPP__
33#define __PDS_GRID_HPP__
34
35
45#include <string>
46#include <Pds/Size>
47#include <vector>
48#include <iostream>
49
50
51namespace Pds{
52
53
54
62template <typename Datum>
63class Grid
64{
65public:
66
68 std::vector<Datum> data;
69
71 unsigned int nlin;
72
74 unsigned int ncol;
75
76public:
77
86 Grid(void)
87 {
88 this->nlin=0;
89 this->ncol=0;
90 this->data.clear();
91 }
92
98 Grid (unsigned int Nlin, unsigned int Ncol)
99 {
100 this->nlin=Nlin;
101 this->ncol=Ncol;
102 this->data.resize (nlin*ncol);
103 }
104
105
107 {
108 this->nlin=0;
109 this->ncol=0;
110 this->data.clear();
111 }
112
117public:
118
129 Datum& operator()(unsigned int Nlin, unsigned int Ncol)
130 {
131 if (Nlin >= this->nlin || Ncol>= this->ncol)
132 {
133 throw std::out_of_range("Indices out of range");
134 }
135
136 return this->data[this->nlin*Ncol + Nlin];
137 }
138
144 Datum& In(unsigned int Nlin, unsigned int Ncol)
145 {
146 if (Nlin >= this->nlin || Ncol>= this->ncol)
147 {
148 throw std::out_of_range("Indices out of range");
149 }
150
151 return this->data[this->nlin*Ncol + Nlin];
152 }
153
160 const Datum& At(unsigned int Nlin, unsigned int Ncol) const
161 {
162 if (Nlin >= this->nlin || Ncol>= this->ncol)
163 {
164 throw std::out_of_range("Indices out of range");
165 }
166
167 return this->data[this->nlin*Ncol + Nlin];
168 }
169
175 Datum Get(unsigned int Nlin, unsigned int Ncol) const
176 {
177 if (Nlin >= this->nlin || Ncol>= this->ncol)
178 {
179 throw std::out_of_range("Indices out of range");
180 }
181
182 return this->data[this->nlin*Ncol + Nlin];
183 }
188public:
189
200 bool IsEmpty(void) const
201 {
202 if((this->nlin==0)||(this->ncol==0)) return true;
203
204 return false;
205 }
206
212 bool IsNotEmpty(void) const
213 {
214 if((this->nlin==0)||(this->ncol==0)) return false;
215
216 return true;
217 }
218
224 void MakeEmpty(void)
225 {
226 this->nlin=0;
227 this->ncol=0;
228 this->data.clear();
229 }
230
235public:
236
247 unsigned int Nlin(void) const
248 {
249 return this->nlin;
250 }
251
256 unsigned int Ncol(void) const
257 {
258 return this->ncol;
259 }
260
264};
265
266} // namespace Pds
267
268
269
274#endif
275
La clase tipo Grid . Esta clase genera una agrupación de 2 datos. Para usar incluir Pds/Grid.
Definition: Grid.hpp:64
std::vector< Datum > data
Definition: Grid.hpp:68
unsigned int nlin
Definition: Grid.hpp:71
unsigned int ncol
Definition: Grid.hpp:74
Grid(unsigned int Nlin, unsigned int Ncol)
Crea un objeto de tipo Pds::Grid.
Definition: Grid.hpp:98
const Datum & At(unsigned int Nlin, unsigned int Ncol) const
Acessar en modo lectura a un dato de un objeto de tipo Pds::Grid.
Definition: Grid.hpp:160
Datum Get(unsigned int Nlin, unsigned int Ncol) const
Obter datos de un objeto de tipo Pds::Grid.
Definition: Grid.hpp:175
Datum & operator()(unsigned int Nlin, unsigned int Ncol)
Acessar en modo lectura y escritura a un dato de un objeto de tipo Pds::Grid.
Definition: Grid.hpp:129
~Grid()
Definition: Grid.hpp:106
void MakeEmpty(void)
Convierte el Kohonen2D a vazio, es decir limpia todos los datos internos.
Definition: Grid.hpp:224
unsigned int Ncol(void) const
Retorna el número de columnas da grid.
Definition: Grid.hpp:256
bool IsNotEmpty(void) const
Verifica si el Kohonen2D NO está vazio.
Definition: Grid.hpp:212
Datum & In(unsigned int Nlin, unsigned int Ncol)
Acessar en modo lectura y escritura a un dato de un objeto de tipo Pds::Grid.
Definition: Grid.hpp:144
unsigned int Nlin(void) const
Retorna el número de lineas da grid.
Definition: Grid.hpp:247
Grid(void)
Crea un objeto de tipo Pds::Grid vacio.
Definition: Grid.hpp:86
bool IsEmpty(void) const
Verifica si el Kohonen2D está vazio.
Definition: Grid.hpp:200
Nombre de espacio para Pds (Procesamiento Digital de Senales)
Definition: AbstractRV.hpp:42

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed