summaryrefslogtreecommitdiff
path: root/read_helper.h
diff options
context:
space:
mode:
Diffstat (limited to 'read_helper.h')
-rw-r--r--read_helper.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/read_helper.h b/read_helper.h
index 2e87b0b..d19834a 100644
--- a/read_helper.h
+++ b/read_helper.h
@@ -46,10 +46,6 @@ public:
key_type minValue() const { return min_value; }
std::vector<key_type> population_vector;
- void finish_read() {
- this->population_vector.push_back(this->max_value);
- this->population_vector.push_back(this->min_value);
- }
static unsigned long randomRow(unsigned long max_value_) {
std::random_device randomDevice;
@@ -92,15 +88,16 @@ public:
read_number++;
fclose(file);
P_ERR("\r");
- finish_read();
}
void split_into(std::vector<key_type> &sample, std::vector<key_type> &p) {
- sample.resize(sample_length);
+ sample.resize(sample_length - 2);
p.resize(needed_read_length - sample_length);
// printf("%zu\n", needed_read_length - sample_length);
memcpy(sample.data(), population_vector.data(),
- sizeof(key_type) * sample_length);
+ sizeof(key_type) * (sample_length - 2));
+ sample.push_back(this->max_value);
+ sample.push_back(this->min_value);
memcpy(p.data(), population_vector.data() + sample_length,
sizeof(key_type) * (needed_read_length - sample_length));
}
@@ -108,7 +105,10 @@ public:
void split_into(key_type *&sample, key_type *&p) {
sample = new key_type[sample_length];
p = new key_type[needed_read_length - sample_length];
- memcpy(sample, population_vector.data(), sizeof(key_type) * sample_length);
+ memcpy(sample, population_vector.data(),
+ sizeof(key_type) * (sample_length - 2));
+ sample[sample_length - 2] = this->max_value;
+ sample[sample_length - 1] = this->min_value;
memcpy(p, population_vector.data() + sample_length,
sizeof(key_type) * (needed_read_length - sample_length));
}