Exemplo n.º 1
0
  @SuppressWarnings("rawtypes")
  @Override
  public void clear() {
    while (queue.poll() != null) ;

    modCount++;
    Entry[] tab = table;
    for (int i = 0; i < tab.length; ++i) {
      tab[i] = null;
    }
    size = 0;
    while (queue.poll() != null) ;
  }
Exemplo n.º 2
0
  @SuppressWarnings("unchecked")
  private void expungeStaleEntries() {
    Entry<K, V> e;

    while ((e = (Entry<K, V>) queue.poll()) != null) {
      int h = e.hash;
      int i = indexFor(h, table.length);

      Entry<K, V> prev = table[i];
      Entry<K, V> p = prev;

      while (p != null) {
        Entry<K, V> next = p.next;
        if (p == e) {
          if (prev == e) {
            table[i] = next;
          } else {
            prev.next = next;
          }
          e.next = null;
          e.value = null;
          size--;
          break;
        }
        prev = p;
        p = next;
      }
    }
  }