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

org.sirix.index.IndexAxis Maven / Gradle / Ivy

package org.sirix.index;

import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Iterator;
import java.util.Set;
import org.sirix.index.avltree.AVLNode;
import org.sirix.index.avltree.keyvalue.NodeReferences;
import com.google.common.collect.AbstractIterator;

public final class IndexAxis>
    extends AbstractIterator {

  private final Iterator> mIter;

  private final Set mFilter;

  public IndexAxis(final Iterator> iter,
      final Set filter) {
    mIter = checkNotNull(iter);
    mFilter = checkNotNull(filter);
  }

  @Override
  protected NodeReferences computeNext() {
    while (mIter.hasNext()) {
      final AVLNode node = mIter.next();
      boolean filterResult = true;
      for (final Filter filter : mFilter) {
        filterResult = filterResult && filter.filter(node);
        if (!filterResult) {
          break;
        }
      }
      if (filterResult) {
        return node.getValue();
      } else {
        return endOfData();
      }
    }
    return endOfData();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy