Use a HashMap if you do not need an order. HashMap faster.
However, you can easily switch using the common interface as an ad:
Map<String,String> M = new HashMap<String,String>(); ...use M lots of places...
Then all you have to do is switch one place, and your code uses a new type of card.
Edit:
Simple time test:
import java.util.*; class TimingTest { public static void main(String[] args) { Map<String,String> M = new HashMap<String,String>(); long start = System.currentTimeMillis(); for (int i = 0; i < 100000; i++) { M.put(Integer.toString(i), "foo"); } long end = System.currentTimeMillis(); System.out.println(end - start); } }
Keith randall
source share