|
14 | 14 | import java.util.Iterator; |
15 | 15 | import java.util.List; |
16 | 16 | import java.util.Map; |
17 | | -import java.util.NoSuchElementException; |
18 | 17 | import java.util.Set; |
19 | 18 | import java.util.SortedMap; |
20 | 19 | import java.util.TreeMap; |
@@ -169,13 +168,13 @@ public int getNumOverflowEntries() { |
169 | 168 | /** @return An iterable over the overflow entries. */ |
170 | 169 | public Iterable<Map.Entry<K, V>> getOverflowEntries() { |
171 | 170 | return overflowEntries.isEmpty() |
172 | | - ? EmptySet.<Map.Entry<K, V>>iterable() |
| 171 | + ? Collections.emptySet() |
173 | 172 | : overflowEntries.entrySet(); |
174 | 173 | } |
175 | 174 |
|
176 | 175 | Iterable<Map.Entry<K, V>> getOverflowEntriesDescending() { |
177 | 176 | return overflowEntriesDescending.isEmpty() |
178 | | - ? EmptySet.<Map.Entry<K, V>>iterable() |
| 177 | + ? Collections.emptySet() |
179 | 178 | : overflowEntriesDescending.entrySet(); |
180 | 179 | } |
181 | 180 |
|
@@ -597,45 +596,6 @@ private Iterator<Map.Entry<K, V>> getOverflowIterator() { |
597 | 596 | } |
598 | 597 | } |
599 | 598 |
|
600 | | - /** |
601 | | - * Helper class that holds immutable instances of an Iterable/Iterator that we return when the |
602 | | - * overflow entries is empty. This eliminates the creation of an Iterator object when there is |
603 | | - * nothing to iterate over. |
604 | | - */ |
605 | | - private static class EmptySet { |
606 | | - |
607 | | - private static final Iterator<Object> ITERATOR = |
608 | | - new Iterator<Object>() { |
609 | | - @Override |
610 | | - public boolean hasNext() { |
611 | | - return false; |
612 | | - } |
613 | | - |
614 | | - @Override |
615 | | - public Object next() { |
616 | | - throw new NoSuchElementException(); |
617 | | - } |
618 | | - |
619 | | - @Override |
620 | | - public void remove() { |
621 | | - throw new UnsupportedOperationException(); |
622 | | - } |
623 | | - }; |
624 | | - |
625 | | - private static final Iterable<Object> ITERABLE = |
626 | | - new Iterable<Object>() { |
627 | | - @Override |
628 | | - public Iterator<Object> iterator() { |
629 | | - return ITERATOR; |
630 | | - } |
631 | | - }; |
632 | | - |
633 | | - @SuppressWarnings("unchecked") |
634 | | - static <T> Iterable<T> iterable() { |
635 | | - return (Iterable<T>) ITERABLE; |
636 | | - } |
637 | | - } |
638 | | - |
639 | 599 | @Override |
640 | 600 | public boolean equals(Object o) { |
641 | 601 | if (this == o) { |
|
0 commit comments