github.com/balzaczyy/golucene@v0.0.0-20151210033525-d0be9ee89713/core/util/iterator.go (about)

     1  package util
     2  
     3  import "sort"
     4  
     5  // BytesRefIterator.java
     6  // A simple iterator interface for []byte iteration.
     7  type BytesRefIterator interface {
     8  	/* Increments the iteration to the next []byte in the iterator. Returns the
     9  	resulting []byte or nil if the end of the iterator is reached. The returned
    10  	[]byte may be re-used across calls to the next. After this method returns
    11  	nil, do not call it again: the results are undefined. */
    12  	Next() (buf []byte, err error)
    13  
    14  	/* Return the []byte Comparator used to sort terms provided by the iterator.
    15  	This may return nil if there are no items or the iterator is not sorted.
    16  	Callers may invoke this method many times, so it's best to cache a single
    17  	instance & reuse it. */
    18  	Comparator() sort.Interface
    19  }
    20  
    21  var EMPTY_BYTES_REF_ITERATOR = &emptyBytesRefIterator{}
    22  
    23  type emptyBytesRefIterator struct{}
    24  
    25  func (iter *emptyBytesRefIterator) Next() (buf []byte, err error) {
    26  	return nil, nil
    27  }
    28  
    29  func (iter *emptyBytesRefIterator) Comparator() sort.Interface {
    30  	return nil
    31  }