Too many iterators?

I've made a habit out of using iterators as much as possible, and use them wherever I am looping over vectors. However, sometimes that means I end up with code like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// iterate through elements of order S for the host and source neurons
auto iS_source = synapse_source->begin(), N_src_iS_source = N_src.synapse_source->begin();
auto iS_weight = synapse_weight->begin(), N_src_iS_weight = N_src.synapse_weight->begin();
auto iS_source_var = synapse_source_var->begin(), N_src_iS_source_var = N_src.synapse_source_var->begin();
auto synapse_weight_var->begin(), N_src_iS_weight_var = N_src.synapse_weight_var->begin();

for (auto lim_iS_source = synapse_source->end(); 
	iS_source != lim_iS_source; 
	iS_source++, 
	iS_weight++, 
	iS_source_var++, 
	iS_weight_var++, 
	N_src_iS_source++, 
	N_src_iS_weight++, 
	N_src_iS_source_var++, 
	N_src_iS_weight_var++)
{
	// Variances of order S
	*iS_weight_var = *N_src_iS_weight_var * exp(rand_synapse_weight * tau_dash_S + tau_S * pB->pC->rand_gauss());

	*iS_source_var = *N_src_iS_source_var * exp(rand_synapse_link * tau_dash_S + tau_S * pB->pC->rand_gauss());

	// Elements of order S
	*iS_weight = (*N_src_iS_weight) + (*iS_weight_var) * pB->pC->rand_gauss();

	// special integer-rounded case of synapse source
	double synapse_source_double = double(*N_src_iS_source) + *iS_source_var * pB->pC->rand_gauss();
	size_t synapse_source_max = j - 1;
	(*iS_source) = round_to_size_t_max(synapse_source_double, j - 1);
}


Is this overdoing it? Is this still good practice from an efficiency point of view?
IMO, that is a bit excessive.

As for from an efficiency point of view -- I don't think iterators are any more/less efficient than using indexes (at least not with vectors), so it really comes down to a clarity/simplicity issue, rather than an efficiency issue.
Topic archived. No new replies allowed.