org.hypergraphdb.query.impl
Class SortedIntersectionResult<T>

java.lang.Object
  extended by org.hypergraphdb.query.impl.SortedIntersectionResult<T>
All Implemented Interfaces:
java.util.Iterator<T>, HGSearchResult<T>, RSCombiner<T>, TwoWayIterator<T>, CloseMe

public class SortedIntersectionResult<T>
extends java.lang.Object
implements HGSearchResult<T>, RSCombiner<T>

Combines two ordered result sets into a (ordered) result representing their set theoretical intersection. It assumes that the objects contained in the result sets being intersected are java.lang.Comparable instances.

Author:
Borislav Iordanov

Constructor Summary
SortedIntersectionResult()
           
SortedIntersectionResult(HGSearchResult<T> left, HGSearchResult<T> right)
           
 
Method Summary
 void close()
          Free all system resources held up by the result set and invalidate it for further use.
 T current()
          Returns the current element in the result set.
 boolean hasNext()
           
 boolean hasPrev()
           Return true if there is a previous element in the current iteration state and false otherwise.
 void init(HGSearchResult<T> left, HGSearchResult<T> right)
           
 boolean isOrdered()
          Return true if the elements in this search result are in ordered and false otherwise.
 T next()
           
 T prev()
           Returns the previous element in this iteration.
 void remove()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortedIntersectionResult

public SortedIntersectionResult()

SortedIntersectionResult

public SortedIntersectionResult(HGSearchResult<T> left,
                                HGSearchResult<T> right)
Method Detail

init

public void init(HGSearchResult<T> left,
                 HGSearchResult<T> right)
Specified by:
init in interface RSCombiner<T>

current

public T current()
Description copied from interface: HGSearchResult

Returns the current element in the result set. If there is no current element, java.util.NoSuchElementException is thrown. There is no current element in one of two cases: either the result set is empty or the next method was never invoked.

Specified by:
current in interface HGSearchResult<T>
Returns:
The current element in a HGSearchResult.

close

public void close()
Description copied from interface: HGSearchResult

Free all system resources held up by the result set and invalidate it for further use.

Specified by:
close in interface HGSearchResult<T>
Specified by:
close in interface CloseMe

hasPrev

public boolean hasPrev()
Description copied from interface: TwoWayIterator

Return true if there is a previous element in the current iteration state and false otherwise. After the iterator has been initialized, the value of hasPrev will always be false.

Specified by:
hasPrev in interface TwoWayIterator<T>

prev

public T prev()
Description copied from interface: TwoWayIterator

Returns the previous element in this iteration.

Specified by:
prev in interface TwoWayIterator<T>

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<T>

next

public T next()
Specified by:
next in interface java.util.Iterator<T>

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<T>

isOrdered

public boolean isOrdered()
Description copied from interface: HGSearchResult

Return true if the elements in this search result are in ordered and false otherwise. It is assumed that when elements are ordered, they are instances of java.lang.Comparable

Specified by:
isOrdered in interface HGSearchResult<T>