|
-
September 7th, 2012, 05:26 PM
#10
Re: Help reviewing C++ Test
 Originally Posted by D_Drmmr
I think this mostly relates to the sort function. If you use a linked list you can sort the items without moving/swapping the data.
I already thought about the sort feature a bit but omitted that from post #7 for brevity. I considered implementing the sort by using an std::vector<int> to map from the item indices as seen by the client code to the actual indices of the items in the pool array.
My primary concern about the semantics of Remove() and operator[]() was whether the exposed item indices were supposed to remain constant (like the item addresses), which would imply that removing items (except the last one) leads to invalid indices within the range fom 0 to Count() - 1 for which operator[]() probably should return nullptr or throw an exception. (And by the way that would make the semantics of Count() rather abstract.)
However, and that was something I failed to consider before reading your post, once sorting gets introduced, constant item indices can't be maintained anymore anyway, rendering the "invalid indices" approach pretty senseless. So, properly anticipating the effect of sorting, that approach obviously is not reasonable anyway.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|