📄 documentiteratorvisitor.java
字号:
package it.unimi.dsi.mg4j.search.visitor;/* * MG4J: Managing Gigabytes for Java * * Copyright (C) 2006-2007 Sebastiano Vigna * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */import java.io.IOException;import it.unimi.dsi.mg4j.index.IndexIterator;import it.unimi.dsi.mg4j.search.DocumentIterator;/** A visitor for the tree defined by a {@link DocumentIterator}. * * <p>Implementations of this interface must be reusable. The user must * invoke {@link #prepare()} before a visit so that the internal state * of the visitor can be suitably set up. * * <p>For maximum flexibility, there is just {@linkplain #visit(IndexIterator) one visit method} * for leaves, but <em>two</em> visits methods for internal nodes, * which should be used for {@linkplain #visitPre(DocumentIterator) preorder} * and {@linkplain #visitPost(DocumentIterator) postorder} visits, respectively. * * <p>Note that this visitor interface and that defined in {@link it.unimi.dsi.mg4j.query.nodes.QueryBuilderVisitor} * are based on different principles: in the latter case, the action of the visitor will likely * be different for each type of internal node, so we have specific visit methods for each type of such nodes. * In our case, the visit will most likely behave differently just for internal nodes and leaves, so we * prefer a simpler interface thatalso let us implement more easily visitor acceptance methods * ({@link it.unimi.dsi.mg4j.search.DocumentIterator#accept(DocumentIteratorVisitor)} * and {@link it.unimi.dsi.mg4j.search.DocumentIterator#acceptOnTruePaths(DocumentIteratorVisitor)}). * * @author Sebastiano Vigna */ public interface DocumentIteratorVisitor { /** Prepares the internal state of this visitor for a(nother) visit. * * <p>By specification, it must be safe to call this method any number of times. * @return this visitor. */ DocumentIteratorVisitor prepare(); /** Visits an internal node <em>before</em> recursing into the corresponding subtree. * * @param documentIterator the internal node to be visited. * @return true if the visit should continue. */ boolean visitPre( DocumentIterator documentIterator ); /** Visits an internal node <em>after</em> recursing into the corresponding subtree. * * @param documentIterator the internal node to be visited. * @return true if the visit should continue. */ boolean visitPost( DocumentIterator documentIterator ); /** Visits a leaf. * * @param indexIterator the leaf to be visited. * @return true if the visit should continue. */ boolean visit( IndexIterator indexIterator ) throws IOException;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -