Refine search
public static List<IWord> spilt(List<IWord> wordList) { ListIterator<IWord> listIterator = wordList.listIterator(); while (listIterator.hasNext()) { IWord word = listIterator.next(); if (word instanceof CompoundWord) { listIterator.remove(); for (Word inner : ((CompoundWord) word).innerList) { listIterator.add(inner); } } } return wordList; } }
private static void mergeDate(ListIterator<Vertex> listIterator, Vertex next, Vertex current) { current = Vertex.newTimeInstance(current.realWord + next.realWord); listIterator.previous(); listIterator.previous(); listIterator.set(current); listIterator.next(); listIterator.next(); listIterator.remove(); }
// Substitute appropriate type. ArrayList<...> a = new ArrayList<...>(); // Add elements to list. // Generate an iterator. Start just after the last element. ListIterator li = a.listIterator(a.size()); // Iterate in reverse. while(li.hasPrevious()) { System.out.println(li.previous()); }
@Override public void absorbContent(ListIterator<Content> contents) { // Fast forward the iterator until after this content. //noinspection StatementWithEmptyBody while (contents.hasPrevious() && contents.previous() != this) {} while (contents.hasPrevious()) { Content content = contents.previous(); if (content instanceof PathContent) { pathContents.add((PathContent) content); contents.remove(); } } }
/** * Apply this patch to the given target * @param target the list to patch * @return the patched text * @throws IllegalStateException if can't apply patch */ public List<T> applyTo(List<T> target) throws IllegalStateException { List<T> result = new LinkedList<>(target); ListIterator<Delta<T>> it = getDeltas().listIterator(deltas.size()); while (it.hasPrevious()) { Delta<T> delta = it.previous(); delta.applyTo(result); } return result; }
public void testEmptyListIterator() { ListIterator<String> iterator = Iterators.emptyListIterator(); assertFalse(iterator.hasNext()); assertFalse(iterator.hasPrevious()); assertEquals(0, iterator.nextIndex()); assertEquals(-1, iterator.previousIndex()); try { iterator.next(); fail("no exception thrown"); } catch (NoSuchElementException expected) { iterator.previous(); fail("no exception thrown"); } catch (NoSuchElementException expected) { iterator.remove(); fail("no exception thrown"); } catch (UnsupportedOperationException expected) { iterator.set("a"); fail("no exception thrown"); } catch (UnsupportedOperationException expected) { iterator.add("a"); fail("no exception thrown"); } catch (UnsupportedOperationException expected) {
private void replaceValue(List<Entry<K, V>> expected, Entry<K, V> newEntry) { for (ListIterator<Entry<K, V>> i = expected.listIterator(); i.hasNext(); ) { if (Helpers.equal(i.next().getKey(), newEntry.getKey())) { i.set(newEntry); return; } } throw new IllegalArgumentException( Platform.format("key %s not found in entries %s", newEntry.getKey(), expected)); }
/** * 将一个词语从词网中彻底抹除 * @param cur 词语 * @param wordNetAll 词网 * @param line 当前扫描的行数 * @param length 当前缓冲区的长度 */ private static void removeFromWordNet(Vertex cur, WordNet wordNetAll, int line, int length) { LinkedList<Vertex>[] vertexes = wordNetAll.getVertexes(); // 将其从wordNet中删除 for (Vertex vertex : vertexes[line + length]) { if (vertex.from == cur) vertex.from = null; } ListIterator<Vertex> iterator = vertexes[line + length - cur.realWord.length()].listIterator(); while (iterator.hasNext()) { Vertex vertex = iterator.next(); if (vertex == cur) iterator.remove(); } }
void appendWhereClause(StringBuilder builder, String tablePrefixOrNull, List<Object> values) { ListIterator<WhereCondition> iter = whereConditions.listIterator(); while (iter.hasNext()) { if (iter.hasPrevious()) { builder.append(" AND "); } WhereCondition condition = iter.next(); condition.appendTo(builder, tablePrefixOrNull); condition.appendValuesTo(values); } }
/** An implementation of {@link List#indexOf(Object)}. */ static int indexOfImpl(List<?> list, @Nullable Object element) { if (list instanceof RandomAccess) { return indexOfRandomAccess(list, element); } else { ListIterator<?> listIterator = list.listIterator(); while (listIterator.hasNext()) { if (Objects.equal(element, listIterator.next())) { return listIterator.previousIndex(); } } return -1; } }
private void walkForward(ListIterator expected, ListIterator testing) { while(expected.hasNext()) { assertEquals(expected.nextIndex(),testing.nextIndex()); assertEquals(expected.previousIndex(),testing.previousIndex()); assertTrue(testing.hasNext()); assertEquals(expected.next(),testing.next()); } }
/** An implementation of {@link List#lastIndexOf(Object)}. */ static int lastIndexOfImpl(List<?> list, @Nullable Object element) { if (list instanceof RandomAccess) { return lastIndexOfRandomAccess(list, element); } else { ListIterator<?> listIterator = list.listIterator(list.size()); while (listIterator.hasPrevious()) { if (Objects.equal(element, listIterator.previous())) { return listIterator.nextIndex(); } } return -1; } }
public void testGet_collections() { assertEquals(ImmutableSet.of().iterator(), ArbitraryInstances.get(Iterator.class)); assertFalse(ArbitraryInstances.get(PeekingIterator.class).hasNext()); assertFalse(ArbitraryInstances.get(ListIterator.class).hasNext()); assertEquals(ImmutableSet.of(), ArbitraryInstances.get(Iterable.class)); assertEquals(ImmutableSet.of(), ArbitraryInstances.get(Set.class)); assertTrue(ArbitraryInstances.get(NavigableSet.class).isEmpty()); assertTrue(ArbitraryInstances.get(NavigableMap.class).isEmpty()); assertTrue(ArbitraryInstances.get(LinkedList.class).isEmpty()); assertTrue(ArbitraryInstances.get(Deque.class).isEmpty()); assertTrue(ArbitraryInstances.get(Queue.class).isEmpty());