Skip to main content
17 events
when toggle format what by license comment
Apr 1, 2016 at 20:27 answer added Loki Astari timeline score: 1
Mar 31, 2016 at 19:18 history edited 200_success CC BY-SA 3.0
Reduced the task claimed to be accomplished, so as to make the question on-topic for Code Review
Mar 31, 2016 at 18:05 history edited 200_success CC BY-SA 3.0
deleted 41 characters in body; edited tags
Mar 31, 2016 at 17:33 answer added Edward timeline score: 3
Mar 31, 2016 at 16:28 history migrated from stackoverflow.com (revisions)
Mar 31, 2016 at 15:59 comment added Richard Hodges @LibertyPaul you can push and pop to both ends of a deque in constant time. Pushing to the back of a vector is amortized constant time (i.e. worse). Inserting at the front is linear time (i.e. much worse). I would say that a deque models a deck of cards extremely well.
Mar 31, 2016 at 15:54 comment added LibertyPaul @RichardHodges no, for user, std::deque looks like a random-access container (and it's not represent a real deck), just like vector. So there is totally no advance for using deque in this task.
Mar 31, 2016 at 15:46 comment added Richard Hodges @LibertyPaul because a deque is purpose-built for the job, but sure - a vector is fine too.
Mar 31, 2016 at 15:23 comment added LibertyPaul @RichardHodges std::vector has a pop_back, so why he should use deque?
Mar 31, 2016 at 15:21 answer added LibertyPaul timeline score: 1
Mar 31, 2016 at 15:18 comment added Richard Hodges @LibertyPaul the implementation of getCard becomes a pop_front. Since a std deque has random access iterators it can also be shuffled. The current implementation of getCard() can theoretically run forever after the first card has been drawn.
Mar 31, 2016 at 15:12 comment added LibertyPaul @RichardHodges And how do you think he can use internal realisation of std::deque for his purposes?
Mar 31, 2016 at 14:30 comment added Alexander Ekzhanov make an array with all the cards in, shuffle it, and then take the first N in order.
Mar 31, 2016 at 14:13 comment added Mehno You should learn more about the stl. You may just make a std::vector and remove every drawn card. array would be possible, too.
Mar 31, 2016 at 14:12 comment added Richard Hodges std::deque models... a deck of card
Mar 31, 2016 at 14:07 comment added VladimirS Reasonable approach would be to have all cards in one array, and rand on it. Then you take next available card (circular approach).
Mar 31, 2016 at 13:58 history asked Breindy CC BY-SA 3.0