double mu;
int t;
uint32_t state; // current state
vector<int16_t> drift; // current absolute drift
vector<uint32_t> past_inputs;
node2(int M, int L) : mu(0), state(0), drift(vector<int16_t>(M, 0)), t(0), past_inputs(vector<uint32_t>(L, 0)){ };
//node2(double m, uint32_t s, vector<int16_t> d, int ti, vector<uint32_t> pr_in): mu(m), state(s), drift(d), t(ti), past_inputs(pr_in) { }
~node2() { }
void get_path(vector<bool> *c_est, vector<bool> *u_est, conv_code *cc);
void copy_node(double mu, int t, uint32_t state, vector<int16_t>& drift, vector<uint32_t>& past_inputs) {
this->t = t;
this->mu = mu;
this->state = state;
std::copy(drift.begin(), drift.end(), this->drift.begin());
std::copy(past_inputs.begin(), past_inputs.begin() + t, this->past_inputs.begin());
}
I now have a function named 'insert_successors', wherein I have a set: 'std::set<node2, CompareSharedPtrNode> stack', where I keep a bunch of 'node2' objects sorted in descending order of their respective mu values.
Within this function, I have a loop, where in each iteration I remove the top element in the set named stack, and create new node2 objects and insert them into the stack.
I want to make the function more time-efficient, by not having to allocate fresh space each time I create a new node2 object, by using a pre-initialized vector. So instead of creating a new node2 object each time, I simply use one of the 'unused' entries in this vector. Maybe I use std::map to refer to these entries in the vector.