當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。