From 731db6c8bba87bfa70911cbae3bc3bdcbf7d7eb4 Mon Sep 17 00:00:00 2001 From: melvin Date: Thu, 16 Jun 2011 12:14:23 +0800 Subject: [PATCH] switch from using multiplicative hashing function to Murmur3 --- src/magic/model/MagicCardList.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/magic/model/MagicCardList.java b/src/magic/model/MagicCardList.java index a60c9867e6..63038066b9 100644 --- a/src/magic/model/MagicCardList.java +++ b/src/magic/model/MagicCardList.java @@ -23,11 +23,13 @@ public class MagicCardList extends ArrayList { } public long getCardsId() { - long id = 0; + int idx = 0; + long[] keys = new long[size() + 1]; for (final MagicCard card : this) { - id = id * 31 + card.getCardDefinition().getIndex(); + keys[idx] = card.getCardDefinition().getIndex(); + idx++; } - return id; + return magic.MurmurHash3.hash(keys); } public void addToBottom(final MagicCard card) {