482 public void clear() {
483 EnumMap.this.clear();
484 }
485 public Object[] toArray() {
486 return fillEntryArray(new Object[size]);
487 }
488 @SuppressWarnings("unchecked")
489 public <T> T[] toArray(T[] a) {
490 int size = size();
491 if (a.length < size)
492 a = (T[])java.lang.reflect.Array
493 .newInstance(a.getClass().getComponentType(), size);
494 if (a.length > size)
495 a[size] = null;
496 return (T[]) fillEntryArray(a);
497 }
498 private Object[] fillEntryArray(Object[] a) {
499 int j = 0;
500 for (int i = 0; i < vals.length; i++)
501 if (vals[i] != null)
502 a[j++] = new AbstractMap.SimpleEntry<K,V>(
503 keyUniverse[i], unmaskNull(vals[i]));
504 return a;
505 }
506 }
507
508 private abstract class EnumMapIterator<T> implements Iterator<T> {
509 // Lower bound on index of next element to return
510 int index = 0;
511
512 // Index of last returned element, or -1 if none
513 int lastReturnedIndex = -1;
514
515 public boolean hasNext() {
516 while (index < vals.length && vals[index] == null)
517 index++;
518 return index != vals.length;
519 }
520
521 public void remove() {
522 checkLastReturnedIndex();
|
482 public void clear() {
483 EnumMap.this.clear();
484 }
485 public Object[] toArray() {
486 return fillEntryArray(new Object[size]);
487 }
488 @SuppressWarnings("unchecked")
489 public <T> T[] toArray(T[] a) {
490 int size = size();
491 if (a.length < size)
492 a = (T[])java.lang.reflect.Array
493 .newInstance(a.getClass().getComponentType(), size);
494 if (a.length > size)
495 a[size] = null;
496 return (T[]) fillEntryArray(a);
497 }
498 private Object[] fillEntryArray(Object[] a) {
499 int j = 0;
500 for (int i = 0; i < vals.length; i++)
501 if (vals[i] != null)
502 a[j++] = new AbstractMap.SimpleEntry<>(
503 keyUniverse[i], unmaskNull(vals[i]));
504 return a;
505 }
506 }
507
508 private abstract class EnumMapIterator<T> implements Iterator<T> {
509 // Lower bound on index of next element to return
510 int index = 0;
511
512 // Index of last returned element, or -1 if none
513 int lastReturnedIndex = -1;
514
515 public boolean hasNext() {
516 while (index < vals.length && vals[index] == null)
517 index++;
518 return index != vals.length;
519 }
520
521 public void remove() {
522 checkLastReturnedIndex();
|