org.basex.util.ft
Class FTBitapSearch

java.lang.Object
  extended by org.basex.util.ft.FTBitapSearch

public final class FTBitapSearch
extends java.lang.Object

Generalized search algorithm based on the Bitap string matching algorithm. The implementation is based on the implementation in Wikipedia, but uses BitSet for fast bit operation. This version works with a set of needles and each one of it can be matched in the haystack.

Author:
BaseX Team 2005-12, BSD License, Dimitar Popov
See Also:
http://en.wikipedia.org/wiki/Bitap_algorithm

Nested Class Summary
static interface FTBitapSearch.TokenComparator
          Token comparator.
 
Constructor Summary
FTBitapSearch(FTIterator h, FTTokens n, FTBitapSearch.TokenComparator c)
          Constructor.
 
Method Summary
 boolean hasNext()
          Is there one more match?
 int next()
          Position in the haystack of the next match.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FTBitapSearch

public FTBitapSearch(FTIterator h,
                     FTTokens n,
                     FTBitapSearch.TokenComparator c)
Constructor.

Parameters:
h - iterator over the set of elements being searched ("haystack")
n - a list of "needles" (a needle is an array of elements being searched for)
c - comparator for comparing two elements for equality
Method Detail

hasNext

public boolean hasNext()
                throws QueryException
Is there one more match?

Returns:
true if yes
Throws:
QueryException - if an error occurs during search

next

public int next()
         throws QueryException
Position in the haystack of the next match.

Returns:
start position of the match; first position is 0
Throws:
QueryException - if an error occurs during search