public synchronized boolean containsKey(long key) { LongIntEntry tab[] = table; int index = hash(key) % tab.length; for (LongIntEntry e = tab[index]; e != null; e = e.next) { if (e.key == key) { return true; } } return false; }
public synchronized int put(long key, int value) { LongIntEntry tab[] = table; int _hash = hash(key); int index = _hash % tab.length; for (LongIntEntry e = tab[index]; e != null; e = e.next) { if (e.key == key) { int old = e.value; e.value = value; return old; } } if (count >= threshold) { rehash(); tab = table; index = _hash % tab.length; } LongIntEntry e = new LongIntEntry(key, value, tab[index]); tab[index] = e; count++; return NONE; }
public String toFormatString() { StringBuffer buf = new StringBuffer(); Enumeration it = entries(); buf.append("{\n"); while (it.hasMoreElements()) { LongIntEntry e = (LongIntEntry) it.nextElement(); buf.append("\t").append(e.getKey() + "=" + e.getValue()).append("\n"); } buf.append("}"); return buf.toString(); }
public synchronized int put(long key, int value) { LongIntEntry tab[] = table; int _hash = hash(key); int index = _hash % tab.length; for (LongIntEntry e = tab[index]; e != null; e = e.next) { if (e.key == key) { int old = e.value; e.value = value; return old; } } if (count >= threshold) { rehash(); tab = table; index = _hash % tab.length; } LongIntEntry e = new LongIntEntry(key, value, tab[index]); tab[index] = e; count++; return NONE; }
public String toFormatString() { StringBuffer buf = new StringBuffer(); Enumeration it = entries(); buf.append("{\n"); while (it.hasMoreElements()) { LongIntEntry e = (LongIntEntry) it.nextElement(); buf.append("\t").append(e.getKey() + "=" + e.getValue()).append("\n"); } buf.append("}"); return buf.toString(); }
public synchronized int get(long key) { LongIntEntry tab[] = table; int index = hash(key) % tab.length; for (LongIntEntry e = tab[index]; e != null; e = e.next) { if (e.key == key) { return e.value; } } return NONE; }
public synchronized int put(long key, int value) { LongIntEntry tab[] = table; int _hash = hash(key); int index = _hash % tab.length; for (LongIntEntry e = tab[index]; e != null; e = e.next) { if (e.key == key) { int old = e.value; e.value = value; return old; } } if (count >= threshold) { rehash(); tab = table; index = _hash % tab.length; } LongIntEntry e = new LongIntEntry(key, value, tab[index]); tab[index] = e; count++; return NONE; }
public String toFormatString() { StringBuffer buf = new StringBuffer(); Enumeration it = entries(); buf.append("{\n"); while (it.hasMoreElements()) { LongIntEntry e = (LongIntEntry) it.nextElement(); buf.append("\t").append(e.getKey() + "=" + e.getValue()).append("\n"); } buf.append("}"); return buf.toString(); }
public synchronized int get(long key) { LongIntEntry tab[] = table; int index = hash(key) % tab.length; for (LongIntEntry e = tab[index]; e != null; e = e.next) { if (e.key == key) { return e.value; } } return NONE; }
public synchronized int put(long key, int value) { LongIntEntry tab[] = table; int _hash = hash(key); int index = _hash % tab.length; for (LongIntEntry e = tab[index]; e != null; e = e.next) { if (e.key == key) { int old = e.value; e.value = value; return old; } } if (count >= threshold) { rehash(); tab = table; index = _hash % tab.length; } LongIntEntry e = new LongIntEntry(key, value, tab[index]); tab[index] = e; count++; return NONE; }