NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
sorter.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2019 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#include <string>
20#include "../structures.hpp"
21
22#ifndef SORTER_HPP
23#define SORTER_HPP
24
30class Sorter
31{
32 private:
33 // Quicksort implementation
34 bool qSortImplementation(int* nIndex, int nElements, int nColumn, long long int nLeft, long long int nRight, int nSign);
35
36 protected:
37 // Comparision functions (have to be implemented in any derived class)
38 virtual int compare(int i, int j, int col) = 0; // -1 if i < j, 0 for i == j and +1 for j > 0
39 virtual bool isValue(int line, int col) = 0;
40
41 public:
42 virtual ~Sorter() {};
43
44 // Quicksort interface function
45 bool qSort(int* nIndex, int nElements, int nColumn, long long int nLeft, long long int nRight, int nSign);
46
47 // Function for hierarchical sorting
48 bool sortSubList(int* nIndex, int nElements, ColumnKeys* KeyList, long long int i1, long long int i2, long long int j1, int nSign, long long int nColumns);
49
50 // Function for preparing the ColumnKeys object based upon the passed string
51 ColumnKeys* evaluateKeyList(std::string& sKeyList, long long int nColumnCount);
52
53};
54
55
56#endif // SORTER_HPP
57
Abstract parent class to implement the sorting functionality (using Quicksort) on a more generic leve...
Definition: sorter.hpp:31
ColumnKeys * evaluateKeyList(std::string &sKeyList, long long int nColumnCount)
This public member function creates a ColumnKeys object from a string containing the hierarchical sor...
Definition: sorter.cpp:252
virtual ~Sorter()
Definition: sorter.hpp:42
bool qSort(int *nIndex, int nElements, int nColumn, long long int nLeft, long long int nRight, int nSign)
This public member function is the interface to the quicksort algorithm, which itself is implemented ...
Definition: sorter.cpp:40
bool qSortImplementation(int *nIndex, int nElements, int nColumn, long long int nLeft, long long int nRight, int nSign)
This private member function is the actual implementation of the quicksort algorithm.
Definition: sorter.cpp:93
virtual bool isValue(int line, int col)=0
virtual int compare(int i, int j, int col)=0
bool sortSubList(int *nIndex, int nElements, ColumnKeys *KeyList, long long int i1, long long int i2, long long int j1, int nSign, long long int nColumns)
This public member function handles the hierarchical sorting process of many columns together....
Definition: sorter.cpp:196
Structure for the sorting functionality: used for the recursive definition of the index columns for s...