sampleSNPs  0.9
Fast ordered sampling of records from files
populations.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Anthony J. Greenberg
3  *
4  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5  *
6  * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7  *
8  * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9  *
10  * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11  *
12  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
13  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
14  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
15  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
16  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
17  * THE POSSIBILITY OF SUCH DAMAGE.
18  */
19 
21 
30 #ifndef populations_hpp
31 #define populations_hpp
32 
33 #include <vector>
34 #include <string>
35 
36 using std::vector;
37 using std::string;
38 
39 namespace sampFiles {
44  class PopIndex {
45 
46  private:
51  vector< vector<size_t> > _popInd;
56  size_t _N;
57 
58  public:
60  PopIndex() {};
68  PopIndex(const int *arr, const size_t &N);
75  PopIndex(const string &inFileName);
76 
77  ~PopIndex(){};
78 
86  vector<size_t> & operator[] (const size_t &i) { return _popInd[i]; };
94  const vector<size_t> & operator[] (const size_t &i) const { return _popInd[i]; };
95 
101  size_t popSize(const size_t &i) {return _popInd[i].size(); };
107  size_t popSize(const size_t &i) const {return _popInd[i].size(); };
108 
113  size_t size() {return _N; };
118  size_t size() const {return _N; };
119 
124  size_t popNumber() {return _popInd.size(); };
129  size_t popNumber() const {return _popInd.size(); };
130 
131  };
132 
133 }
134 
135 #endif /* populations_hpp */
Definition: populations.hpp:39
PopIndex()
Default constructor.
Definition: populations.hpp:60
size_t size() const
const total sample size
Definition: populations.hpp:118
vector< size_t > & operator[](const size_t &i)
Vector subscript operator.
Definition: populations.hpp:86
size_t popSize(const size_t &i)
Population size.
Definition: populations.hpp:101
size_t popNumber() const
const number of populations
Definition: populations.hpp:129
size_t size()
Total sample size.
Definition: populations.hpp:113
size_t popSize(const size_t &i) const
const population size
Definition: populations.hpp:107
Population index.
Definition: populations.hpp:44
size_t popNumber()
Number of populations.
Definition: populations.hpp:124