31 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_ITERATOR_H 32 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_ITERATOR_H 34 #include "llvm/ADT/ArrayRef.h" 35 #include "llvm/Support/raw_ostream.h" 95 friend llvm::raw_ostream &
operator<<(llvm::raw_ostream &OS,
97 return Iterator.dump(OS);
101 virtual llvm::raw_ostream &dump(llvm::raw_ostream &OS)
const = 0;
113 std::unique_ptr<Iterator>
114 createAnd(std::vector<std::unique_ptr<Iterator>> Children);
118 std::unique_ptr<Iterator>
119 createOr(std::vector<std::unique_ptr<Iterator>> Children);
122 template <
typename... Args> std::unique_ptr<Iterator>
createAnd(Args... args) {
123 std::vector<std::unique_ptr<Iterator>> Children;
129 template <
typename... Args> std::unique_ptr<Iterator>
createOr(Args... args) {
130 std::vector<std::unique_ptr<Iterator>> Children;
135 template <
typename HeadT,
typename... TailT>
138 Children.push_back(move(Head));
142 template <
typename HeadT>
145 Children.push_back(move(Head));
std::vector< DocID > PostingList
Contains sorted sequence of DocIDs all of which belong to symbols matching certain criteria...
std::vector< DocID > consume(Iterator &It)
Exhausts given iterator and returns all processed DocIDs.
llvm::ArrayRef< DocID > PostingListRef
Immutable reference to PostingList object.
Iterator is the interface for Query Tree node.
virtual DocID peek() const =0
Returns the current element this iterator points to.
std::unique_ptr< Iterator > create(PostingListRef Documents)
Returns a document iterator over given PostingList.
uint32_t DocID
Symbol position in the list of all index symbols sorted by a pre-computed symbol quality.
virtual void advance()=0
Moves to next valid DocID.
std::unique_ptr< Iterator > createOr(std::vector< std::unique_ptr< Iterator >> Children)
Returns OR Iterator which performs the union of the PostingLists of its children. ...
std::unique_ptr< Iterator > createAnd(std::vector< std::unique_ptr< Iterator >> Children)
Returns AND Iterator which performs the intersection of the PostingLists of its children.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
virtual void advanceTo(DocID ID)=0
Moves to the first valid DocID which is equal or higher than given ID.
virtual bool reachedEnd() const =0
Returns true if all valid DocIDs were processed and hence the iterator is exhausted.
void populateChildren(std::vector< std::unique_ptr< Iterator >> &Children, HeadT &Head, TailT &... Tail)
friend llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const Iterator &Iterator)
Prints a convenient human-readable iterator representation by recursively dumping iterators in the fo...