| 395 | /// |
| 396 | /// a set of the mappings. |
| 397 | public Set<Map.Entry<K, V>> entrySet() { |
| 398 | return new Collections.SynchronizedSet<Map.Entry<K, V>>( |
| 399 | new AbstractSet<Map.Entry<K, V>>() { |
| 400 | @Override |
| 401 | public int size() { |
| 402 | return elementCount; |
| 403 | } |
| 404 | |
| 405 | @Override |
| 406 | public void clear() { |
| 407 | Hashtable.this.clear(); |
| 408 | } |
| 409 | |
| 410 | @Override |
| 411 | @SuppressWarnings("unchecked") |
| 412 | public boolean remove(Object object) { |
| 413 | if (contains(object)) { |
| 414 | Hashtable.this.remove(((Map.Entry<K, V>) object) |
| 415 | .getKey()); |
| 416 | return true; |
| 417 | } |
| 418 | return false; |
| 419 | } |
| 420 | |
| 421 | @Override |
| 422 | @SuppressWarnings("unchecked") |
| 423 | public boolean contains(Object object) { |
| 424 | Entry<K, V> entry = getEntry(((Map.Entry<K, V>) object) |
| 425 | .getKey()); |
| 426 | return object.equals(entry); |
| 427 | } |
| 428 | |
| 429 | @Override |
| 430 | public Iterator<Map.Entry<K, V>> iterator() { |
| 431 | return new HashIterator<Map.Entry<K, V>>( |
| 432 | new MapEntry.Type<Map.Entry<K, V>, K, V>() { |
| 433 | public Map.Entry<K, V> get( |
| 434 | MapEntry<K, V> entry) { |
| 435 | return entry; |
| 436 | } |
| 437 | }); |
| 438 | } |
| 439 | }, this); |
| 440 | } |
| 441 | |
| 442 | /// Compares this `Hashtable` with the specified object and indicates |
| 443 | /// if they are equal. In order to be equal, `object` must be an |