1 19 package gnu.trove; 20 21 34 35 abstract public class TPrimitiveHash extends THash { 36 38 protected transient byte[] _states; 39 40 41 42 43 protected static final byte FREE = 0; 44 45 46 protected static final byte FULL = 1; 47 48 50 protected static final byte REMOVED = 2; 51 52 56 public TPrimitiveHash() { 57 super(); 58 } 59 60 67 public TPrimitiveHash(int initialCapacity) { 68 this(initialCapacity, DEFAULT_LOAD_FACTOR); 69 } 70 71 80 public TPrimitiveHash(int initialCapacity, float loadFactor) { 81 super(); 82 _loadFactor = loadFactor; 83 setUp((int)Math.ceil(initialCapacity / loadFactor)); 84 } 85 86 public Object clone() { 87 TPrimitiveHash h = (TPrimitiveHash)super.clone(); 88 h._states = (byte[])this._states.clone(); 89 return h; 90 } 91 92 98 protected int capacity() { 99 return _states.length; 100 } 101 102 107 protected void removeAt(int index) { 108 _states[index] = REMOVED; 109 super.removeAt(index); 110 } 111 112 119 protected int setUp(int initialCapacity) { 120 int capacity; 121 122 capacity = super.setUp(initialCapacity); 123 _states = new byte[capacity]; 124 return capacity; 125 } 126 } | Popular Tags |