MCPcopy
hub / github.com/careercup/ctci / shuffle

Method shuffle

java/Chapter 8/Question8_1/Deck.java:18–26  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16 }
17
18 public void shuffle() {
19 for (int i = 0; i < cards.size(); i++) {
20 int j = AssortedMethods.randomIntInRange(i, cards.size() - i - 1);
21 T card1 = cards.get(i);
22 T card2 = cards.get(j);
23 cards.set(i, card2);
24 cards.set(j, card1);
25 }
26 }
27
28 public int remainingCards() {
29 return cards.size() - dealtIndex;

Callers 1

initializeDeckMethod · 0.45

Calls 4

randomIntInRangeMethod · 0.95
sizeMethod · 0.45
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected