data structures - vector of list. Should I use pointers or values? -
i implementing data struct hash table collisions resolved using chains.
so underlying data structure need vector of lists.
choice 2 variants:
std::vector<std::list<entry> >
std::vector<std::list<entry>* >
where entry struct contains data , hash value;
question: huge decrease in efficiency if use first variant(question considered on large input data)?
thank in advance!
there's no advantage using pointer, , adds complication of needing deleted when destroy vector. go ahead , use vector<list<entry> >
. list
allocating memory elements anyway, invisible you.
there might performance penalty if vector has resized, c++11 compiler should use moves instead of copies minimize it. , learning project performance shouldn't first concern anyway.
Comments
Post a Comment