/** * Returns a shallow copy of this <code>IntHashMap</code> instance: the keys and * values themselves are not cloned. * * @return a shallow copy of this map. */ @Override public IntHashMap clone() { try { IntHashMap t = (IntHashMap) super.clone(); t.table = new Entry[table.length]; for (int i = table.length; i-- > 0; ) { t.table[i] = (table[i] != null) ? (Entry) table[i].clone() : null; } t.keySet = null; t.entrySet = null; t.values = null; t.modCount = 0; return t; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } }
@Override public boolean remove(final Object o) { if (!(o instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) o; Object key = entry.getKey(); Entry[] tab = table; int hash = (key == null ? 0 : key.hashCode()); int index = (hash & 0x7FFFFFFF) % tab.length; for (Entry e = tab[index], prev = null; e != null; prev = e, e = e.next) { if (e.key == hash && e.equals(entry)) { modCount++; if (prev != null) { prev.next = e.next; } else { tab[index] = e.next; } count--; e.value = null; return true; } } return false; }
@Override public Object next() { if (modCount != expectedModCount) { throw new ConcurrentModificationException(); } while (entry == null && index > 0) { entry = _table[--index]; } if (entry != null) { Entry e = lastReturned = entry; entry = e.next; return type == KEYS ? e.getKey() : (type == VALUES ? e.value : e); } throw new NoSuchElementException(); }
tab[index] = new Entry(key, value, tab[index]); count++; return null;
tab[index] = new Entry(key, value, tab[index]); count++; return null;
@Override public boolean remove(Object o) { if (!(o instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) o; Object key = entry.getKey(); Entry tab[] = table; int hash = (key == null ? 0 : key.hashCode()); int index = (hash & 0x7FFFFFFF) % tab.length; for (Entry e = tab[index], prev = null; e != null; prev = e, e = e.next) { if (e.key == hash && e.equals(entry)) { modCount++; if (prev != null) { prev.next = e.next; } else { tab[index] = e.next; } count--; e.value = null; return true; } } return false; }
/** * Returns a shallow copy of this <code>IntHashMap</code> instance: the keys and * values themselves are not cloned. * * @return a shallow copy of this map. */ @Override public IntHashMap clone() { try { IntHashMap t = (IntHashMap) super.clone(); t.table = new Entry[table.length]; for (int i = table.length; i-- > 0; ) { t.table[i] = (table[i] != null) ? (Entry) table[i].clone() : null; } t.keySet = null; t.entrySet = null; t.values = null; t.modCount = 0; return t; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } }
/** * Returns a shallow copy of this <code>IntHashMap</code> instance: the keys and * values themselves are not cloned. * * @return a shallow copy of this map. */ @Override public IntHashMap clone() { try { IntHashMap t = (IntHashMap) super.clone(); t.table = new Entry[table.length]; for (int i = table.length; i-- > 0; ) { t.table[i] = (table[i] != null) ? (Entry) table[i].clone() : null; } t.keySet = null; t.entrySet = null; t.values = null; t.modCount = 0; return t; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } }
@Override public boolean remove(final Object o) { if (!(o instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) o; Object key = entry.getKey(); Entry[] tab = table; int hash = (key == null ? 0 : key.hashCode()); int index = (hash & 0x7FFFFFFF) % tab.length; for (Entry e = tab[index], prev = null; e != null; prev = e, e = e.next) { if (e.key == hash && e.equals(entry)) { modCount++; if (prev != null) { prev.next = e.next; } else { tab[index] = e.next; } count--; e.value = null; return true; } } return false; }
@Override public boolean contains(Object o) { if (!(o instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) o; Object key = entry.getKey(); Entry tab[] = table; int hash = (key == null ? 0 : key.hashCode()); int index = (hash & 0x7FFFFFFF) % tab.length; for (Entry e = tab[index]; e != null; e = e.next) { if (e.key == hash && e.equals(entry)) { return true; } } return false; }
@Override public boolean contains(final Object o) { if (!(o instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) o; Object key = entry.getKey(); Entry[] tab = table; int hash = (key == null ? 0 : key.hashCode()); int index = (hash & 0x7FFFFFFF) % tab.length; for (Entry e = tab[index]; e != null; e = e.next) { if (e.key == hash && e.equals(entry)) { return true; } } return false; }
public Object next() { if (modCount != expectedModCount) { throw new ConcurrentModificationException(); } while (entry == null && index > 0) { entry = _table[--index]; } if (entry != null) { Entry e = lastReturned = entry; entry = e.next; return type == KEYS ? e.getKey() : (type == VALUES ? e.value : e); } throw new NoSuchElementException(); }
@Override public Object next() { if (modCount != expectedModCount) { throw new ConcurrentModificationException(); } while (entry == null && index > 0) { entry = _table[--index]; } if (entry != null) { Entry e = lastReturned = entry; entry = e.next; return type == KEYS ? e.getKey() : (type == VALUES ? e.value : e); } throw new NoSuchElementException(); }
@Override public boolean equals(final Object o) { if (this.getClass() != o.getClass()) { return false; } Map.Entry e = (Map.Entry) o; return (getKey().equals(e.getKey())) && (value == null ? e.getValue() == null : value.equals(e.getValue())); }
@Override public boolean equals(Object o) { if (!(o instanceof Map.Entry)) { return false; } Map.Entry e = (Map.Entry) o; return (getKey().equals(e.getKey())) && (value == null ? e.getValue() == null : value.equals(e.getValue())); }
tab[index] = new Entry(key, value, tab[index]); count++; return null;
tab[index] = new Entry(key, value, tab[index]); count++; return null;
@Override public boolean contains(final Object o) { if (!(o instanceof Map.Entry)) { return false; } Map.Entry entry = (Map.Entry) o; Object key = entry.getKey(); Entry[] tab = table; int hash = (key == null ? 0 : key.hashCode()); int index = (hash & 0x7FFFFFFF) % tab.length; for (Entry e = tab[index]; e != null; e = e.next) { if (e.key == hash && e.equals(entry)) { return true; } } return false; }