示例#1
0
  /**
   * Tests if some key maps into the specified value in this hashtable. This operation is more
   * expensive than the <code>containsKey</code> method.
   *
   * <p>Note that this method is identical in functionality to containsValue, (which is part of the
   * Map interface in the collections framework).
   *
   * @param value a value to search for.
   * @return <code>true</code> if and only if some key maps to the <code>value</code> argument in
   *     this hashtable as determined by the <tt>equals</tt> method; <code>false</code> otherwise.
   * @throws NullPointerException if the value is <code>null</code>.
   * @see #containsKey(int)
   * @see #containsValue(Object)
   * @see java.util.Map
   */
  public boolean contains(Object value) {
    if (value == null) {
      I18nManager intl_mgr = I18nManager.getManager();

      String msg = intl_mgr.getString(NO_VALUE_ERR_PROP);
      throw new NullPointerException(msg);
    }

    Entry[] tab = table;
    for (int i = tab.length; i-- > 0; ) {
      for (Entry e = tab[i]; e != null; e = e.next) {
        if (e.value.equals(value)) return true;
      }
    }
    return false;
  }