Commit eb1e64ef by Bryce McKinlay Committed by Bryce McKinlay

Hashtable.java (internalContainsValue): Removed.

	* java/util/Hashtable.java (internalContainsValue): Removed.
	(containsValue): Don't delegate to internalContainsValue.

From-SVN: r74399
parent 63cf211a
2002-12-08 Bryce McKinlay <bryce@mckinlay.net.nz>
* java/util/Hashtable.java (internalContainsValue): Removed.
(containsValue): Don't delegate to internalContainsValue.
2003-12-06 Michael Koch <konqueror@gmx.de> 2003-12-06 Michael Koch <konqueror@gmx.de>
* javax/naming/directory/Attribute.java, * javax/naming/directory/Attribute.java,
......
...@@ -333,11 +333,22 @@ public class Hashtable extends Dictionary ...@@ -333,11 +333,22 @@ public class Hashtable extends Dictionary
*/ */
public synchronized boolean contains(Object value) public synchronized boolean contains(Object value)
{ {
/* delegate to non-overridable worker method for (int i = buckets.length - 1; i >= 0; i--)
* to avoid blowing up the stack, when called {
* from overridden contains[Value]() method. HashEntry e = buckets[i];
*/ while (e != null)
return internalContainsValue(value); {
if (value.equals(e.value))
return true;
e = e.next;
}
}
// Must throw on null argument even if the table is empty
if (value == null)
throw new NullPointerException();
return false;
} }
/** /**
...@@ -354,44 +365,12 @@ public class Hashtable extends Dictionary ...@@ -354,44 +365,12 @@ public class Hashtable extends Dictionary
*/ */
public boolean containsValue(Object value) public boolean containsValue(Object value)
{ {
/* delegate to older method to make sure code overwriting it // Delegate to older method to make sure code overriding it continues
* continues to work. // to work.
*/
return contains(value); return contains(value);
} }
/** /**
* Returns true if this Hashtable contains a value <code>o</code>, such that
* <code>o.equals(value)</code>. This is an internal worker method
* called by <code>contains()</code> and <code>containsValue()</code>.
*
* @param value the value to search for in this Hashtable
* @return true if at least one key maps to the value
* @see #contains(Object)
* @see #containsKey(Object)
* @throws NullPointerException if <code>value</code> is null
*/
private boolean internalContainsValue(Object value)
{
for (int i = buckets.length - 1; i >= 0; i--)
{
HashEntry e = buckets[i];
while (e != null)
{
if (value.equals(e.value))
return true;
e = e.next;
}
}
// Must throw on null argument even if the table is empty
if (value == null)
throw new NullPointerException();
return false;
}
/**
* Returns true if the supplied object <code>equals()</code> a key * Returns true if the supplied object <code>equals()</code> a key
* in this Hashtable. * in this Hashtable.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment