libStatGen Software 1
QuickIndex.h
1/*
2 * Copyright (C) 2010 Regents of the University of Michigan
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __QUICKINDEX_H__
19#define __QUICKINDEX_H__
20
21#include "MathVector.h"
22#include "StringArray.h"
23#include "StringHash.h"
24#include "IntArray.h"
25#include "StringMap.h"
26
27class QuickIndex : public IntArray
28{
29public:
30 QuickIndex();
31 QuickIndex(const IntArray & source_data)
32 {
33 Index(source_data);
34 }
35 QuickIndex(const StringArray & source_data)
36 {
37 Index(source_data);
38 }
39 QuickIndex(const Vector & source_data)
40 {
41 Index(source_data);
42 }
43
44 void Index(const IntArray & source_data);
45 void Index(const StringArray & source_data);
46 void Index(const Vector & source_data);
47 void IndexCounts(const StringIntMap & source_data);
48 void IndexCounts(const StringIntHash & source_data);
49
50private:
51 const void * source;
52 int datatype;
53
54 bool IsBefore(int i, int j);
55 void Sort();
56};
57
58#endif
59