Returns a set of the mappings contained in this Hashtable. Each element in the set is a Map.Entry. The set is backed by this Hashtable so changes to one are reflected by the other. The set does not support adding. @return a set of the mappings.
()
| 417 | * @return a set of the mappings. |
| 418 | */ |
| 419 | public Set<Map.Entry<K, V>> entrySet() { |
| 420 | return new Collections.SynchronizedSet<Map.Entry<K, V>>( |
| 421 | new AbstractSet<Map.Entry<K, V>>() { |
| 422 | @Override |
| 423 | public int size() { |
| 424 | return elementCount; |
| 425 | } |
| 426 | |
| 427 | @Override |
| 428 | public void clear() { |
| 429 | Hashtable.this.clear(); |
| 430 | } |
| 431 | |
| 432 | @Override |
| 433 | @SuppressWarnings("unchecked") |
| 434 | public boolean remove(Object object) { |
| 435 | if (contains(object)) { |
| 436 | Hashtable.this.remove(((Map.Entry<K, V>) object) |
| 437 | .getKey()); |
| 438 | return true; |
| 439 | } |
| 440 | return false; |
| 441 | } |
| 442 | |
| 443 | @Override |
| 444 | @SuppressWarnings("unchecked") |
| 445 | public boolean contains(Object object) { |
| 446 | Entry<K, V> entry = getEntry(((Map.Entry<K, V>) object) |
| 447 | .getKey()); |
| 448 | return object.equals(entry); |
| 449 | } |
| 450 | |
| 451 | @Override |
| 452 | public Iterator<Map.Entry<K, V>> iterator() { |
| 453 | return new HashIterator<Map.Entry<K, V>>( |
| 454 | new MapEntry.Type<Map.Entry<K, V>, K, V>() { |
| 455 | public Map.Entry<K, V> get( |
| 456 | MapEntry<K, V> entry) { |
| 457 | return entry; |
| 458 | } |
| 459 | }); |
| 460 | } |
| 461 | }, this); |
| 462 | } |
| 463 | |
| 464 | /** |
| 465 | * Compares this {@code Hashtable} with the specified object and indicates |