Reference Manual for the "SysSorting Professional" application. Throughout this manual we have access to portions or parts of the application source code and the core libraries developed specifically for the evaluation of strategies for sorting taking into account the nature of the generators of pseudo-random numbers used in the experiments.
10. Chapter 5
Namespace Documentation
5.1
LibraryUtils Namespace Reference
Classes
• class ConversionError
Functions
• string FloatToStr (double numero, int digitos)
• template<typename T >
std::string DoubleToStr (T const &myvalue, unsigned int precision)
• bool IsNumeric (const std::string &str)
• long double StrToFloat (const std::string &str)
• string IntToStr (int numero)
• long int StrToInt (const std::string &str)
• string TrimString (const std::string str)
• int SignalNumber (long double value)
5.1.1
Function Documentation
5.1.1.1
template<typename T > std::string LibraryUtils::DoubleToStr (T const & myvalue,
unsigned int precision) [inline]
Definition at line 55 of file LibraryUtils.h.
00056 {
00057
std::ostringstream oss;
00058
oss << std::setprecision(precision) << myvalue;
00059
return oss.str();
00060 }
11. 10
Namespace Documentation
Here is the caller graph for this function:
MyApplication::GeraListaDeNumeros
LibraryUtils::DoubleToStr
MyApplication::OrdenaListaDeNumeros
5.1.1.2
string LibraryUtils::FloatToStr (double numero, int digitos)
Definition at line 45 of file LibraryUtils.h.
00046 {
00047
MyCharArrayString str;
00048
gcvt(numero, (digitos > MAX_LENGTH_CHAR_ARRAY)?(MAX_LENGTH_CHAR_ARRAY):(digitos
) , str);
00049
return string(str);
00050 }
5.1.1.3
string LibraryUtils::IntToStr (int numero)
Definition at line 100 of file LibraryUtils.h.
00101 {
00102
std::ostringstream osbuffer;
00103
osbuffer << numero;
00104
return osbuffer.str();
00105 }
Here is the caller graph for this function:
LibraryUtils::IntToStr
5.1.1.4
MyApplication::GeraListaDeNumeros
bool LibraryUtils::IsNumeric (const std::string & str)
Definition at line 64 of file LibraryUtils.h.
00065 {
00066
//Declaração das variáveis de conversão
00067
std::istringstream iss(str);
00068
long double d;
00069
00070
//Movendo o conteudo da string para a variavel do tipo double
00071
iss >> d;
00072
00073
//Fazendo verificações de conversão
00074
if ( !(iss && (iss >> std::ws).eof())) return false;
00075
00076
//Caso haja falha na conversão uma exceção é lançada caso não o valor é retorna
do
00077
return true;
00078 }
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
12. 5.1 LibraryUtils Namespace Reference
11
Here is the caller graph for this function:
LibraryUtils::IsNumeric
5.1.1.5
MyApplication::GeraListaDeNumeros
int LibraryUtils::SignalNumber (long double value)
Definition at line 135 of file LibraryUtils.h.
00136 {
00137
return (value >= 0)?(1):(-1);
00138 }
5.1.1.6
long double LibraryUtils::StrToFloat (const std::string & str)
Definition at line 82 of file LibraryUtils.h.
00083 {
00084
//Declaração das variáveis de conversão
00085
std::istringstream iss(str);
00086
double d;
00087
00088
//Movendo o conteudo da string para a variavel do tipo double
00089
iss >> d;
00090
00091
//Fazendo verificações de conversão
00092
if ( !(iss && (iss >> std::ws).eof())) throw ConversionError();
00093
00094
//Caso haja falha na conversão uma exceção é lançada caso não o valor é retorna
do
00095
return d;
00096 }
Here is the caller graph for this function:
LibraryUtils::StrToFloat
5.1.1.7
MyApplication::GeraListaDeNumeros
long int LibraryUtils::StrToInt (const std::string & str)
Definition at line 109 of file LibraryUtils.h.
00110 {
00111
//Declaração das variaveis de conversão
00112
std::istringstream iss(str);
00113
int i;
00114
00115
//Movendo o conteudo do stringstream para a variavel
00116
iss >> i;
00117
00118
//Fazendo verificações de conversão
00119
if ( !(iss && (iss >> std::ws).eof())) throw ConversionError();
00120
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
13. 12
Namespace Documentation
00121
//Caso haja falha na conversão uma exceção é lançada caso não o valor é retorna
do
00122
return i;
00123 }
Here is the caller graph for this function:
LibraryUtils::StrToInt
5.1.1.8
MyApplication::GeraListaDeNumeros
string LibraryUtils::TrimString (const std::string str)
Definition at line 127 of file LibraryUtils.h.
00128 {
00129
string result = str;
00130
std::remove(result.begin(),result.end(),’ ’);
00131
return result;
00132 }
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
14. 5.2 RNG Namespace Reference
5.2
13
RNG Namespace Reference
Classes
•
•
•
•
•
•
•
•
•
•
•
class RandomNumberGenerator
class MersenneTwisterInt32
class MersenneTwisterDouble
class MersenneTwisterDoubleClosed
class MersenneTwisterDoubleOpened
class MersenneTwisterDouble53
class R250Base
class R250Int
class R250Double
class BoxMuller
class Distribution
Functions
• template<typename T >
void swap (T &a, T &b)
5.2.1
Detailed Description
Namespace RandomNumberGenerator
RNG - RandomNumberGenerator Namespace para os algoritmos de geracao de numeros pseudo-aleatórios
em suas diversas implementacoes.
5.2.2
Function Documentation
5.2.2.1
template<typename T > void RNG::swap (T & a, T & b) [inline]
Definition at line 686 of file RandomNumberGenerator.h.
00686 { T temp(a);
a = b;
b = temp; };
Here is the caller graph for this function:
RNG::Distribution::Equilikely
RNG::RandomNumberGenerator::GetDouble
RNG::swap
RNG::RandomNumberGenerator::GetInt
RNG::Distribution::Uniform
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
17. 16
6.1.1
Class Documentation
Detailed Description
Classe base para uso do padrão strategy.
Definition at line 17 of file SortingAlgorithms.h.
6.1.2
Constructor & Destructor Documentation
6.1.2.1
AbstractSorting::AbstractSorting ()
Constructor
Definition at line 16 of file SortingAlgorithms.cxx.
00017 {
00018
InitializeVariables();
00019 }
Here is the call graph for this function:
AbstractSorting::AbstractSorting
6.1.2.2
AbstractSorting::InitializeVariables
virtual AbstractSorting::∼AbstractSorting () [inline, virtual]
Método destrutor. Responsável por liberar todos os recursos alocados.
Definition at line 78 of file SortingAlgorithms.h.
00078 {}
6.1.3
Member Function Documentation
6.1.3.1
long double AbstractSorting::ComparisonsNumber (void) [inline]
Método que retorna o número de comparações realizadas entre elementos da lista de Elementos.
Definition at line 68 of file SortingAlgorithms.h.
00068 { return _numero_de_comparacoes; };
Here is the caller graph for this function:
MyApplication::OrdenaListaDeNumeros
AbstractSorting::ComparisonsNumber
ProgramTest
main
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
18. 6.1 AbstractSorting Class Reference
6.1.3.2
17
void AbstractSorting::InitializeVariables (void)
Método que executa a inicialização das variáveis de estado da classe para posterior avaliação do desempenho dos algoritmos utilizados.
Definition at line 26 of file SortingAlgorithms.cxx.
00027 {
00028
_numero_de_iteracoes
= 0;
00029
_numero_de_trocas
= 0;
00030
_numero_de_comparacoes = 0;
00031 }
Here is the caller graph for this function:
AbstractSorting::AbstractSorting
AbstractSorting::InitializeVariables
MyApplication::OrdenaListaDeNumeros
6.1.3.3
long double AbstractSorting::InversionsNumber (void) [inline]
Método que retorna o número de trocas ou mudanças de valor entre posições dentro da lista de Elementos.
Definition at line 62 of file SortingAlgorithms.h.
00062 { return _numero_de_trocas; };
Here is the caller graph for this function:
MyApplication::OrdenaListaDeNumeros
AbstractSorting::InversionsNumber
ProgramTest
6.1.3.4
main
long double AbstractSorting::IterationsNumber (void) [inline]
Método que retorna o número de iterações realizadas pelo último algoritmo de ordenação executado.
Definition at line 56 of file SortingAlgorithms.h.
00056 { return _numero_de_iteracoes; };
Here is the caller graph for this function:
MyApplication::OrdenaListaDeNumeros
AbstractSorting::IterationsNumber
ProgramTest
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
main
19. 18
Class Documentation
6.1.3.5
virtual void AbstractSorting::sort (ElementVector & ev) [pure virtual]
Método que executa a ordenação dos elementos.
Implemented in BubbleSort, BubbleSort2, GnomeSort, ShakerSort, CombSort, InsertionSort, SelectionSort, QuickPivotCentral, QuickPivotPeripheral, MergeSort, ShellSort, HeapSort, and InternalQuickSort.
Here is the caller graph for this function:
ExecuteSort
ProgramTest
main
AbstractSorting::sort
MyApplication::OrdenaListaDeNumeros
6.1.4
Member Data Documentation
6.1.4.1
long double AbstractSorting::_numero_de_comparacoes [protected]
Atributo que irá armazenar o número de comparações realizadas.
Definition at line 37 of file SortingAlgorithms.h.
6.1.4.2
long double AbstractSorting::_numero_de_iteracoes [protected]
Atributo que irá armazenar o numero de iterações realizadas em cada algoritmo contado como operação de
maior relevância a comparação e a possivel troca de valor entre duas posições que armazenam o valor de
um determinado elemento.
Definition at line 26 of file SortingAlgorithms.h.
6.1.4.3
long double AbstractSorting::_numero_de_trocas [protected]
Atributo que irá armazenar para alguns algoritmos o número efetivo de trocas realizadas necessárias para a
ordenação da lista de elementos
Definition at line 32 of file SortingAlgorithms.h.
The documentation for this class was generated from the following files:
• SortingAlgorithms.h
• SortingAlgorithms.cxx
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
20. 6.2 RNG::BoxMuller Class Reference
6.2
19
RNG::BoxMuller Class Reference
#include <RandomNumberGenerator.h>
Inheritance diagram for RNG::BoxMuller:
RNG::RandomNumberGenerator
- _seed
+ RandomNumberGenerator()
+ RandomNumberGenerator()
+ InitSeed()
+ ClockRandomSeed()
+ Seed()
+ GetInt()
+ GetInt()
+ GetInt()
+ GetDouble()
+ Random()
+ GetDouble()
+ GetDouble()
+ ~RandomNumberGenerator()
RNG::BoxMuller
+ BoxMuller()
+ BoxMuller()
+ operator()()
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
21. 20
Class Documentation
Collaboration diagram for RNG::BoxMuller:
RNG::RandomNumberGenerator
- _seed
+ RandomNumberGenerator()
+ RandomNumberGenerator()
+ InitSeed()
+ ClockRandomSeed()
+ Seed()
+ GetInt()
+ GetInt()
+ GetInt()
+ GetDouble()
+ Random()
+ GetDouble()
+ GetDouble()
+ ~RandomNumberGenerator()
RNG::BoxMuller
+ BoxMuller()
+ BoxMuller()
+ operator()()
Public Member Functions
• BoxMuller ()
• BoxMuller (unsigned long seed)
• double operator() (double Mean, double StandardDev)
6.2.1
Detailed Description
Classe para geração de números pseudo-aleatórios que tem como principal algoritmo a distribuição BoxMuller ou Forma Polar da Transformação Box-Muller, caracterizado como um método simples de geração
de números aleatórios em distribução normal através de números aleatórios uniformemente distrbuídos,
ou seja, o algoritmo converte sequências de distribuição uniforme U(0,1) em sequências com distribuição
gaussiana N(0,1).
Definition at line 535 of file RandomNumberGenerator.h.
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
22. 6.2 RNG::BoxMuller Class Reference
6.2.2
Constructor & Destructor Documentation
6.2.2.1
21
RNG::BoxMuller::BoxMuller () [inline]
Método construtor da classe de geracao de numeros aleatórios
Definition at line 542 of file RandomNumberGenerator.h.
00542 : RandomNumberGenerator() {};
6.2.2.2
RNG::BoxMuller::BoxMuller (unsigned long seed) [inline]
Método construtor que recebe uma semente inicial
Definition at line 547 of file RandomNumberGenerator.h.
00547 : RandomNumberGenerator(seed) {};
6.2.3
Member Function Documentation
6.2.3.1
double RNG::BoxMuller::operator() (double Mean, double StandardDev)
Overload do operador () fazendo com que o objeto criado tenha um aspecto de objeto-função. Esse método
retorna números pseudo-aleatório reais distribuídos dentro intervalo compreendido entre 0 e 1. Parâmetros
: Mean - Média , StandardDev - Desvio Padrão
Classe para geração de números pseudo-aleatórios que tem como principal algoritmo a distribuição BoxMuller ou Forma Polar da Transformação Box-Muller, caracterizado como um método simples de geração
de números aleatórios em distribução normal através de números aleatórios uniformemente distrbuídos,
ou seja, o algoritmo converte sequências de distribuição uniforme U(0,1) em sequências com distribuição
gaussiana N(0,1). Overload do operador () fazendo com que o objeto criado tenha um aspecto de objetofunção. Esse método retorna números pseudo-aleatório reais distribuídos dentro intervalo compreendido
entre 0 e 1.
Definition at line 453 of file RandomNumberGenerator.cxx.
00454 {
00455
float x1, x2, w, y1;
00456
static float y2;
00457
static bool use_last = false;
00458
00459
//Verifica se o valor usado deve ser o da última chamada
00460
if (use_last)
00461
{
00462
y1 = y2;
00463
use_last = false;
00464
}
00465
else
00466
{
00467
00468
//Calculo da localização do número dentro do intervalo passado
00469
do
00470
{
00471
x1 = 2.0 * GetDouble() - 1.0;
00472
x2 = 2.0 * GetDouble() - 1.0;
00473
w = x1 * x1 + x2 * x2;
00474
}
00475
while ( w >= 1.0 );
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
23. 22
Class Documentation
00476
00477
w = sqrt( (-2.0 * log( w ) ) / w );
00478
y1 = x1 * w;
00479
y2 = x2 * w;
00480
use_last = true;
00481
}
00482
00483
//Retorno do número transformado ...
00484
return( Mean + y1 * StandardDev );
00485 }
Here is the call graph for this function:
RNG::BoxMuller::operator()
RNG::RandomNumberGenerator::GetDouble
The documentation for this class was generated from the following files:
• RandomNumberGenerator.h
• RandomNumberGenerator.cxx
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
24. 6.3 BubbleSort Class Reference
6.3
23
BubbleSort Class Reference
#include <SortingAlgorithms.h>
Inheritance diagram for BubbleSort:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
BubbleSort
+ BubbleSort()
+ sort()
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
25. 24
Class Documentation
Collaboration diagram for BubbleSort:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
BubbleSort
+ BubbleSort()
+ sort()
Public Member Functions
• BubbleSort ()
• void sort (ElementVector &ev)
6.3.1
Detailed Description
Método da ordenação em bolha ou método bubble sort. Esse primeiro método é da ordem quadrática e não
constitui um algoritmo ótimo para ordenação, porém sua complexidade de implementação é muita baixa
(trivial) em relação a outros algoritmos da mesma classe tal como o quicksort.
Definition at line 88 of file SortingAlgorithms.h.
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
26. 6.3 BubbleSort Class Reference
25
6.3.2
Constructor & Destructor Documentation
6.3.2.1
BubbleSort::BubbleSort () [inline]
Contructor
Definition at line 94 of file SortingAlgorithms.h.
00094 :AbstractSorting(){};
6.3.3
Member Function Documentation
6.3.3.1
void BubbleSort::sort (ElementVector & ev) [virtual]
Método que executa a ordenação dos elementos.
Método da ordenação em bolha ou bubblesort. Esse primeiro método é da ordem quadrática e não constitui
um algoritmo ótimo para ordenação, porém sua complexidade de implementação é muita baixa (trivial) em
relação a outros algoritmos da mesma classe tal como o quicksort.
Implements AbstractSorting.
Definition at line 43 of file SortingAlgorithms.cxx.
00044 {
00045
//std::cout << "Bubble..." << std::endl;
00046
register unsigned int i,j;
00047
00048
//executa loopings para varrer a lista de números
00049
for (i = 1; i < ev.size(); ++i)
00050
{
00051
for(j = ev.size()-1; j >= i; --j)
00052
{
00053
//executa troca caso encontre elementos desordenados
00054
if ( ev[j-1] > ev[j] )
00055
{
00056
ev.swap(j-1,j);
00057
_numero_de_trocas++;
00058
}
00059
_numero_de_comparacoes++;
00060
_numero_de_iteracoes++;
00061
}
00062
}
00063 }
Here is the call graph for this function:
ElementVector::size
BubbleSort::sort
ElementVector::swap
The documentation for this class was generated from the following files:
• SortingAlgorithms.h
• SortingAlgorithms.cxx
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
27. 26
6.4
Class Documentation
BubbleSort2 Class Reference
#include <SortingAlgorithms.h>
Inheritance diagram for BubbleSort2:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
BubbleSort2
+ BubbleSort2()
+ sort()
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
28. 6.4 BubbleSort2 Class Reference
27
Collaboration diagram for BubbleSort2:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
BubbleSort2
+ BubbleSort2()
+ sort()
Public Member Functions
• BubbleSort2 ()
• void sort (ElementVector &ev)
6.4.1
Detailed Description
Método da ordenação em bolha com alguma melhora em relação ao número de iterações e trocas. Caso
não haja nenhuma troca o algoritmo não executa todas as iterações necessarias. Caso hajam muitas trocas
a serem feitas o número de iterações irá superar o convencional estipulado pelo algoritmo BubbleSort
convencional.
Definition at line 109 of file SortingAlgorithms.h.
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
29. 28
Class Documentation
6.4.2
Constructor & Destructor Documentation
6.4.2.1
BubbleSort2::BubbleSort2 () [inline]
Contructor
Definition at line 115 of file SortingAlgorithms.h.
00115 :AbstractSorting(){};
6.4.3
Member Function Documentation
6.4.3.1
void BubbleSort2::sort (ElementVector & ev) [virtual]
Método que executa a ordenação dos elementos.
Método da ordenação em bolha com alguma melhora em relação ao número de iterações e trocas. Caso
não haja nenhuma troca o algoritmo não executa todas as iterações necessarias. Caso hajam muitas trocas
a serem feitas o número de iterações irá superar o convencional estipulado pelo algoritmo BubbleSort
convencional.
Implements AbstractSorting.
Definition at line 72 of file SortingAlgorithms.cxx.
00073 {
00074
bool houvetroca = false;
00075
register unsigned int index = 0;
00076
register unsigned int size_vector = ev.size();
00077
00078
while ((!houvetroca) && (index < size_vector - 1))
00079
{
00080
index = 0;
00081
while(index < size_vector - 1)
00082
{
00083
00084
//Verifica o número de comparações realizadas
00085
_numero_de_comparacoes++;
00086
00087
//Verifica se algum elemento deve sofrer inversão
00088
if (ev[index] > ev[index + 1])
00089
{
00090
ev.swap(index + 1,index);
00091
houvetroca = true;
00092
_numero_de_trocas++;
00093
}
00094
00095
//Caso haja troca retorna o indice para o começo da lista
00096
if(houvetroca) { index = 0; houvetroca = false; }
00097
else { ++index;}
00098
_numero_de_iteracoes++;
00099
}
00100
}
00101 }
Here is the call graph for this function:
ElementVector::size
BubbleSort2::sort
ElementVector::swap
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
30. 6.4 BubbleSort2 Class Reference
The documentation for this class was generated from the following files:
• SortingAlgorithms.h
• SortingAlgorithms.cxx
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
29
31. 30
Class Documentation
6.5
Color Class Reference
#include <Color.h>
Public Member Functions
•
•
•
•
•
•
•
•
Color (unsigned char r=255, unsigned char g=255, unsigned char b=255)
void r (unsigned char red)
void g (unsigned char green)
void b (unsigned char blue)
unsigned char r (void)
unsigned char g (void)
unsigned char b (void)
virtual ∼Color ()
6.5.1
Detailed Description
Classe para armazenamento das componentes da cor em rgb variando 0 até 255.
Definition at line 15 of file Color.h.
6.5.2
Constructor & Destructor Documentation
6.5.2.1
Color::Color (unsigned char r = 255, unsigned char g = 255, unsigned char b = 255)
[inline]
Metodo Construtor da classe Color
Definition at line 37 of file Color.h.
00038
: _r(r), _g(g), _b(b) {};
6.5.2.2
virtual Color::∼Color () [inline, virtual]
Método destrutor. Responsável por liberar todos os recursos alocados pela classe.
Definition at line 74 of file Color.h.
00074 {};
6.5.3
Member Function Documentation
6.5.3.1
unsigned char Color::b (void) [inline]
Método que retorna o valor da componente azul
Definition at line 68 of file Color.h.
00068 { return _b; };
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
32. 6.5 Color Class Reference
6.5.3.2
void Color::b (unsigned char blue) [inline]
Método que atribui um valor a componente azul
Definition at line 53 of file Color.h.
00053 { _b = blue; };
6.5.3.3
unsigned char Color::g (void) [inline]
Método que retorna o valor da componente verde
Definition at line 63 of file Color.h.
00063 { return _g; };
6.5.3.4
void Color::g (unsigned char green) [inline]
Método que atribui um valor a componente verde
Definition at line 48 of file Color.h.
00048 { _g = green; };
6.5.3.5
unsigned char Color::r (void) [inline]
Método que retorna o valor da componente vermelha
Definition at line 58 of file Color.h.
00058 { return _r; };
6.5.3.6
void Color::r (unsigned char red) [inline]
Método que atribui um valor a componente vermelha
Definition at line 43 of file Color.h.
00043 { _r = red;
};
The documentation for this class was generated from the following file:
• Color.h
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
31
33. 32
6.6
Class Documentation
CombSort Class Reference
#include <SortingAlgorithms.h>
Inheritance diagram for CombSort:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
CombSort
+ CombSort()
+ sort()
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
34. 6.6 CombSort Class Reference
33
Collaboration diagram for CombSort:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
CombSort
+ CombSort()
+ sort()
Public Member Functions
• CombSort ()
• void sort (ElementVector &ev)
6.6.1
Detailed Description
Método que repetidamente reordena diferentes pares de itens, separados por um salto, que é calculado a
cada passagem, semelhante ao Bubble Sort, porém mais eficiente. O CombSort é um algoritmo relativamente simplista orinalmente criado por Wlodek Dobosiewicz em 1980, mais tarde redescoberto e popularizado por Stephen Lacey e Richard Box com um artigo na Byte Magazine [artigo publicado em abril
em 1991]. A idéia básica é a eliminação das ’Turtles’, ou valores pequenos perto do final da lista, já que
no bubble sort estes valores pequenos retardam tremendamente a triagem e ordenação quando deslocados
para baixo[ou começo da lista]. ’Rabbits’, grandes valores em torno do início da lista, não representam um
problema no bubble sort. A maioria dos autores interpretam esse algoritmo como uma variante do Shell
Sort, só que usando um núcleo baseado em trocas [bubble] ao invés de inserções como o próprio Shell Sort.
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
35. 34
Class Documentation
Definition at line 180 of file SortingAlgorithms.h.
6.6.2
Constructor & Destructor Documentation
6.6.2.1
CombSort::CombSort () [inline]
Contructor
Definition at line 186 of file SortingAlgorithms.h.
00186 :AbstractSorting(){};
6.6.3
Member Function Documentation
6.6.3.1
void CombSort::sort (ElementVector & ev) [virtual]
Método que executa a ordenação dos elementos.
Método que repetidamente reordena diferentes pares de itens, separados por um salto, que é calculado a
cada passagem, semelhante ao Bubble Sort, porém mais eficiente. O CombSort é um algoritmo relativamente simplista orinalmente criado por Wlodek Dobosiewicz em 1980, mais tarde redescoberto e popularizado por Stephen Lacey e Richard Box com um artigo na Byte Magazine [artigo publicado em abril
em 1991]. A idéia básica é a eliminação das ’Turtles’, ou valores pequenos perto do final da lista, já que
no bubble sort estes valores pequenos retardam tremendamente a triagem e ordenação quando deslocados
para baixo[ou começo da lista]. ’Rabbits’, grandes valores em torno do início da lista, não representam um
problema no bubble sort. A maioria dos autores interpretam esse algoritmo como uma variante do Shell
Sort, só que usando um núcleo baseado em trocas [bubble] ao invés de inserções como o próprio Shell Sort.
Implements AbstractSorting.
Definition at line 556 of file SortingAlgorithms.cxx.
00557 {
00558
//Variáveis de controle do tamanho do gap/salto/intervalo e troca de elementos
00559
int gap = (int)ev.size();
00560
int size_vector = (int)ev.size();
00561
bool swapped = true;
00562
00563
//Verifica se o gap é maior que um ou se ainda está ocorrendo trocas
00564
while (gap > 1 || swapped)
00565
{
00566
//Calculo do gap/salto/intervalo de aferição ou comparação dos elementos
00567
if (gap > 1) { gap = (int) (gap / 1.3); }
00568
00569
//Variaveis de controle
00570
int i = 0;
00571
swapped = false;
00572
00573
//Looping onde ocorrerá verificações e trocas
00574
while (i + gap < size_vector)
00575
{
00576
_numero_de_iteracoes++;
00577
_numero_de_comparacoes++;
00578
if (ev[i] > ev[i + gap])
00579
{
00580
_numero_de_trocas++;
00581
ev.swap(i, i+gap);
00582
swapped = true;
00583
}
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
36. 6.6 CombSort Class Reference
35
00584
i++;
00585
}
00586
}
00587 }
Here is the call graph for this function:
ElementVector::size
CombSort::sort
ElementVector::swap
The documentation for this class was generated from the following files:
• SortingAlgorithms.h
• SortingAlgorithms.cxx
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
37. 36
Class Documentation
6.7
LibraryUtils::ConversionError Class Reference
#include <LibraryUtils.h>
Public Member Functions
• const char ∗ what ()
6.7.1
Detailed Description
Definition at line 36 of file LibraryUtils.h.
6.7.2
Member Function Documentation
6.7.2.1
const char∗ LibraryUtils::ConversionError::what () [inline]
Definition at line 39 of file LibraryUtils.h.
00039 { return "Erro de conversão !"; };
The documentation for this class was generated from the following file:
• LibraryUtils.h
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
39. 38
Class Documentation
Collaboration diagram for RNG::Distribution:
RNG::RandomNumberGenerator
- _seed
+ RandomNumberGenerator()
+ RandomNumberGenerator()
+ InitSeed()
+ ClockRandomSeed()
+ Seed()
+ GetInt()
+ GetInt()
+ GetInt()
+ GetDouble()
+ Random()
+ GetDouble()
+ GetDouble()
+ ~RandomNumberGenerator()
RNG::Distribution
+ Distribution()
+ Distribution()
+ Bernoulli()
+ Binomial()
+ Equilikely()
+ Geometric()
+ Pascal()
+ Poisson()
+ Uniform()
+ Exponential()
+ Erlang()
+ Normal()
+ Lognormal()
+ Chisquare()
+ Student()
Public Member Functions
•
•
•
•
•
•
•
•
•
•
•
•
•
Distribution ()
Distribution (unsigned long seed)
long Bernoulli (double probability=0.5)
long Binomial (unsigned long limit_experiment, double probability=0.5)
long Equilikely (long a, long b)
unsigned long Geometric (double probability=0.5)
long Pascal (unsigned long limit_experiment, double probability=0.5)
long Poisson (double mean)
double Uniform (double a, double b)
double Exponential (double mean=0.5)
double Erlang (long limit_experiment, double base)
double Normal (double Mean, double StandarDev)
double Lognormal (double a, double b)
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
40. 6.8 RNG::Distribution Class Reference
39
• double Chisquare (unsigned long limit_experiment)
• double Student (unsigned long limit_experiment)
6.8.1
Detailed Description
Classe para geração de números pseudo-aleatórios que possui em seu núcleo um gerador com distribuição
uniforme - no caso específico dessa classe usaremos a ancestral RandomNumberGenerator para gerar essa
distribuição uniforme e a partir desse ’motor’ iremos gerar os demais tipos de distribuição. Com isso
teremos para a classe Distribuition 6 distribuições discretas :
Generator Range (x) Mean Variance
Bernoulli(p) x = 0,1 p p∗(1-p) Binomial(n, p) x = 0,...,n n∗p n∗p∗(1-p) Equilikely(a, b) x = a,...,b (a+b)/2
((b-a+1)∗(b-a+1)-1)/12 Geometric(p) x = 0,... p/(1-p) p/((1-p)∗(1-p)) Pascal(n, p) x = 0,... n∗p/(1-p)
n∗p/((1-p)∗(1-p)) Poisson(m) x = 0,... m m
E sete distribuições contínuas :
Uniform(a, b) a < x < b (a + b)/2 (b - a)∗(b - a)/12 Exponential(m) x > 0 m m∗m Erlang(n, b) x > 0 n∗b
n∗b∗b Normal(m, s) all x m s∗s Lognormal(a, b) x > 0 (ver abaixo) Chisquare(n) x > 0 n 2∗n Student(n)
all x 0 (n > 1) n/(n - 2) (n > 2)
Para a Lognormal(a, b), sua média e sua variância serão dadas por:
mean = exp(a + 0.5∗b∗b) variance = (exp(b∗b) - 1) ∗ exp(2∗a + b∗b)
Definition at line 590 of file RandomNumberGenerator.h.
6.8.2
Constructor & Destructor Documentation
6.8.2.1
RNG::Distribution::Distribution () [inline]
Método construtor da classe de geracao de numeros aleatórios
Definition at line 597 of file RandomNumberGenerator.h.
00597 : RandomNumberGenerator() {};
6.8.2.2
RNG::Distribution::Distribution (unsigned long seed) [inline]
Método construtor que recebe uma semente inicial
Definition at line 602 of file RandomNumberGenerator.h.
00602 : RandomNumberGenerator(seed) {};
6.8.3
Member Function Documentation
6.8.3.1
long RNG::Distribution::Bernoulli (double probability = 0.5)
Método que retorna 1 com probabilidade p ou 0 com probabilidade (1-p). Para isso p deverá estar compreendido no intervalo aberto 0.0 e 1.0 - (0.0, 1.0) Adotamos aqui 0.5 como 50% de chance do número
randômico ser maior ou menor que o número internamente escolhido pelo método.
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
41. 40
Class Documentation
Classe para geração de números pseudo-aleatórios que possui em seu núcleo um gerador com distribuição
uniforme - no caso específico dessa classe usaremos a ancestral RandomNumberGenerator para gerar essa
distribuição uniforme e a partir desse ’motor’ iremos gerar os demais tipos de distribuição. Com isso
Método que retorna 1 com probabilidade p ou 0 com probabilidade (1-p). Para isso ’p’ deverá estar compreendido no intervalo aberto 0.0 e 1.0 - (0.0, 1.0)
Definition at line 500 of file RandomNumberGenerator.cxx.
00501 {
00502
return ((Random() < (1.0 - probability)) ? 0 : 1);
00503 }
Here is the call graph for this function:
RNG::Distribution::Bernoulli
RNG::RandomNumberGenerator::Random
RNG::RandomNumberGenerator::GetDouble
Here is the caller graph for this function:
RNG::Distribution::Bernoulli
6.8.3.2
RNG::Distribution::Binomial
long RNG::Distribution::Binomial (unsigned long limit_experiment, double probability =
0.5)
Método que retorna um inteiro distribuído de forma binomial entre 0 e limit Nota : use limit > 0 e 0.0 <
probabilidade < 1.0
Definition at line 509 of file RandomNumberGenerator.cxx.
00510 {
00511
unsigned long i, x = 0;
00512
for (i = 0; i < limit_experiment; i++)
00513
return (x);
00514 }
x += Bernoulli(probability);
Here is the call graph for this function:
RNG::Distribution::Binomial
6.8.3.3
RNG::Distribution::Bernoulli
RNG::RandomNumberGenerator::Random
RNG::RandomNumberGenerator::GetDouble
double RNG::Distribution::Chisquare (unsigned long limit_experiment)
Método que retorna um número real com distribuição Chi-square. Nota: use limit_experiment > 0
Definition at line 635 of file RandomNumberGenerator.cxx.
00636 {
00637
unsigned long
i;
00638
double z, x = 0.0;
00639
00640
for (i = 0; i < limit_experiment; i++)
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
42. 6.8 RNG::Distribution Class Reference
41
00641
{
00642
z = Normal(0.0, 1.0);
00643
x += z * z;
00644
}
00645
00646
return (x);
00647 }
Here is the call graph for this function:
RNG::Distribution::Chisquare
RNG::Distribution::Normal
RNG::RandomNumberGenerator::Random
RNG::RandomNumberGenerator::GetDouble
Here is the caller graph for this function:
RNG::Distribution::Chisquare
6.8.3.4
RNG::Distribution::Student
long RNG::Distribution::Equilikely (long a, long b)
Método que retorna um inteiro eqüitativamente distribuído compreendido no intervalo semi-aberto (a,b].
Definition at line 520 of file RandomNumberGenerator.cxx.
00521 {
00522
if (a > b) swap(a,b); // Verificando se o intervalo foi fornecido corretamente
00523
return (a + (long)((b - a + 1) * Random()));
00524 }
Here is the call graph for this function:
RNG::RandomNumberGenerator::Random
RNG::RandomNumberGenerator::GetDouble
RNG::Distribution::Equilikely
RNG::swap
6.8.3.5
double RNG::Distribution::Erlang (long limit_experiment, double base)
Método que retorna um número real positivo com distribuição de Erlang. Nota: use limit_experiment > 0
e base > 0.0
Definition at line 587 of file RandomNumberGenerator.cxx.
00588 {
00589
long
i;
00590
double x = 0.0;
00591
for (i = 0; i < limit_experiment; i++) x += Exponential(base);
00592
return (x);
00593 }
Here is the call graph for this function:
RNG::Distribution::Erlang
RNG::Distribution::Exponential
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
RNG::RandomNumberGenerator::Random
RNG::RandomNumberGenerator::GetDouble
43. 42
6.8.3.6
Class Documentation
double RNG::Distribution::Exponential (double mean = 0.5)
Método que retorna um número real positivo exponencialmente distribuído. Nota: use mean > 0.0
Definition at line 578 of file RandomNumberGenerator.cxx.
00579 {
00580
return (-mean * log(1.0 - Random()));
00581 }
Here is the call graph for this function:
RNG::Distribution::Exponential
RNG::RandomNumberGenerator::Random
RNG::RandomNumberGenerator::GetDouble
Here is the caller graph for this function:
RNG::Distribution::Erlang
RNG::Distribution::Exponential
RNG::Distribution::Poisson
6.8.3.7
unsigned long RNG::Distribution::Geometric (double probability = 0.5)
Método que retorna um inteiro não negativo geometricamente distribuído. Nota: use 0.0 < p < 1.0
Definition at line 530 of file RandomNumberGenerator.cxx.
00531 {
00532
return ((long) (log(1.0 - Random()) / log(probability)));
00533 }
Here is the call graph for this function:
RNG::Distribution::Geometric
RNG::RandomNumberGenerator::Random
RNG::RandomNumberGenerator::GetDouble
Here is the caller graph for this function:
RNG::Distribution::Geometric
6.8.3.8
RNG::Distribution::Pascal
double RNG::Distribution::Lognormal (double a, double b)
Método que retorna um número real com distribuição lognormal. Nota: use b > 0.0
Definition at line 626 of file RandomNumberGenerator.cxx.
00627 {
00628
return (exp(a + b * Normal(0.0, 1.0)));
00629 }
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
44. 6.8 RNG::Distribution Class Reference
43
Here is the call graph for this function:
RNG::Distribution::Lognormal
6.8.3.9
RNG::Distribution::Normal
RNG::RandomNumberGenerator::Random
RNG::RandomNumberGenerator::GetDouble
double RNG::Distribution::Normal (double Mean, double StandarDev)
Método que retorna um número real com distribuição normal (gaussiana). Nota: use StandardDev > 0.0
Definition at line 599 of file RandomNumberGenerator.cxx.
00600 {
00601
const double p0 = 0.322232431088;
const double q0
00602
const double p1 = 1.0;
const double q1
00603
const double p2 = 0.342242088547;
const double q2
00604
const double p3 = 0.204231210245e-1; const double q3
00605
const double p4 = 0.453642210148e-4; const double q4
00606
double u, t, p, q, z;
00607
00608
u
= Random();
00609
00610
if (u < 0.5) t = sqrt(-2.0 * log(u));
00611
else t = sqrt(-2.0 * log(1.0 - u));
00612
00613
p
= p0 + t * (p1 + t * (p2 + t * (p3 + t * p4)));
00614
q
= q0 + t * (q1 + t * (q2 + t * (q3 + t * q4)));
00615
00616
if (u < 0.5) z = (p / q) - t;
00617
else
z = t - (p / q);
00618
00619
return (Mean + StandarDev * z);
00620 }
=
=
=
=
=
0.099348462606;
0.588581570495;
0.531103462366;
0.103537752850;
0.385607006340e-2;
Here is the call graph for this function:
RNG::Distribution::Normal
RNG::RandomNumberGenerator::Random
RNG::RandomNumberGenerator::GetDouble
Here is the caller graph for this function:
RNG::Distribution::Chisquare
RNG::Distribution::Student
RNG::Distribution::Normal
RNG::Distribution::Lognormal
6.8.3.10
long RNG::Distribution::Pascal (unsigned long limit_experiment, double probability =
0.5)
Método que retorna um inteiro não negativo com distribuição de Pascal. Nota: use n > 0 e 0.0 < p < 1.0
Definition at line 539 of file RandomNumberGenerator.cxx.
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
45. 44
Class Documentation
00540 {
00541
unsigned long i, x = 0;
00542
for (i = 0; i < limit_experiment; i++) x += Geometric(probability);
00543
return (x);
00544 }
Here is the call graph for this function:
RNG::Distribution::Pascal
6.8.3.11
RNG::Distribution::Geometric
RNG::RandomNumberGenerator::Random
RNG::RandomNumberGenerator::GetDouble
long RNG::Distribution::Poisson (double mean)
Método que retorna um inteiro não negativo com distribuição de Poisson. Nota: use mean > 0
Definition at line 550 of file RandomNumberGenerator.cxx.
00551 {
00552
double t = 0.0;
00553
long
x = 0;
00554
00555
while (t < mean)
00556
{
00557
t += Exponential(1.0);
00558
x++;
00559
}
00560
00561
return (x - 1);
00562 }
Here is the call graph for this function:
RNG::Distribution::Poisson
6.8.3.12
RNG::Distribution::Exponential
RNG::RandomNumberGenerator::Random
RNG::RandomNumberGenerator::GetDouble
double RNG::Distribution::Student (unsigned long limit_experiment)
Método que retorna um número real com distribuição Student-t. Nota: use limit_experiment > 0
Definition at line 653 of file RandomNumberGenerator.cxx.
00654 {
00655
return (Normal(0.0, 1.0)/sqrt(Chisquare(limit_experiment)/limit_experiment));
00656 }
Here is the call graph for this function:
RNG::Distribution::Chisquare
RNG::Distribution::Student
RNG::Distribution::Normal
RNG::RandomNumberGenerator::Random
RNG::RandomNumberGenerator::GetDouble
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
46. 6.8 RNG::Distribution Class Reference
6.8.3.13
45
double RNG::Distribution::Uniform (double a, double b)
Método que retorna um número real uniformemente distribuído entre a e b. Nota: use a < b.
Definition at line 568 of file RandomNumberGenerator.cxx.
00569 {
00570
if (a > b) swap(a,b);
00571
return (a + (b - a) * Random());
00572 }
Here is the call graph for this function:
RNG::RandomNumberGenerator::Random
RNG::RandomNumberGenerator::GetDouble
RNG::Distribution::Uniform
RNG::swap
The documentation for this class was generated from the following files:
• RandomNumberGenerator.h
• RandomNumberGenerator.cxx
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
47. 46
Class Documentation
6.9
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 ()
6.9.1
Detailed Description
Classe para armazenamento das caracteristicas de um determinado elemento
Definition at line 18 of file Element.h.
6.9.2
Constructor & Destructor Documentation
6.9.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
6.9.2.2
Element::value
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 {};
6.9.3
Member Function Documentation
6.9.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.
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
48. 6.9 Element Class Reference
47
00050 { return (this->value() < e.value()); };
Here is the call graph for this function:
Element::operator<
6.9.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<=
6.9.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>
6.9.3.4
Element::value
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>
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
49. 48
Class Documentation
6.9.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:
ElementVector::maxValue
ElementVector::absMaxValue
MyApplication::GeraListaDeNumeros
ElementVector::minValue
Element::operator<
Element::value
Element::operator<=
Element::operator>
MyApplication::OrdenaListaDeNumeros
ProgramTest
main
The documentation for this class was generated from the following file:
• Element.h
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
50. 6.10 ElementVector Class Reference
6.10
49
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 ()
6.10.1
Detailed Description
Classe para armazenamento de uma lista de elementos
Definition at line 76 of file Element.h.
6.10.2
Constructor & Destructor Documentation
6.10.2.1
ElementVector::ElementVector (void) [inline]
Método construtor da classe.
Definition at line 88 of file Element.h.
00088 {};
6.10.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
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
ElementVector::clear
51. 50
Class Documentation
6.10.3
Member Function Documentation
6.10.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
Here is the caller graph for this function:
ElementVector::absMaxValue
6.10.3.2
MyApplication::GeraListaDeNumeros
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:
MyApplication::GeraListaDeNumeros
ElementVector::add
MyApplication::OrdenaListaDeNumeros
ProgramTest
main
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
52. 6.10 ElementVector Class Reference
6.10.3.3
51
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::absMaxValue
MyApplication::GeraListaDeNumeros
ElementVector::minValue
ElementVector::at
MyApplication::OrdenaListaDeNumeros
ProgramTest
6.10.3.4
main
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:
MyApplication::GeraListaDeNumeros
MergeSort::Merges
MergeSort::MergeMethod
ProgramTest
main
ElementVector::clear
ElementVector::~ElementVector
6.10.3.5
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(); };
6.10.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.
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
MergeSort::sort
53. 52
Class Documentation
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
6.10.3.7
ElementVector::absMaxValue
MyApplication::GeraListaDeNumeros
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
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
54. 6.10 ElementVector Class Reference
53
Here is the caller graph for this function:
ElementVector::minValue
6.10.3.8
ElementVector::absMaxValue
MyApplication::GeraListaDeNumeros
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]; };
6.10.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); }
Here is the caller graph for this function:
MyApplication::GeraListaDeNumeros
ElementVector::push_back
ElementVector::add
MyApplication::OrdenaListaDeNumeros
ProgramTest
6.10.3.10
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); };
Here is the caller graph for this function:
ElementVector::resize
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
MergeSort::Merges
MergeSort::MergeMethod
MergeSort::sort
55. 54
6.10.3.11
Class Documentation
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:
MyApplication::GeraListaDeNumeros
MyApplication::OrdenaListaDeNumeros
ProgramTest
main
CombSort::sort
ShakerSort::sort
GnomeSort::sort
HeapSort::sort
ElementVector::size
ShellSort::sort
MergeSort::sort
QuickPivotPeripheral::sort
QuickPivotCentral::sort
SelectionSort::sort
InsertionSort::sort
BubbleSort2::sort
BubbleSort::sort
6.10.3.12
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()); };
Here is the caller graph for this function:
ElementVector::sort
InternalQuickSort::sort
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
56. 6.10 ElementVector Class Reference
6.10.3.13
55
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 }
Here is the caller graph for this function:
QuickPivotPeripheral::Partition
QuickPivotPeripheral::QSort
CombSort::sort
ShakerSort::sort
ElementVector::swap
GnomeSort::sort
SelectionSort::sort
BubbleSort2::sort
BubbleSort::sort
The documentation for this class was generated from the following files:
• Element.h
• Element.cxx
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
QuickPivotPeripheral::sort
57. 56
Class Documentation
6.11
FLPlotColor Class Reference
#include <MyGlWindowPlot.h>
Public Member Functions
•
•
•
•
•
•
•
FLPlotColor (unsigned char r=0, unsigned char g=0, unsigned char b=0)
void r (unsigned char red)
void g (unsigned char green)
void b (unsigned char blue)
unsigned char r (void)
unsigned char g (void)
unsigned char b (void)
6.11.1
Detailed Description
Classe para armazenamento das componentes da cor em rgb.
Definition at line 23 of file MyGlWindowPlot.h.
6.11.2
Constructor & Destructor Documentation
6.11.2.1
FLPlotColor::FLPlotColor (unsigned char r = 0, unsigned char g = 0, unsigned char b =
0) [inline]
Definition at line 30 of file MyGlWindowPlot.h.
00030 : _r(r), _g(g), _b(b) {};
6.11.3
Member Function Documentation
6.11.3.1
unsigned char FLPlotColor::b (void) [inline]
Definition at line 38 of file MyGlWindowPlot.h.
00038 { return _b; };
6.11.3.2
void FLPlotColor::b (unsigned char blue) [inline]
Definition at line 34 of file MyGlWindowPlot.h.
00034 {
_b = blue; };
6.11.3.3
unsigned char FLPlotColor::g (void) [inline]
Definition at line 37 of file MyGlWindowPlot.h.
00037 { return _g; };
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
58. 6.11 FLPlotColor Class Reference
6.11.3.4
void FLPlotColor::g (unsigned char green) [inline]
Definition at line 33 of file MyGlWindowPlot.h.
00033 { _g = green; };
6.11.3.5
unsigned char FLPlotColor::r (void) [inline]
Definition at line 36 of file MyGlWindowPlot.h.
00036 { return _r; };
6.11.3.6
void FLPlotColor::r (unsigned char red) [inline]
Definition at line 32 of file MyGlWindowPlot.h.
00032 { _r = red;
};
The documentation for this class was generated from the following file:
• MyGlWindowPlot.h
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
57
59. 58
Class Documentation
6.12
FLPlotPointXY Class Reference
#include <MyGlWindowPlot.h>
Collaboration diagram for FLPlotPointXY:
FLPlotColor
- _r
- _g
- _b
+ FLPlotColor()
+ r()
+ g()
+ b()
+ r()
+ g()
+ b()
_color
FLPlotPointXY
- _x
- _y
- _color
- _label
+ FLPlotPointXY()
+ FLPlotPointXY()
+ x()
+ x()
+ y()
+ y()
+ color()
+ color()
+ label()
+ label()
Public Member Functions
•
•
•
•
•
•
•
•
•
•
FLPlotPointXY ()
FLPlotPointXY (float x, float y, FLPlotColor color, std::string label)
float x (void)
void x (float X)
float y (void)
void y (float Y)
FLPlotColor color (void)
void color (FLPlotColor color)
std::string label (void)
void label (std::string L)
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
60. 6.12 FLPlotPointXY Class Reference
6.12.1
Detailed Description
Classe para armazenamento das caracteristicas do ponto
Definition at line 44 of file MyGlWindowPlot.h.
6.12.2
Constructor & Destructor Documentation
6.12.2.1
FLPlotPointXY::FLPlotPointXY () [inline]
Definition at line 52 of file MyGlWindowPlot.h.
00052 { _x = 0; _y = 0; _color = 0; _label = ""; };
6.12.2.2
FLPlotPointXY::FLPlotPointXY (float x, float y, FLPlotColor color, std::string label)
[inline]
Definition at line 53 of file MyGlWindowPlot.h.
00053 { _x = x; _y = y; _color = color; _label = label; };
6.12.3
Member Function Documentation
6.12.3.1
void FLPlotPointXY::color (FLPlotColor color) [inline]
Definition at line 62 of file MyGlWindowPlot.h.
00062 { _color
6.12.3.2
= color; };
FLPlotColor FLPlotPointXY::color (void) [inline]
Definition at line 61 of file MyGlWindowPlot.h.
00061 { return _color;
6.12.3.3
};
void FLPlotPointXY::label (std::string L) [inline]
Definition at line 65 of file MyGlWindowPlot.h.
00065 { _label
6.12.3.4
= L;
};
std::string FLPlotPointXY::label (void) [inline]
Definition at line 64 of file MyGlWindowPlot.h.
00064 { return _label; };
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
59
61. 60
Class Documentation
6.12.3.5
void FLPlotPointXY::x (float X) [inline]
Definition at line 56 of file MyGlWindowPlot.h.
00056 { _x
6.12.3.6
= X;
};
float FLPlotPointXY::x (void) [inline]
Definition at line 55 of file MyGlWindowPlot.h.
00055 { return _x; };
6.12.3.7
void FLPlotPointXY::y (float Y) [inline]
Definition at line 59 of file MyGlWindowPlot.h.
00059 { _y
6.12.3.8
= Y;
};
float FLPlotPointXY::y (void) [inline]
Definition at line 58 of file MyGlWindowPlot.h.
00058 { return _y; };
The documentation for this class was generated from the following file:
• MyGlWindowPlot.h
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
62. 6.13 GnomeSort Class Reference
6.13
61
GnomeSort Class Reference
#include <SortingAlgorithms.h>
Inheritance diagram for GnomeSort:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
GnomeSort
+ GnomeSort()
+ sort()
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
63. 62
Class Documentation
Collaboration diagram for GnomeSort:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
GnomeSort
+ GnomeSort()
+ sort()
Public Member Functions
• GnomeSort ()
• void sort (ElementVector &ev)
6.13.1
Detailed Description
Método similiar ao Insertion sort com a diferença que o GnomeSort leva um elemento para sua posição
correta, com uma seqüencia grande de trocas assim como o Bubble sort. O algoritmo percorre o vetor
comparando seus elementos dois a dois, assim que ele encontra um elemento que está na posição incorreta,
ou seja, um número maior antes de um menor, ele troca a posição dos elementos, e volta com este elemento
até que encontre o seu respectivo lugar.
Definition at line 132 of file SortingAlgorithms.h.
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
64. 6.13 GnomeSort Class Reference
63
6.13.2
Constructor & Destructor Documentation
6.13.2.1
GnomeSort::GnomeSort () [inline]
Contructor
Definition at line 138 of file SortingAlgorithms.h.
00138 :AbstractSorting(){};
6.13.3
Member Function Documentation
6.13.3.1
void GnomeSort::sort (ElementVector & ev) [virtual]
Método que executa a ordenação dos elementos.
Método similiar ao Insertion sort com a diferença que o GnomeSort leva um elemento para sua posição
correta, com uma seqüencia grande de trocas assim como o Bubble sort. O algoritmo percorre o vetor
comparando seus elementos dois a dois, assim que ele encontra um elemento que está na posição incorreta,
ou seja, um número maior antes de um menor, ele troca a posição dos elementos, e volta com este elemento
até que encontre o seu respectivo lugar.
Implements AbstractSorting.
Definition at line 463 of file SortingAlgorithms.cxx.
00464 {
00465
//Controlador de indice de posicionamento
00466
unsigned int index = 1;
00467
00468
//looping que executa as ordenações
00469
while( index < ev.size() )
00470
{
00471
//Sempre executa uma comparação antes de modificar o índice
00472
_numero_de_comparacoes++;
00473
_numero_de_iteracoes++;
00474
if((index == 0) || ( ev[index-1] <= ev[index] ))
00475
{
00476
index++;
00477
}
00478
else
00479
{
00480
_numero_de_trocas++;
00481
ev.swap( index - 1, index );
00482
--index;
00483
}
00484
}
00485 }
Here is the call graph for this function:
ElementVector::size
GnomeSort::sort
ElementVector::swap
The documentation for this class was generated from the following files:
• SortingAlgorithms.h
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
66. 6.14 HeapSort Class Reference
6.14
65
HeapSort Class Reference
#include <SortingAlgorithms.h>
Inheritance diagram for HeapSort:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
HeapSort
+ HeapSort()
+ sort()
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
67. 66
Class Documentation
Collaboration diagram for HeapSort:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
HeapSort
+ HeapSort()
+ sort()
Public Member Functions
• HeapSort ()
• void sort (ElementVector &ev)
6.14.1
Detailed Description
O algoritmo heapsort é um algoritmo de ordenação generalista, e faz parte da família de algoritmos de
ordenação por seleção. Tem um desempenho em tempo de execução muito bom em conjuntos ordenados
aleatoriamente, tem um uso de memória bem comportado e o seu desempenho em pior cenário é praticamente igual ao desempenho em cenário médio. Alguns algoritmos de ordenação rápidos têm desempenhos
espectacularmente ruins no pior cenário, quer em tempo de execução, quer no uso da memória. O Heapsort
trabalha no lugar e o tempo de execução em pior cenário para ordenar n elementos é de O (n lg n). Para
valores de n, razoavelmente grande, o termo lg n é quase constante, de modo que o tempo de ordenação é
quase linear com o número de itens a ordenar.
Definition at line 367 of file SortingAlgorithms.h.
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
68. 6.14 HeapSort Class Reference
6.14.2
Constructor & Destructor Documentation
6.14.2.1
67
HeapSort::HeapSort () [inline]
Contructor
Definition at line 373 of file SortingAlgorithms.h.
00373 :AbstractSorting(){};
6.14.3
Member Function Documentation
6.14.3.1
void HeapSort::sort (ElementVector & ev) [virtual]
Método que executa a ordenação dos elementos.
O algoritmo heapsort é um algoritmo de ordenação generalista, e faz parte da família de algoritmos de
ordenação por seleção. Tem um desempenho em tempo de execução muito bom em conjuntos ordenados
aleatoriamente, tem um uso de memória bem comportado e o seu desempenho em pior cenário é praticamente igual ao desempenho em cenário médio. Alguns algoritmos de ordenação rápidos têm desempenhos
espectacularmente ruins no pior cenário, quer em tempo de execução, quer no uso da memória. O Heapsort
trabalha no lugar e o tempo de execução em pior cenário para ordenar n elementos é de O (n lg n). Para
valores de n, razoavelmente grande, o termo lg n é quase constante, de modo que o tempo de ordenação é
quase linear com o número de itens a ordenar.
Implements AbstractSorting.
Definition at line 393 of file SortingAlgorithms.cxx.
00394 {
00395
int i = ev.size()/2, n = ev.size(), pai, filho;
00396
Element t;
00397
00398
for (;;)
00399
{
00400
if (i > 0)
00401
{
00402
i--;
00403
t = ev[i];
00404
}
00405
else
00406
{
00407
n--;
00408
if (n == 0) return;
00409
t = ev[n];
00410
ev[n] = ev[0];
00411
}
00412
00413
pai = i;
00414
filho = i*2 + 1;
00415
00416
while (filho < n)
00417
{
00418
if ((filho + 1 < n) && (ev[filho + 1] > ev[filho]))
00419
{
00420
filho++;
00421
_numero_de_comparacoes++;
00422
}
00423
00424
if (ev[filho] > t)
00425
{
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
69. 68
Class Documentation
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
}
00442 }
ev[pai] = ev[filho];
pai = filho;
filho = pai*2 + 1;
_numero_de_comparacoes++;
_numero_de_trocas++;
}
else
break;
_numero_de_iteracoes++;
}
ev[pai] = t;
//_numero_de_trocas++;
_numero_de_iteracoes++;
Here is the call graph for this function:
HeapSort::sort
ElementVector::size
The documentation for this class was generated from the following files:
• SortingAlgorithms.h
• SortingAlgorithms.cxx
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
70. 6.15 InsertionSort Class Reference
6.15
69
InsertionSort Class Reference
#include <SortingAlgorithms.h>
Inheritance diagram for InsertionSort:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
InsertionSort
+ InsertionSort()
+ sort()
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
71. 70
Class Documentation
Collaboration diagram for InsertionSort:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
InsertionSort
+ InsertionSort()
+ sort()
Public Member Functions
• InsertionSort ()
• void sort (ElementVector &ev)
6.15.1
Detailed Description
Método da ordenação por inserção que também possui complexidade quadrática porém em média se comporta melhor que a ordenação pelo método bolha.
Definition at line 198 of file SortingAlgorithms.h.
6.15.2
Constructor & Destructor Documentation
6.15.2.1
InsertionSort::InsertionSort () [inline]
Contructor
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
72. 6.15 InsertionSort Class Reference
71
Definition at line 204 of file SortingAlgorithms.h.
00204 :AbstractSorting(){};
6.15.3
Member Function Documentation
6.15.3.1
void InsertionSort::sort (ElementVector & ev) [virtual]
Método que executa a ordenação dos elementos.
Método da ordenação por inserção que também possui complexidade quadrática porém em média se comporta melhor que a ordenação pelo método bolha.
Implements AbstractSorting.
Definition at line 107 of file SortingAlgorithms.cxx.
00108 {
00109
Element temp;
00110
int index;
00111
unsigned int j, size_vector = ev.size();
00112
00113
for(j = 1; j < size_vector; j++)
00114
{
00115
temp = ev[j];
00116
00117
//O algoritmo faz pelo menos uma comparação antes de entrar no looping e uma
00118
//iteração pois se as condições do cabeçalho condicional do próximo laço não
00119
//forem aceitas o looping[for] não será executado.
00120
_numero_de_iteracoes++;
00121
_numero_de_comparacoes++;
00122
00123
//O restante das comparações são feitas pelo cabeçalho condicional do laço
00124
for(index = j-1; index >= 0 && ev[index] > temp; index--)
00125
{
00126
ev[index + 1] = ev[index];
00127
_numero_de_iteracoes++;
00128
_numero_de_trocas++;
00129
_numero_de_comparacoes++;
00130
}
00131
00132
//Necessáriamente isso é apenas uma reatribuição quando a lista já se
00133
//encontra ordenada, por isso comentamos o incremento do número de trocas
00134
//_numero_de_trocas++;
00135
ev[index + 1] = temp;
00136
}
00137 }
Here is the call graph for this function:
InsertionSort::sort
ElementVector::size
The documentation for this class was generated from the following files:
• SortingAlgorithms.h
• SortingAlgorithms.cxx
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
73. 72
6.16
Class Documentation
InternalQuickSort Class Reference
#include <SortingAlgorithms.h>
Inheritance diagram for InternalQuickSort:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
InternalQuickSort
+ InternalQuickSort()
+ sort()
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
74. 6.16 InternalQuickSort Class Reference
73
Collaboration diagram for InternalQuickSort:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
InternalQuickSort
+ InternalQuickSort()
+ sort()
Public Member Functions
• InternalQuickSort ()
• void sort (ElementVector &ev)
6.16.1
Detailed Description
Método que utiliza o algoritmo quiscksort implementado pela STL. Por isso o número de comparações,
iterações e trocas não poderá ser fornecido com precisão
Definition at line 385 of file SortingAlgorithms.h.
6.16.2
Constructor & Destructor Documentation
6.16.2.1
InternalQuickSort::InternalQuickSort () [inline]
Contructor
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
75. 74
Class Documentation
Definition at line 391 of file SortingAlgorithms.h.
00391 :AbstractSorting(){};
6.16.3
Member Function Documentation
6.16.3.1
void InternalQuickSort::sort (ElementVector & ev) [virtual]
Método que executa a ordenação dos elementos.
Método que utiliza o algoritmo quiscksort implementado pela STL. Por isso o número de comparações,
iterações e trocas não poderá ser fornecido com precisão
Implements AbstractSorting.
Definition at line 448 of file SortingAlgorithms.cxx.
00449 {
00450
//Executa o método de ordenação fornecido pela STL baseado no quicksort
00451
ev.sort();
00452 }
Here is the call graph for this function:
InternalQuickSort::sort
ElementVector::sort
The documentation for this class was generated from the following files:
• SortingAlgorithms.h
• SortingAlgorithms.cxx
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
76. 6.17 LibraryTime Class Reference
6.17
75
LibraryTime Class Reference
#include <LibraryTime.h>
Public Member Functions
•
•
•
•
•
•
LibraryTime ()
void Start (void)
void Stop (void)
double Get (void)
void Delay (const int miliseconds)
virtual ∼LibraryTime ()
6.17.1
Detailed Description
Classe que executa verificação de tempo decorrido para realização de determinadas tarefas. Usada para
fazer análise de complexidade computacional em relação a quanto tempo um determinado trecho de código
consome para ser realizado. O retorno é dado em milisegundos com base no clock da máquina.
Definition at line 19 of file LibraryTime.h.
6.17.2
Constructor & Destructor Documentation
6.17.2.1
LibraryTime::LibraryTime () [inline]
Método construtor da classe.
Definition at line 35 of file LibraryTime.h.
00035 {};
6.17.2.2
virtual LibraryTime::∼LibraryTime () [inline, virtual]
Método destrutor da classe responsável por desalocar quaisquer recursos previamente alocados retornando
os mesmos ao sistema.
Definition at line 66 of file LibraryTime.h.
00066 {};
6.17.3
Member Function Documentation
6.17.3.1
void LibraryTime::Delay (const int miliseconds) [inline]
Método que imprime uma pausa em milisegundos na execução do fluxo do programa a partir do ponto onde
ela foi chamada.
Definition at line 59 of file LibraryTime.h.
00060
{ clock_t exit_time = clock() + miliseconds; while(clock() <= exit_time); }
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
77. 76
Class Documentation
6.17.3.2
double LibraryTime::Get (void) [inline]
Método responsável por retornar o intervalo em milisegundos decorrido entre as chamadas dos método
Start() e Stop()
Definition at line 53 of file LibraryTime.h.
00053 { return double( stop - start )/CLOCKS_PER_SEC; }
Here is the caller graph for this function:
LibraryTime::Get
6.17.3.3
MyApplication::OrdenaListaDeNumeros
void LibraryTime::Start (void) [inline]
Método responsável por capturar o tempo ou intervalo inicial de execução de alguma operação.
Definition at line 41 of file LibraryTime.h.
00041 { start = clock(); }
Here is the caller graph for this function:
LibraryTime::Start
6.17.3.4
MyApplication::OrdenaListaDeNumeros
void LibraryTime::Stop (void) [inline]
Método responsável por capturar o tempo ou intervalo de interrupção de execução de alguma operação.
Definition at line 47 of file LibraryTime.h.
00047 { stop
= clock(); }
Here is the caller graph for this function:
LibraryTime::Stop
MyApplication::OrdenaListaDeNumeros
The documentation for this class was generated from the following file:
• LibraryTime.h
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
78. 6.18 MergeSort Class Reference
6.18
77
MergeSort Class Reference
#include <SortingAlgorithms.h>
Inheritance diagram for MergeSort:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
MergeSort
+ MergeSort()
+ sort()
+ MergeMethod()
+ Merges()
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
79. 78
Class Documentation
Collaboration diagram for MergeSort:
AbstractSorting
# _numero_de_iteracoes
# _numero_de_trocas
# _numero_de_comparacoes
+ AbstractSorting()
+ InitializeVariables()
+ IterationsNumber()
+ InversionsNumber()
+ ComparisonsNumber()
+ sort()
+ ~AbstractSorting()
MergeSort
+ MergeSort()
+ sort()
+ MergeMethod()
+ Merges()
Public Member Functions
• MergeSort ()
• void sort (ElementVector &ev)
• void MergeMethod (ElementVector &ev, int BeginList, int EndList)
• void Merges (ElementVector &ev, int BeginList, int Middle, int EndList)
6.18.1
Detailed Description
Método de Ordenação Merge Sort
Definition at line 298 of file SortingAlgorithms.h.
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
80. 6.18 MergeSort Class Reference
79
6.18.2
Constructor & Destructor Documentation
6.18.2.1
MergeSort::MergeSort () [inline]
Contructor
Definition at line 304 of file SortingAlgorithms.h.
00304 :AbstractSorting(){};
6.18.3
Member Function Documentation
6.18.3.1
void MergeSort::MergeMethod (ElementVector & ev, int BeginList, int EndList)
Método merge sort, ou ordenação por intercalação, é um exemplo de algoritmo de ordenação do tipo
dividir-para-conquistar. Sua idéia básica é que é muito fácil criar uma sequência ordenada a partir de duas
outras também ordenadas. Para isso, ele divide a sequência original em pares de dados, ordena-as; depois
as agrupa em sequências de quatro elementos, e assim por diante, até ter toda a sequência dividida em
apenas duas partes. O método MergeSort rearranja o vetor v[BeginList..EndList-1] em ordem crescente.
Cuidado ao usar esse método, o final da lista compreende todo o seu tamanho, logo o mesmo deve ser
chamado da seguinte forma : MergeSort(MinhaLista, 0, MinhaLista.size())
Definition at line 282 of file SortingAlgorithms.cxx.
00283 {
00284
if (BeginList < EndList -1)
00285
{
00286
int middle = (BeginList + EndList)/2;
00287
MergeMethod(ev, BeginList, middle);
00288
MergeMethod(ev, middle, EndList);
00289
Merges(ev, BeginList, middle, EndList);
00290
}
00291 }
Here is the call graph for this function:
ElementVector::clear
MergeSort::MergeMethod
MergeSort::Merges
ElementVector::resize
Here is the caller graph for this function:
MergeSort::MergeMethod
6.18.3.2
MergeSort::sort
void MergeSort::Merges (ElementVector & ev, int BeginList, int Middle, int EndList)
Método auxiliar ao MergeSort que executa a intercalação das listas. O método recebe vetores crescentes
v[BeginList..Middle-1] e v[Middle..EndList-1] e rearranja v[BeginList..EndList-1] em ordem crescente.
Definition at line 298 of file SortingAlgorithms.cxx.
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
81. 80
Class Documentation
00299 {
00300
int i, j, k;
00301
ElementVector w;
00302
00303
//Executa um resize na lista de elementos alocando o necessário para a
00304
//intercalação dos elementos.
00305
w.resize(EndList - BeginList);
00306
00307
//Estabelecendo os limites para a intercalação
00308
i = BeginList; j = Middle; k = 0;
00309
00310
//Verifica quem deve ser intercalado
00311
while( i < Middle && j < EndList)
00312
{
00313
if (ev[i] <= ev[j]) w[k++] = ev[i++];
00314
else w[k++] = ev[j++];
00315
00316
//Executa analise de desempenho do algoritmo.
00317
_numero_de_comparacoes++;
00318
_numero_de_trocas++;
00319
_numero_de_iteracoes++;
00320
}
00321
00322
//Executa as intercalações finais.
00323
while(i < Middle) { w[k++] = ev[i++]; _numero_de_iteracoes++; }
00324
while(j < EndList) { w[k++] = ev[j++]; _numero_de_iteracoes++; }
00325
00326
//Copia o a lista auxiliar para a lista original
00327
for( i = BeginList; i < EndList; ++i)
00328
{ ev[i] = w[i-BeginList]; _numero_de_iteracoes++; }
00329
00330
//Limpa a lista auxiliar ...
00331
w.clear();
00332 }
Here is the call graph for this function:
ElementVector::clear
MergeSort::Merges
ElementVector::resize
Here is the caller graph for this function:
MergeSort::Merges
6.18.3.3
MergeSort::MergeMethod
MergeSort::sort
void MergeSort::sort (ElementVector & ev) [virtual]
Método que executa a ordenação dos elementos.
Implements AbstractSorting.
Definition at line 269 of file SortingAlgorithms.cxx.
00269 { MergeMethod(ev, 0, ev.size()); };
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
82. 6.18 MergeSort Class Reference
81
Here is the call graph for this function:
ElementVector::clear
MergeSort::MergeMethod
MergeSort::Merges
MergeSort::sort
ElementVector::resize
ElementVector::size
The documentation for this class was generated from the following files:
• SortingAlgorithms.h
• SortingAlgorithms.cxx
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
83. 82
6.19
Class Documentation
RNG::MersenneTwisterDouble Class Reference
#include <RandomNumberGenerator.h>
Inheritance diagram for RNG::MersenneTwisterDouble:
RNG::MersenneTwisterInt32
-n
-m
- state
-p
- init
+ MersenneTwisterInt32()
+ MersenneTwisterInt32()
+ MersenneTwisterInt32()
+ Seed()
+ Seed()
+ operator()()
+ ~MersenneTwisterInt32()
# rand_int32()
- twiddle()
- gen_state()
- MersenneTwisterInt32()
- operator=()
RNG::MersenneTwisterDouble
+ MersenneTwisterDouble()
+ MersenneTwisterDouble()
+ MersenneTwisterDouble()
+ operator()()
+ ~MersenneTwisterDouble()
- MersenneTwisterDouble()
- operator=()
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
84. 6.19 RNG::MersenneTwisterDouble Class Reference
83
Collaboration diagram for RNG::MersenneTwisterDouble:
RNG::MersenneTwisterInt32
-n
-m
- state
-p
- init
+ MersenneTwisterInt32()
+ MersenneTwisterInt32()
+ MersenneTwisterInt32()
+ Seed()
+ Seed()
+ operator()()
+ ~MersenneTwisterInt32()
# rand_int32()
- twiddle()
- gen_state()
- MersenneTwisterInt32()
- operator=()
RNG::MersenneTwisterDouble
+ MersenneTwisterDouble()
+ MersenneTwisterDouble()
+ MersenneTwisterDouble()
+ operator()()
+ ~MersenneTwisterDouble()
- MersenneTwisterDouble()
- operator=()
Public Member Functions
•
•
•
•
•
MersenneTwisterDouble ()
MersenneTwisterDouble (unsigned long seed)
MersenneTwisterDouble (const unsigned long ∗seed, int size)
double operator() ()
∼MersenneTwisterDouble ()
6.19.1
Detailed Description
Classe para geração de números pseudo-aleatórios que tem como principal algoritmo o ’Mersenne Twister
Pseudo-random Number Generator’ que possui periodicidade de 2∧ 19937-1. A classe abaixo retorna
números em ponto flutuante no intervalo semi-aberto [0,1).
Definition at line 203 of file RandomNumberGenerator.h.
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
85. 84
Class Documentation
6.19.2
Constructor & Destructor Documentation
6.19.2.1
RNG::MersenneTwisterDouble::MersenneTwisterDouble () [inline]
Método construtor da classe de geracao de numeros aleatorios
Definition at line 210 of file RandomNumberGenerator.h.
00210 : MersenneTwisterInt32() {};
6.19.2.2
RNG::MersenneTwisterDouble::MersenneTwisterDouble (unsigned long seed)
[inline]
Método construtor que recebe um chave de 32 bits como semente
Definition at line 215 of file RandomNumberGenerator.h.
00215 : MersenneTwisterInt32(seed) {};
6.19.2.3
RNG::MersenneTwisterDouble::MersenneTwisterDouble (const unsigned long ∗ seed, int
size) [inline]
Método construtor que recebe um array inteiro de 32 bits e o tamanho do array como semente de geração
de números
Definition at line 221 of file RandomNumberGenerator.h.
00222
: MersenneTwisterInt32(seed, size) {};
6.19.2.4
RNG::MersenneTwisterDouble::∼MersenneTwisterDouble () [inline]
Método destrutor da classe responsável por desalocar qualquer recurso previamente alocado retornando o
mesmo ao sistema .
Definition at line 235 of file RandomNumberGenerator.h.
00235 {};
6.19.3
Member Function Documentation
6.19.3.1
double RNG::MersenneTwisterDouble::operator() () [inline]
Overload do operador () fazendo com que o objeto criado tenha um aspecto de objeto-função.
Reimplemented from RNG::MersenneTwisterInt32.
Definition at line 228 of file RandomNumberGenerator.h.
00229
{ return static_cast<double>(rand_int32()) * (1. / 4294967296.); } // divisão p
or 2^32
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
86. 6.19 RNG::MersenneTwisterDouble Class Reference
85
Here is the call graph for this function:
RNG::MersenneTwisterDouble::operator()
RNG::MersenneTwisterInt32::rand_int32
The documentation for this class was generated from the following file:
• RandomNumberGenerator.h
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
87. 86
6.20
Class Documentation
RNG::MersenneTwisterDouble53 Class Reference
#include <RandomNumberGenerator.h>
Inheritance diagram for RNG::MersenneTwisterDouble53:
RNG::MersenneTwisterInt32
-n
-m
- state
-p
- init
+ MersenneTwisterInt32()
+ MersenneTwisterInt32()
+ MersenneTwisterInt32()
+ Seed()
+ Seed()
+ operator()()
+ ~MersenneTwisterInt32()
# rand_int32()
- twiddle()
- gen_state()
- MersenneTwisterInt32()
- operator=()
RNG::MersenneTwisterDouble53
+ MersenneTwisterDouble53()
+ MersenneTwisterDouble53()
+ MersenneTwisterDouble53()
+ operator()()
+ ~MersenneTwisterDouble53()
- MersenneTwisterDouble53()
- operator=()
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
88. 6.20 RNG::MersenneTwisterDouble53 Class Reference
87
Collaboration diagram for RNG::MersenneTwisterDouble53:
RNG::MersenneTwisterInt32
-n
-m
- state
-p
- init
+ MersenneTwisterInt32()
+ MersenneTwisterInt32()
+ MersenneTwisterInt32()
+ Seed()
+ Seed()
+ operator()()
+ ~MersenneTwisterInt32()
# rand_int32()
- twiddle()
- gen_state()
- MersenneTwisterInt32()
- operator=()
RNG::MersenneTwisterDouble53
+ MersenneTwisterDouble53()
+ MersenneTwisterDouble53()
+ MersenneTwisterDouble53()
+ operator()()
+ ~MersenneTwisterDouble53()
- MersenneTwisterDouble53()
- operator=()
Public Member Functions
•
•
•
•
•
MersenneTwisterDouble53 ()
MersenneTwisterDouble53 (unsigned long seed)
MersenneTwisterDouble53 (const unsigned long ∗seed, int size)
double operator() ()
∼MersenneTwisterDouble53 ()
6.20.1
Detailed Description
Classe para geração de números pseudo-aleatórios que tem como principal algoritmo o ’Mersenne Twister
Pseudo-random Number Generator’ que possui periodicidade de 2∧ 19937-1. A classe abaixo retorna
números em ponto flutuante com uma resolução de até 53 bits no intervalo semi-aberto [0,1) .
Definition at line 369 of file RandomNumberGenerator.h.
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
89. 88
Class Documentation
6.20.2
Constructor & Destructor Documentation
6.20.2.1
RNG::MersenneTwisterDouble53::MersenneTwisterDouble53 () [inline]
Método construtor da classe de geracao de numeros aleatorios
Definition at line 376 of file RandomNumberGenerator.h.
00376 : MersenneTwisterInt32() {};
6.20.2.2
RNG::MersenneTwisterDouble53::MersenneTwisterDouble53 (unsigned long seed)
[inline]
Método construtor que recebe uma chave de 32 bits como semente
Definition at line 381 of file RandomNumberGenerator.h.
00381 : MersenneTwisterInt32(seed) {};
6.20.2.3
RNG::MersenneTwisterDouble53::MersenneTwisterDouble53 (const unsigned long ∗
seed, int size) [inline]
Método construtor que recebe um array inteiro de 32 bits e o tamanho do array como semente de geração
de números
Definition at line 387 of file RandomNumberGenerator.h.
00388
: MersenneTwisterInt32(seed, size) {};
6.20.2.4
RNG::MersenneTwisterDouble53::∼MersenneTwisterDouble53 () [inline]
Método destrutor da classe responsável por desalocar qualquer recurso previamente alocado retornando o
mesmo ao sistema .
Definition at line 404 of file RandomNumberGenerator.h.
00404 {};
6.20.3
Member Function Documentation
6.20.3.1
double RNG::MersenneTwisterDouble53::operator() () [inline]
Overload do operador () fazendo com que o objeto criado tenha um aspecto de objeto-função.
Reimplemented from RNG::MersenneTwisterInt32.
Definition at line 394 of file RandomNumberGenerator.h.
00395
00396
00397
{
return (static_cast<double>(rand_int32() >> 5) * 67108864. +
static_cast<double>(rand_int32() >> 6)) * (1. / 9007199254740992.
);
00398
}
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
90. 6.20 RNG::MersenneTwisterDouble53 Class Reference
Here is the call graph for this function:
RNG::MersenneTwisterDouble53::operator()
RNG::MersenneTwisterInt32::rand_int32
The documentation for this class was generated from the following file:
• RandomNumberGenerator.h
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
89
91. 90
6.21
Class Documentation
RNG::MersenneTwisterDoubleClosed Class Reference
#include <RandomNumberGenerator.h>
Inheritance diagram for RNG::MersenneTwisterDoubleClosed:
RNG::MersenneTwisterInt32
-n
-m
- state
-p
- init
+ MersenneTwisterInt32()
+ MersenneTwisterInt32()
+ MersenneTwisterInt32()
+ Seed()
+ Seed()
+ operator()()
+ ~MersenneTwisterInt32()
# rand_int32()
- twiddle()
- gen_state()
- MersenneTwisterInt32()
- operator=()
RNG::MersenneTwisterDoubleClosed
+ MersenneTwisterDoubleClosed()
+ MersenneTwisterDoubleClosed()
+ MersenneTwisterDoubleClosed()
+ operator()()
+ ~MersenneTwisterDoubleClosed()
- MersenneTwisterDoubleClosed()
- operator=()
Generated on Sun Dec 4 16:17:54 2011 by Doxygen
92. 6.21 RNG::MersenneTwisterDoubleClosed Class Reference
91
Collaboration diagram for RNG::MersenneTwisterDoubleClosed:
RNG::MersenneTwisterInt32
-n
-m
- state
-p
- init
+ MersenneTwisterInt32()
+ MersenneTwisterInt32()
+ MersenneTwisterInt32()
+ Seed()
+ Seed()
+ operator()()
+ ~MersenneTwisterInt32()
# rand_int32()
- twiddle()
- gen_state()
- MersenneTwisterInt32()
- operator=()
RNG::MersenneTwisterDoubleClosed
+ MersenneTwisterDoubleClosed()
+ MersenneTwisterDoubleClosed()
+ MersenneTwisterDoubleClosed()
+ operator()()
+ ~MersenneTwisterDoubleClosed()
- MersenneTwisterDoubleClosed()
- operator=()
Public Member Functions
•
•
•
•
•
MersenneTwisterDoubleClosed ()
MersenneTwisterDoubleClosed (unsigned long seed)
MersenneTwisterDoubleClosed (const unsigned long ∗seed, int size)
double operator() ()
∼MersenneTwisterDoubleClosed ()
6.21.1
Detailed Description
Classe para geração de números pseudo-aleatórios que tem como principal algoritmo o ’Mersenne Twister
Pseudo-random Number Generator’ que possui periodicidade de 2∧ 19937-1. A classe abaixo retorna
números em ponto flutuante no intervalo fechado [0,1].
Definition at line 258 of file RandomNumberGenerator.h.
Generated on Sun Dec 4 16:17:54 2011 by Doxygen