Home | History | Annotate | Download | only in normalizer
      1 //  2016 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html#License
      3 package com.ibm.icu.dev.test.normalizer;
      4 
      5 import java.util.HashMap;
      6 import java.util.Map;
      7 
      8 
      9 /**
     10  *******************************************************************************
     11  * Copyright (C) 1998-2010, International Business Machines Corporation and    *
     12  * Unicode, Inc. All Rights Reserved.                                          *
     13  *******************************************************************************
     14  *
     15  * Integer hash table.
     16  * @author Mark Davis
     17  */
     18 
     19 public class IntHashtable {
     20 
     21     public IntHashtable (int defaultValue) {
     22         this.defaultValue = defaultValue;
     23     }
     24 
     25     public void put(int key, int value) {
     26         if (value == defaultValue) {
     27             table.remove(new Integer(key));
     28         } else {
     29             table.put(new Integer(key), new Integer(value));
     30         }
     31     }
     32 
     33     public int get(int key) {
     34         Integer value = table.get(new Integer(key));
     35         if (value == null) return defaultValue;
     36         return value.intValue();
     37     }
     38 
     39     private int defaultValue;
     40     private Map<Integer, Integer> table = new HashMap<Integer, Integer>();
     41 }