// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
package primitivemap;

import java.util.Map;

public class Test {
    private static int keyGen(int i) {
        return i * i + 13 * i + 19;
    }
    private static String valueGen(int i) {
        return "Test " + keyGen(i);
    }
    public static void main(String[] args) {
        Map<Integer,String> m = new PrimitiveMap<>(100);
        for(int j = 0; j < 10; j++) {
            for(int i = 0; i < 50; i++) {
                m.put(keyGen(i), valueGen(i));
                if(m.size() != (i + 1)) {
                    System.out.println("Problem with size after put " + (i + 1));
                }
            }
            for(int i = 0; i < 50; i++) {
                if(!m.get(keyGen(i)).equals(valueGen(i))) {
                    System.out.println("Problem with key " + keyGen(i));
                }
            }
            for(int i = 50; i < 100; i++) {
                if(m.containsKey(keyGen(i))) {
                    System.out.println("Problem with key " + keyGen(i));
                }
            }
            for(int i = 25; i < 50; i++) {
                if(!m.remove(keyGen(i)).equals(valueGen(i))) {
                    System.out.println("Problem with key " + keyGen(i));
                }
                if(m.size() != (74 - i)) {
                    System.out.println("Problem with size after remove " + (i + 1));
                }
            }
            m.clear();
        }
    }
}
