|
-
November 25th, 2009, 03:44 AM
#16
Re: My new GoFish thread.
 Originally Posted by laserlight
It might be an oversight in the standard, but it might also be because we're talking about linear time complexity degrading to quadratic time complexity, if my analysis is correct. Consequently, it might be "dangerous" to allow it to work with mere forward iterators, since it would likely be considerably better to shuffle an auxiliary container with random access.
Speaking of containers with random access... exiledgolem, I am guessing that you chose std::list over std::vector because you want to pop/push front/back, and generally did not need the random access. However, perhaps you should consider std:  eque, which would allow you to pop/push front/back in constant time, and also provides random access. Unfortunately, it is not suitable if you need to store, in other objects, iterators to the elements of that container, since std:  eque iterators can be invalidated on any insertion or deletion from the std:  eque.
Could be, could be. I always thought the philosophy behind the std was "we give you the best tools we can, but it is your responsability to use them right".
To get back to OP, though, why do you need to popFront? Your cardStack (I'm avoiding the word deque) can only be read from one "tip" right? Why don't you just use back() and pop_back()? That would solve a bunch of your problems. Also, you will be able to use a vector, and random_suffle.
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
|