Example usage for org.apache.commons.collections4.iterators EmptyIterator INSTANCE

List of usage examples for org.apache.commons.collections4.iterators EmptyIterator INSTANCE

Introduction

In this page you can find the example usage for org.apache.commons.collections4.iterators EmptyIterator INSTANCE.

Prototype

Iterator INSTANCE

To view the source code for org.apache.commons.collections4.iterators EmptyIterator INSTANCE.

Click Source Link

Document

Singleton instance of the iterator.

Usage

From source file:org.cyclop.model.CqlQueryResult.java

@SuppressWarnings("unchecked")
CqlQueryResult() {
    rows = EmptyIterator.INSTANCE;
    rowMetadata = CqlRowMetadata.EMPTY;
}

From source file:org.cyclop.model.CqlQueryResult.java

private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
    in.defaultReadObject();//w  ww .j  a  va 2s  .com
    SerializationUtil.setField(this, "rows", EmptyIterator.INSTANCE);
}

From source file:phex.common.collections.StringTrie.java

/**
 * Same as getPrefixedBy(prefix.substring(startOffset, stopOffset). This is
 * useful as an optimization in certain applications to avoid allocations.
 * <p>/*www  .java2  s . c  o  m*/
 * <p>
 * Important: canonicalization of prefix substring is NOT performed here!
 * But it can be performed early on the whole buffer using the public method
 * <tt>canonicalCase(String)</tt> of this.
 *
 * @requires 0 &lt;= startOffset &lt;= stopOffset &lt;= prefix.length
 * @see #canonicalCase(String)
 */
public Iterator<V> getPrefixedBy(String prefix, int startOffset, int stopOffset) {
    // Find the first node for which "prefix" prefixes KEY(node). (See the
    // implementation overview for a definition of KEY(node).) This code is
    // similar to fetch(prefix), except that if prefix extends into the
    // middle of an edge label, that edge's child is considered a match.
    TrieNode<V> node = root;
    for (int i = startOffset; i < stopOffset;) {
        // Find the edge whose label starts with prefix[i].
        TrieEdge<V> edge = node.get(prefix.charAt(i));
        if (edge == null) {
            return EmptyIterator.INSTANCE;
        }
        // Now check that rest of label matches
        node = edge.getChild();
        String label = edge.getLabel();
        int j = match(prefix, i, stopOffset, label);
        assert j != 0 : "Label didn't start with prefix[0].";
        if (i + j == stopOffset) {
            // a) prefix overlaps perfectly with just part of edge label
            break;
        } else if (j >= 0) {
            // b) prefix and label differ at some point
            node = null;
            break;
        } else {
            // c) prefix overlaps perfectly with all of edge label.
            assert j == -1 : "Bad return value from match: " + i;
        }
        i += label.length();
    }
    // Yield all children of node, including node itself.
    if (node == null)
        return EmptyIterator.INSTANCE;
    else
        return new ValueIterator(node);
}