Skip to main content
gamedev.net
🔒 Locked

[java] shuffling a stack

Started by himifire 1 reply 300+ views
Original Post
himifire
himifire
like the subject said im looking for an easy way to shuffle the items inside a stack. I dont know if theres a java class that can do it so excuse me if this is a stupid question, im only a novice =( code or a link would be very helpful. thx in advance. himifire
___________ DADDY LONG LEGZ HERE! novice java programmer :-)feel free to email me or my SN for AIM is JHHIM
ManiacMac
ManiacMac
Im not sure if it would work, but here goes. You take a stack, get its size, then pick a random number from that size, grab the object at that number, add it to a new stack, and remove it from the old one. Then just go until the old stack is empty. It should mix it up a bit.

[edited by - ManiacMac on January 2, 2004 1:44:51 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.