/** Tests if the key in the table. * @return <tt>true</tt> if the key is in the table */ public boolean containsKey( long key ) { return get(key) != null; }
/** Auto-boxing version of {@link #get(long)}. */ public TypeV get ( Object key ) { return (key instanceof Long) ? get (((Long)key).longValue()) : null; } /** Auto-boxing version of {@link #remove(long)}. */
private void writeObject(java.io.ObjectOutputStream s) throws IOException { s.defaultWriteObject(); // Write nothing for( long K : keySet() ) { final Object V = get(K); // Do an official 'get' s.writeLong (K); // Write the <long,TypeV> pair s.writeObject(V); } s.writeLong(NO_KEY); // Sentinel to indicate end-of-data s.writeObject(null); }
if (x < _gr) { get_ops++; String val = _hash.get(k); if (val != null && !val.equals(key)) throw new IllegalArgumentException("Mismatched key=" + key + " and val=" + val);
HM.put(i, KEYS[i]); for (int j = 0; j < i; j++) { if (HM.get(j) != KEYS[j]) { throw new Error("Broken table, put " + i + " but cannot find #" + j);
@Test public void testIterationBig2() { final int CNT = 10000; assertThat(_nbhml.size(), is(0)); final String v = "v"; for (int i = 0; i < CNT; i++) { _nbhml.put(i, v); String s = _nbhml.get(i); assertThat(s, is(v)); } assertThat(_nbhml.size(), is(CNT)); _nbhml.clear(); }
sum += x; assertTrue(x >= 0 && x <= (CNT - 1)); String v = _nbhml.get(x); assertThat("", v.charAt(0), is('v')); assertThat("", x, is(Long.parseLong(v.substring(1))));
assertThat(_nbhml.put(0, "v0"), nullValue()); assertEquals(_nbhml.replace(0, "v0a"), "v0"); assertEquals(_nbhml.get(0), "v0a"); assertThat(_nbhml.remove(0), is("v0a")); assertFalse(_nbhml.containsKey(0)); assertThat(_nbhml.put(1, "v1"), nullValue()); assertEquals(_nbhml.replace(1, "v1a"), "v1"); assertEquals(_nbhml.get(1), "v1a"); assertThat(_nbhml.remove(1), is("v1a")); assertFalse(_nbhml.containsKey(1)); map.get(33); // this causes a NPE
/** Tests if the key in the table. * @return <tt>true</tt> if the key is in the table */ public boolean containsKey( long key ) { return get(key) != null; }
/** Auto-boxing version of {@link #get(long)}. */ public TypeV get ( Object key ) { return (key instanceof Long) ? get (((Long)key).longValue()) : null; } /** Auto-boxing version of {@link #remove(long)}. */
private void writeObject(java.io.ObjectOutputStream s) throws IOException { s.defaultWriteObject(); // Write nothing for( long K : keySet() ) { final Object V = get(K); // Do an official 'get' s.writeLong (K); // Write the <long,TypeV> pair s.writeObject(V); } s.writeLong(NO_KEY); // Sentinel to indicate end-of-data s.writeObject(null); }