1 #ifndef gamgee__variant_builder_multi_sample_vector__guard
2 #define gamgee__variant_builder_multi_sample_vector__guard
39 template<
class ELEMENT_TYPE>
54 m_multi_sample_values(num_samples * max_values_per_sample, end_of_vector_value),
55 m_num_samples{num_samples},
60 for (
auto sample_start = 0u; sample_start < m_multi_sample_values.size(); sample_start += m_max_values_per_sample ) {
61 m_multi_sample_values[sample_start] = missing_value;
85 inline void set_sample_value(
const uint32_t sample_index,
const uint32_t value_index,
const ELEMENT_TYPE value) {
86 assert(sample_index < m_num_samples);
87 assert(value_index < m_max_values_per_sample);
89 m_multi_sample_values[sample_index * m_max_values_per_sample + value_index] = value;
104 inline void set_sample_values(
const uint32_t sample_index,
const std::vector<ELEMENT_TYPE>& values) {
105 assert(sample_index < m_num_samples);
106 assert(values.size() <= m_max_values_per_sample);
108 const auto sample_start = sample_index * m_max_values_per_sample;
109 for (
auto value_index = 0u; value_index < values.size(); ++value_index ) {
110 m_multi_sample_values[sample_start + value_index] = values[value_index];
117 const std::vector<ELEMENT_TYPE>&
get_vector()
const {
return m_multi_sample_values; }
130 std::vector<ELEMENT_TYPE> m_multi_sample_values;
131 uint32_t m_num_samples;
132 uint32_t m_max_values_per_sample;
uint32_t num_samples() const
Return the number of samples whose values we are storing.
Definition: variant_builder_multi_sample_vector.h:122
~VariantBuilderMultiSampleVector()=default
void set_sample_value(const uint32_t sample_index, const uint32_t value_index, const ELEMENT_TYPE value)
Set a single value for one sample.
Definition: variant_builder_multi_sample_vector.h:85
uint32_t max_values_per_sample() const
Return the maximum number of values across all samples.
Definition: variant_builder_multi_sample_vector.h:127
VariantBuilderMultiSampleVector(const uint32_t num_samples, const uint32_t max_values_per_sample, const ELEMENT_TYPE missing_value, const ELEMENT_TYPE end_of_vector_value)
Construct a VariantBuilderMultiSampleVector.
Definition: variant_builder_multi_sample_vector.h:53
Class that allows you to efficiently prepare multi-sample data for setting individual fields in Varia...
Definition: variant_builder_multi_sample_vector.h:40
VariantBuilder: construct Variant records from scratch (and, coming soon, from existing Variant recor...
Definition: variant_builder.h:164
Definition: exceptions.h:9
const std::vector< ELEMENT_TYPE > & get_vector() const
Get a reference to the internal one-dimensional vector used for value storage.
Definition: variant_builder_multi_sample_vector.h:117
VariantBuilderMultiSampleVector & operator=(const VariantBuilderMultiSampleVector &other)=default
void set_sample_values(const uint32_t sample_index, const std::vector< ELEMENT_TYPE > &values)
Set all values for one sample at once.
Definition: variant_builder_multi_sample_vector.h:104