3 ms·
I've been working on an application for a card game and I have been considering the implications of using a linked list for the deck structure. I just don't see
by b0b_d0e 13y ago
I've been working on an application for a card game and I have been considering the implications of using a linked list for the deck structure. I just don't see how using an array would make sense for a deck of cards. I need the ability to constantly grow and shrink the deck (this is for Yugioh so cards would get put back into the deck often). I did consider using an array but it seemed to be more trouble than its worth considering the need to remove cards from random locations in the deck. My question is then what kind of data structure is optimal for this then? Are arrays still the better choice or is there another data structure I don't know about that is optimal for card decks?
- mkilling 13y agoJust use linked lists. If it turns out to be a performance problem (my guess: it won't) you can change the data structure later.
- betterunix 13y agoFirst implement this using a linked list; then an array; and then, if you have some time, see if a random access list improves on performance: http://www.cl.cam.ac.uk/teaching/2004/IntroFuncProg/lecture08.html http://www.cl.cam.ac.uk/teaching/2004/IntroFuncProg/lecture0...
- VLM 13y ago"optimal for card decks" When n is human-typical card deck size, the optimal solution is whatever minimizes some balance of development time and debugging time. CPU and coding efficiency will never enter as a limitation. The absolute dirt simplest way to test your numerous card manipulation algorithms might be two arrays (or plain text files?) and your algos copy from one array into the other. In Yugioh isn't there some inherent (however ridiculously large) limit to the possible number of cards in a deck?