using union of vectors and arrays

Hi -

I'm trying to decide whether to create a union for convenience. A class I have contains several instances of an object, some of which are in vectors. It looks something like this:

1
2
3
4
5
6
private:
	vector<Cell>	regI;
	vector<Cell>	regQ;
	vector<Cell>	regPredI;
	vector<Cell>	regPredQ;
	Cell	regShared0, regShared1;


In my code, I'll need to process each Cell in this object. If I don't use a union, I'll need two "for" loops and two individual calls (I think). If I could union them with one array, I could just make one call.

So...is this possible? Is this a good idea? Am I trying to get too fancy?

I'm not doing anything with the vectors other than creating them, and referencing members with the "at" function.

Thanks for any feedback.
If I understood correctly, you have some functions that you apply to the various vectors. You are then thinking "hey, this feels like rework somehow, can I do this in one shot?". My answer is: Unless you have repeated cells in the vectors, I don't think it is repetitive work. I mean, it sure feels like it, but you have them separated for a reason.

In other words: If the contents of one vector is similar to another vector, then you could gain something by calculating the set union of the two before processing. Otherwise keep as is.
I'll need two "for" loops and two individual calls (I think). If I could union them with one array, I could just make one call.
Maybe you should read up on unions.

http://msdn.microsoft.com/en-us/library/5dxy4b7b%28v=vs.80%29.aspx
http://www.cplusplus.com/doc/tutorial/other_data_types/
Topic archived. No new replies allowed.