@Test public void listIterator() { MapPM<Integer, DummyPM> map = new MapPM<Integer, DummyPM>(); final int NUM = 10; populate(map, NUM); ListIterator<DummyPM> iter = map.listIterator(0); assertNotNull("iter", iter); for (int i = 0; i < map.size(); ++i) { assertTrue("iter.hasNext()", iter.hasNext()); DummyPM model = iter.next(); assertEquals("map", map.getAt(i), model); } assertFalse("iter.hasNext()", iter.hasNext()); }
public ListIterator<V> listIterator(final int index) { return new ListIterator<V>() { int next = index; int last = -1; public void add(V o) { throw new UnsupportedOperationException("'add' ist not supported by this ListIterator"); } public boolean hasNext() { return next < entries.size(); } public boolean hasPrevious() { return next - 1 >= 0; } public V next() { V result = entries.get(next); last = next; next++; return result; } public int nextIndex() { return next; } public V previous() { int previous = next - 1; V result = entries.get(previous); last = previous; next--; return result; } public int previousIndex() { return next - 1; } public void remove() { removeAt(last); next = last; last = -1; } public void set(V o) { throw new UnsupportedOperationException("'set' ist not supported by this ListIterator"); } }; }
MapPM extends AbstractPM implements IMapPM<K, V> { public ListIterator<V> listIterator(final int index) { return new ListIterator<V>() { int next = index; int last = -1; public void add(V o) { throw new UnsupportedOperationException("'add' ist not supported by this ListIterator"); } public boolean hasNext() { return next < entries.size(); } public boolean hasPrevious() { return next - 1 >= 0; } public V next() { V result = entries.get(next); last = next; next++; return result; } public int nextIndex() { return next; } public V previous() { int previous = next - 1; V result = entries.get(previous); last = previous; next--; return result; } public int previousIndex() { return next - 1; } public void remove() { removeAt(last); next = last; last = -1; } public void set(V o) { throw new UnsupportedOperationException("'set' ist not supported by this ListIterator"); } }; } }
MapPM extends AbstractPM implements IMapPM<K, V> { public ListIterator<V> listIterator(final int index) { return new ListIterator<V>() { int next = index; int last = -1; public void add(V o) { throw new UnsupportedOperationException("'add' ist not supported by this ListIterator"); } public boolean hasNext() { return next < entries.size(); } public boolean hasPrevious() { return next - 1 >= 0; } public V next() { V result = entries.get(next); last = next; next++; return result; } public int nextIndex() { return next; } public V previous() { int previous = next - 1; V result = entries.get(previous); last = previous; next--; return result; } public int previousIndex() { return next - 1; } public void remove() { removeAt(last); next = last; last = -1; } public void set(V o) { throw new UnsupportedOperationException("'set' ist not supported by this ListIterator"); } }; } MapPM(); }
MapPM extends AbstractPM implements IMapPM<K, V> { public ListIterator<V> listIterator(final int index) { return new ListIterator<V>() { int next = index; int last = -1; public void add(V o) { throw new UnsupportedOperationException("'add' ist not supported by this ListIterator"); } public boolean hasNext() { return next < entries.size(); } public boolean hasPrevious() { return next - 1 >= 0; } public V next() { V result = entries.get(next); last = next; next++; return result; } public int nextIndex() { return next; } public V previous() { int previous = next - 1; V result = entries.get(previous); last = previous; next--; return result; } public int previousIndex() { return next - 1; } public void remove() { removeAt(last); next = last; last = -1; } public void set(V o) { throw new UnsupportedOperationException("'set' ist not supported by this ListIterator"); } }; } MapPM(); Sorter getSorter(); void setSorter(Sorter sorter); boolean isRevalidateElementsOnChangeEnabled(); void setRevalidateElementsOnChangeEnabled(boolean enabled); void revalidateElements(); boolean isEmpty(); void clear(); V put(K key, V newElement); V put(K key, V newElement, int toIndex); void swap(int indexA, int indexB); void swap(V elemA, V elemB); void reverse(); void sortBy(boolean ascending, Path... paths); void sortBy(Collection<SortKey> newSortKeys); void sortBy(SortKey... newSortKeys); Collection<SortKey> getSortKeys(); int size(); Collection<V> getAll(int startIndex, int endIndex); Collection<V> getAll(int[] indices); V getAt(int index); V get(K key); V removeAt(int index); V removeKey(K key); boolean remove(V elem); boolean removeAll(Collection<? extends V> col); Collection<V> toCollection(); Map<K, V> toMap(); Object[] toArray(); Set<K> keySet(); boolean containsKey(K key); boolean contains(V element); int indexOfKey(K key); int indexOf(V element); int[] indicesOfKeys(Collection<K> keys); int[] indicesOf(Collection elements); K getKey(V element); K getKey(int index); List<K> getKeys(int beginIndex, int endIndex); Set<K> getKeys(int[] indices); Set<K> getKeys(Collection<?> col); SelectedKeys<K> getSelectedKeys(); Selection<V> getSelection(); void addListListener(ListListener l); void removeListListener(ListListener l); Iterator<V> iterator(); ListIterator<V> listIterator(final int index); Iterator<K> keyiterator(); Collection<V> removeAllKeys(Set<K> keySet); Collection<V> retainAllKeys(Set<K> keySet); Collection<V> removeAllIndices(int[] indices); void putAll(Map<K, V> aMap); void putAll(Collection<Entry<K, V>> aEntries); void setAll(Map<K, V> newMap); }
MapPM extends AbstractPM implements IMapPM<K, V> { public ListIterator<V> listIterator(final int index) { return new ListIterator<V>() { int next = index; int last = -1; public void add(V o) { throw new UnsupportedOperationException("'add' ist not supported by this ListIterator"); } public boolean hasNext() { return next < entries.size(); } public boolean hasPrevious() { return next - 1 >= 0; } public V next() { V result = entries.get(next); last = next; next++; return result; } public int nextIndex() { return next; } public V previous() { int previous = next - 1; V result = entries.get(previous); last = previous; next--; return result; } public int previousIndex() { return next - 1; } public void remove() { removeAt(last); next = last; last = -1; } public void set(V o) { throw new UnsupportedOperationException("'set' ist not supported by this ListIterator"); } }; } MapPM(); Sorter getSorter(); void setSorter(Sorter sorter); boolean isRevalidateElementsOnChangeEnabled(); void setRevalidateElementsOnChangeEnabled(boolean enabled); void revalidateElements(); boolean isEmpty(); void clear(); V put(K key, V newElement); V put(K key, V newElement, int toIndex); void swap(int indexA, int indexB); void swap(V elemA, V elemB); void reverse(); void sortBy(boolean ascending, Path... paths); void sortBy(Collection<SortKey> newSortKeys); void sortBy(SortKey... newSortKeys); Collection<SortKey> getSortKeys(); int size(); Collection<V> getAll(int startIndex, int endIndex); Collection<V> getAll(int[] indices); V getAt(int index); V get(K key); V removeAt(int index); V removeKey(K key); boolean remove(V elem); boolean removeAll(Collection<? extends V> col); Collection<V> toCollection(); Map<K, V> toMap(); Object[] toArray(); Set<K> keySet(); boolean containsKey(K key); boolean contains(V element); int indexOfKey(K key); int indexOf(V element); int[] indicesOfKeys(Collection<K> keys); int[] indicesOf(Collection elements); K getKey(V element); K getKey(int index); List<K> getKeys(int beginIndex, int endIndex); Set<K> getKeys(int[] indices); Set<K> getKeys(Collection<?> col); SelectedKeys<K> getSelectedKeys(); Selection<V> getSelection(); void addListListener(ListListener l); void removeListListener(ListListener l); Iterator<V> iterator(); ListIterator<V> listIterator(final int index); Iterator<K> keyiterator(); Collection<V> removeAllKeys(Set<K> keySet); Collection<V> retainAllKeys(Set<K> keySet); Collection<V> removeAllIndices(int[] indices); void putAll(Map<K, V> aMap); void putAll(Collection<Entry<K, V>> aEntries); void setAll(Map<K, V> newMap);  }