All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.stanford.nlp.util.ConcatenationIterator Maven / Gradle / Ivy

Go to download

Stanford Parser processes raw text in English, Chinese, German, Arabic, and French, and extracts constituency parse trees.

There is a newer version: 3.9.2
Show newest version
package edu.stanford.nlp.util;

import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;

/**
 * Iterator that represents the concatenation of two other iterators.
 * 

* User: Dan Klein ([email protected]) * Date: Oct 22, 2003 * Time: 7:27:39 PM */ public class ConcatenationIterator implements Iterator { Iterator first = null; Iterator second = null; Iterator current() { if (first.hasNext()) { return first; } return second; } public boolean hasNext() { return current().hasNext(); } public T next() { return current().next(); } public void remove() { current().remove(); } public ConcatenationIterator(Iterator first, Iterator second) { this.first = first; this.second = second; } public static void main(String[] args) { Collection c1 = Collections.singleton("a"); Collection c2 = Collections.singleton("b"); Iterator i = new ConcatenationIterator<>(c1.iterator(), c2.iterator()); while (i.hasNext()) { System.out.println(i.next() + " "); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy