]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-52_1/main/tests/core/src/com/ibm/icu/dev/test/normalizer/LongHashtable.java
Upgrade ICU4J.
[Dictionary.git] / jars / icu4j-52_1 / main / tests / core / src / com / ibm / icu / dev / test / normalizer / LongHashtable.java
1 package com.ibm.icu.dev.test.normalizer;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 /**
7  *******************************************************************************
8  * Copyright (C) 2002-2010, International Business Machines Corporation and    *
9  * Unicode, Inc. All Rights Reserved.                                          *
10  *******************************************************************************
11  *
12  * Hashtable storing ints addressed by longs. Used
13  * for storing of composition data.
14  * @author Vladimir Weinstein
15  */
16 public class LongHashtable {
17
18     public LongHashtable (int defaultValue) {
19         this.defaultValue = defaultValue;
20     }
21
22     public void put(long key, int value) {
23         if (value == defaultValue) {
24             table.remove(new Long(key));
25         } else {
26             table.put(new Long(key), new Integer(value));
27         }
28     }
29
30     public int get(long key) {
31         Integer value = table.get(new Long(key));
32         if (value == null) return defaultValue;
33         return value.intValue();
34     }
35
36     private int defaultValue;
37     private Map<Long, Integer> table = new HashMap<Long, Integer>();
38
39 }