当前位置: 首页>>代码示例>>Java>>正文


Java CloseableIterator类代码示例

本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.util.CloseableIterator的典型用法代码示例。如果您正苦于以下问题:Java CloseableIterator类的具体用法?Java CloseableIterator怎么用?Java CloseableIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CloseableIterator类属于org.apache.tinkerpop.gremlin.structure.util包,在下文中一共展示了CloseableIterator类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: map

import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator; //导入依赖的package包/类
public static <S, E> Iterator<E> map(final Iterator<S> iterator, final Function<S, E> function) {
    return new CloseableIterator<E>() {
        @Override
        public boolean hasNext() {
            return iterator.hasNext();
        }

        @Override
        public void remove() {
            iterator.remove();
        }

        @Override
        public E next() {
            return function.apply(iterator.next());
        }

        @Override
        public void close() {
            CloseableIterator.closeIterator(iterator);
        }
    };
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:24,代码来源:CloseableIteratorUtils.java

示例2: flatMap

import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator; //导入依赖的package包/类
public static <S, E> Iterator<E> flatMap(final Iterator<S> iterator, final Function<S, Iterator<E>> function) {
    return new CloseableIterator<E>() {

        private Iterator<E> currentIterator = Collections.emptyIterator();

        @Override
        public boolean hasNext() {
            if (this.currentIterator.hasNext())
                return true;
            else {
                while (iterator.hasNext()) {
                    this.currentIterator = function.apply(iterator.next());
                    if (this.currentIterator.hasNext())
                        return true;
                }
            }
            return false;
        }

        @Override
        public void remove() {
            iterator.remove();
        }

        @Override
        public E next() {
            if (this.hasNext())
                return this.currentIterator.next();
            else
                throw FastNoSuchElementException.instance();
        }

        @Override
        public void close() {
            CloseableIterator.closeIterator(iterator);
        }
    };
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:39,代码来源:CloseableIteratorUtils.java

示例3: filter

import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator; //导入依赖的package包/类
public static <S> Iterator<S> filter(final Iterator<S> iterator, final Predicate<S> predicate) {
    return new CloseableIterator<S>() {
        S nextResult = null;

        @Override
        public boolean hasNext() {
            if (null != this.nextResult) {
                return true;
            } else {
                advance();
                return null != this.nextResult;
            }
        }

        @Override
        public void remove() {
            iterator.remove();
        }

        @Override
        public S next() {
            try {
                if (null != this.nextResult) {
                    return this.nextResult;
                } else {
                    advance();
                    if (null != this.nextResult)
                        return this.nextResult;
                    else
                        throw FastNoSuchElementException.instance();
                }
            } finally {
                this.nextResult = null;
            }
        }

        private void advance() {
            this.nextResult = null;
            while (iterator.hasNext()) {
                final S s = iterator.next();
                if (predicate.test(s)) {
                    this.nextResult = s;
                    return;
                }
            }
        }

        @Override
        public void close() {
            CloseableIterator.closeIterator(iterator);
        }
    };
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:54,代码来源:CloseableIteratorUtils.java

示例4: close

import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator; //导入依赖的package包/类
@Override
public void close() {
    this.iterators.forEach(CloseableIterator::closeIterator);
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:5,代码来源:CloseableIteratorUtils.java

示例5: closeIterator

import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator; //导入依赖的package包/类
protected void closeIterator() {
    CloseableIterator.closeIterator(iterator);
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:4,代码来源:FlatMapStep.java

示例6: close

import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator; //导入依赖的package包/类
/**
 * Attempts to close an underlying iterator if it is of type {@link CloseableIterator}. Graph providers may choose
 * to return this interface containing their vertices and edges if there are expensive resources that might need to
 * be released at some point.
 */
@Override
public void close() {
    CloseableIterator.closeIterator(iterator);
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:10,代码来源:GraphStep.java


注:本文中的org.apache.tinkerpop.gremlin.structure.util.CloseableIterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。