8. Chapter 3
Class Documentation
3.1
Element Class Reference
#include <Element.h>
Public Member Functions
•
•
•
•
•
•
•
Element (long double value=0.0)
void value (long double Value)
long double value (void)
bool operator> (Element &e)
bool operator< (Element &e)
bool operator<= (Element &e)
virtual ∼Element ()
3.1.1
Detailed Description
Classe para armazenamento das caracteristicas de um determinado elemento
Definition at line 18 of file Element.h.
3.1.2
Constructor & Destructor Documentation
3.1.2.1
Element::Element (long double value = 0.0) [inline]
Método construtor da classe.
Definition at line 30 of file Element.h.
00030 {_value = value;};
Here is the call graph for this function:
Element::Element
Element::value
9. 6
3.1.2.2
Class Documentation
virtual Element::∼Element () [inline, virtual]
Método destrutor. Responsável por liberar todos os recursos alocados pela classe.
Definition at line 61 of file Element.h.
00061 {};
3.1.3
Member Function Documentation
3.1.3.1
bool Element::operator< (Element & e) [inline]
Sobrecarga do operador < para simplificação da comparação de valores.
Definition at line 50 of file Element.h.
00050 { return (this->value() < e.value()); };
Here is the call graph for this function:
Element::operator<
3.1.3.2
Element::value
bool Element::operator<= (Element & e) [inline]
Sobrecarga do operador <= para simplificação da comparação de valores.
Definition at line 55 of file Element.h.
00055 { return (this->value() <= e.value()); };
Here is the call graph for this function:
Element::operator<=
3.1.3.3
Element::value
bool Element::operator> (Element & e) [inline]
Sobrecarga do operador > para simplificação da comparação de valores.
Definition at line 45 of file Element.h.
00045 { return (this->value() > e.value()); };
Here is the call graph for this function:
Element::operator>
Element::value
Generated on Mon Dec 5 12:55:58 2011 by Doxygen
10. 3.1 Element Class Reference
3.1.3.4
7
long double Element::value (void) [inline]
Método que retorna o valor contido no atributo value.
Definition at line 40 of file Element.h.
00040 { return _value; };
Here is the caller graph for this function:
Element::Element
Element::operator<
Element::value
Element::operator<=
Element::operator>
3.1.3.5
void Element::value (long double Value) [inline]
Método que atribui um valor ao atributo value.
Definition at line 35 of file Element.h.
00035 { _value = Value; };
Here is the caller graph for this function:
main
ElementVector::maxValue
ElementVector::absMaxValue
ElementVector::minValue
Element::value
Element::operator<
Element::operator<=
Element::operator>
The documentation for this class was generated from the following file:
• Element.h
Generated on Mon Dec 5 12:55:58 2011 by Doxygen
11. 8
Class Documentation
3.2
ElementVector Class Reference
#include <Element.h>
Public Member Functions
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
ElementVector (void)
long double maxValue (void)
long double minValue (void)
long double absMaxValue (void)
bool isEmpty (void)
void resize (unsigned int new_size)
void sort (void)
unsigned int size (void)
Element at (unsigned int index)
Element & operator[ ] (unsigned int index)
void push_back (Element e)
void add (Element e)
void swap (unsigned int position_a, unsigned int position_b)
void clear (void)
virtual ∼ElementVector ()
3.2.1
Detailed Description
Classe para armazenamento de uma lista de elementos
Definition at line 76 of file Element.h.
3.2.2
Constructor & Destructor Documentation
3.2.2.1
ElementVector::ElementVector (void) [inline]
Método construtor da classe.
Definition at line 88 of file Element.h.
00088 {};
3.2.2.2
virtual ElementVector::∼ElementVector () [inline, virtual]
Método destrutor. Responsável por liberar todos os recursos alocados pela classe.
Definition at line 163 of file Element.h.
00163 { clear(); }
Here is the call graph for this function:
ElementVector::~ElementVector
ElementVector::clear
Generated on Mon Dec 5 12:55:58 2011 by Doxygen
12. 3.2 ElementVector Class Reference
9
3.2.3
Member Function Documentation
3.2.3.1
long double ElementVector::absMaxValue (void)
Método que retorna o maior valor absoluto contido na lista.
Definition at line 54 of file Element.cxx.
00055 {
00056
return (fabsl(maxValue()) > fabsl(minValue()))?(maxValue()):(fabsl(minValue()))
;
00057 }
Here is the call graph for this function:
ElementVector::maxValue
ElementVector::at
ElementVector::minValue
Element::value
ElementVector::absMaxValue
3.2.3.2
void ElementVector::add (Element e) [inline]
Método que insere elementos na lista
Definition at line 146 of file Element.h.
00146 { this->push_back(e);
}
Here is the call graph for this function:
ElementVector::add
ElementVector::push_back
Here is the caller graph for this function:
ElementVector::add
3.2.3.3
main
Element ElementVector::at (unsigned int index) [inline]
Método que retorna o elemento de uma determinada posição
Definition at line 128 of file Element.h.
00128 { return _list.at(index); };
Here is the caller graph for this function:
ElementVector::maxValue
ElementVector::at
ElementVector::absMaxValue
ElementVector::minValue
Generated on Mon Dec 5 12:55:58 2011 by Doxygen
13. 10
3.2.3.4
Class Documentation
void ElementVector::clear (void) [inline]
Método que executa limpeza da lista de elementos
Definition at line 157 of file Element.h.
00157 { _list.clear(); }
Here is the caller graph for this function:
ElementVector::clear
3.2.3.5
ElementVector::~ElementVector
bool ElementVector::isEmpty (void) [inline]
Método que verifica se a alista está vazia
Definition at line 108 of file Element.h.
00108 { return _list.empty(); };
3.2.3.6
long double ElementVector::maxValue (void)
Método que retorna o maior valor existente na lista de elementos
Definition at line 13 of file Element.cxx.
00014 {
00015
//Verificando se a lista foi preenchida ...
00016
if (_list.size() == 0 ) return 0;
00017
00018
//Resgatando o primeiro elemento da lista para verificação do maior elemento
00019
long double maximo = at(0).value();
00020
00021
//Looping para verificação do maior elemento
00022
for (unsigned int index = 1; index < _list.size(); index++)
00023
{
00024
if (maximo < at(index).value()) maximo = at(index).value();
00025
}
00026
00027
//Retornando o maior valor da lista
00028
return maximo;
00029 }
Here is the call graph for this function:
ElementVector::at
ElementVector::maxValue
Element::value
Here is the caller graph for this function:
ElementVector::maxValue
ElementVector::absMaxValue
Generated on Mon Dec 5 12:55:58 2011 by Doxygen
14. 3.2 ElementVector Class Reference
3.2.3.7
11
long double ElementVector::minValue (void)
Método que retorna o menor valor existente na lista de elementos
Definition at line 33 of file Element.cxx.
00034 {
00035
//Verificando se a lista foi preenchida ...
00036
if (_list.size() == 0 ) return 0;
00037
00038
//Resgatando o primeiro elemento da lista para verificação do maior elemento
00039
long double minimo = at(0).value();
00040
00041
//Looping para verificação do maior elemento
00042
for (unsigned int index = 1; index < _list.size(); index++)
00043
{
00044
if (minimo > at(index).value()) minimo = at(index).value();
00045
}
00046
00047
//Retornando o maior valor da lista
00048
return minimo;
00049 }
Here is the call graph for this function:
ElementVector::at
ElementVector::minValue
Element::value
Here is the caller graph for this function:
ElementVector::minValue
3.2.3.8
ElementVector::absMaxValue
Element& ElementVector::operator[ ] (unsigned int index) [inline]
Sobrecarga do operador [] para simplificar o acesso a um determinado elemento. Lembrando que esse
operador devolve uma referência, o que faz que acessemos diretamente o valor do objeto, além disso não
executamos verificação de limites com esse operador, isso fica a cargo do programador.
Definition at line 136 of file Element.h.
00136 { return _list[index]; };
3.2.3.9
void ElementVector::push_back (Element e) [inline]
Método que insere elementos na lista
Definition at line 141 of file Element.h.
00141 { _list.push_back(e); }
Generated on Mon Dec 5 12:55:58 2011 by Doxygen
15. 12
Class Documentation
Here is the caller graph for this function:
ElementVector::push_back
3.2.3.10
ElementVector::add
main
void ElementVector::resize (unsigned int new_size) [inline]
Método que executa um resize na lista de elementos
Definition at line 113 of file Element.h.
00113 { _list.resize(new_size); };
3.2.3.11
unsigned int ElementVector::size (void) [inline]
Método que retorna o tamanho da lista de elementos
Definition at line 123 of file Element.h.
00123 { return _list.size(); }
Here is the caller graph for this function:
ElementVector::size
3.2.3.12
main
void ElementVector::sort (void) [inline]
Método que utiliza o algoritmo de ordenação quick sort fornecido pela STL
Definition at line 118 of file Element.h.
00118 { std::sort(_list.begin(), _list.end(), PredicateSort()); };
3.2.3.13
void ElementVector::swap (unsigned int position_a, unsigned int position_b)
Método que executa a troca entre dois valores de uma determinada posição dentro da lista de elementos.
Definition at line 63 of file Element.cxx.
00064 {
00065
//Executa a troca dos valores
00066
long double temp = _list[position_a].value();
00067
_list[position_a].value( _list[position_b].value() );
00068
_list[position_b].value(temp);
00069 }
The documentation for this class was generated from the following files:
• Element.h
• Element.cxx
Generated on Mon Dec 5 12:55:58 2011 by Doxygen
16. 3.3 PredicateSort Struct Reference
3.3
PredicateSort Struct Reference
#include <Element.h>
Public Member Functions
• bool operator() (Element a, Element b)
3.3.1
Detailed Description
Estrutura auxiliar usada como predicado para executar ordenação usando o quicksort interno da STL.
Definition at line 68 of file Element.h.
3.3.2
Member Function Documentation
3.3.2.1
bool PredicateSort::operator() (Element a, Element b) [inline]
Definition at line 70 of file Element.h.
00070 { return a < b; }
The documentation for this struct was generated from the following file:
• Element.h
Generated on Mon Dec 5 12:55:58 2011 by Doxygen
13
18. Chapter 4
File Documentation
4.1
Element.cxx File Reference
#include "Element.h"
#include <vector>
#include <cmath>
#include <algorithm>
Include dependency graph for Element.cxx:
Element.cxx
vector
cmath
algorithm
This graph shows which files directly or indirectly include this file:
Element.cxx
19. 16
4.2
00001
00002
00003
00004
00005
00006
00007
00008
00009
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00054
00055
00056
File Documentation
Element.cxx
/*
* _Element.cpp
*
* Created on: 25/10/2009
Author: Administrador
*
*/
#include "Element.h"
long double ElementVector::maxValue(void)
{
//Verificando se a lista foi preenchida ...
if (_list.size() == 0 ) return 0;
//Resgatando o primeiro elemento da lista para verificação do maior elemento
long double maximo = at(0).value();
//Looping para verificação do maior elemento
for (unsigned int index = 1; index < _list.size(); index++)
{
if (maximo < at(index).value()) maximo = at(index).value();
}
//Retornando o maior valor da lista
return maximo;
}
long double ElementVector::minValue(void)
{
//Verificando se a lista foi preenchida ...
if (_list.size() == 0 ) return 0;
//Resgatando o primeiro elemento da lista para verificação do maior elemento
long double minimo = at(0).value();
//Looping para verificação do maior elemento
for (unsigned int index = 1; index < _list.size(); index++)
{
if (minimo > at(index).value()) minimo = at(index).value();
}
//Retornando o maior valor da lista
return minimo;
}
long double ElementVector::absMaxValue(void)
{
return (fabsl(maxValue()) > fabsl(minValue()))?(maxValue()):(fabsl(minValue()))
;
00057 }
00058
00063 void ElementVector::swap(unsigned int position_a, unsigned int position_b)
00064 {
00065
//Executa a troca dos valores
00066
long double temp = _list[position_a].value();
00067
_list[position_a].value( _list[position_b].value() );
00068
_list[position_b].value(temp);
00069 }
00070
00071
Generated on Mon Dec 5 12:55:58 2011 by Doxygen
20. 4.3 Element.h File Reference
4.3
17
Element.h File Reference
#include <vector>
#include <cmath>
#include <algorithm>
Include dependency graph for Element.h:
Element.h
vector
cmath
algorithm
This graph shows which files directly or indirectly include this file:
Element.h
Sys-Element.cpp
Classes
• class Element
• struct PredicateSort
• class ElementVector
Generated on Mon Dec 5 12:55:58 2011 by Doxygen
23. 20
File Documentation
4.5
Sys-Element.cpp File Reference
#include <iostream>
#include "Element.h"
Include dependency graph for Sys-Element.cpp:
Sys-Element.cpp
iostream
Element.h
vector
cmath
algorithm
Functions
• int main (int argc, char ∗argv[ ])
4.5.1
Function Documentation
4.5.1.1
int main (int argc, char ∗ argv[ ])
Função para testes com a biblioteca.
Definition at line 13 of file Sys-Element.cpp.
00014 {
00015
Element e(10.5);
00016
ElementVector ev;
00017
00018
ev.add(e); ev.add(Element(11.15)); ev.add(Element(9.5));
00019
00020
std::cout << "Valor armazenado: " << e.value() << std::endl;
00021
std::cout << "Número de elementos na lista: " << ev.size() << std::endl;
00022
00023
return 0;
00024 }
Here is the call graph for this function:
ElementVector::add
main
ElementVector::push_back
ElementVector::size
Element::value
Generated on Mon Dec 5 12:55:58 2011 by Doxygen