FirteX-高性能全文索引和检索平台

API Documentation


首页 | 名字空间列表 | 类继承关系 | 组合类型列表 | $(BL\录(B | 文件列表 | 名字空间成员 | 组合类型成员 | 文件成员

MultiTermIterator.h

浏览该文件的文档。
00001 //
00002 // Copyright(C) 2005--2006 Institute of Computing Tech, Chinese Academy of Sciences. 
00003 // All rights reserved.
00004 // This file is part of FirteX (www.firtex.org)
00005 //
00006 // Use of the FirteX is subject to the terms of the software license set forth in 
00007 // the LICENSE file included with this software, and also available at
00008 // http://www.firtex.org/license.html
00009 //
00010 // Author       : 郭瑞杰(GuoRuijie)
00011 // Email        : ruijieguo@software.ict.ac.cn
00012 // Created      : 2006/7/20
00013 //
00014 #ifndef _MULTITERMITERATOR_H
00015 #define _MULTITERMITERATOR_H
00016 
00017 #if _MSC_VER > 1000
00018 #pragma once
00019 #endif // _MSC_VER > 1000
00020 
00021 #include "TermIterator.h"
00022 #include "../utility/PriorityQueue.h"
00023 #include <vector>
00024 using namespace std;
00025 
00026 namespace firtex
00027 {
00028         namespace index
00029         {
00030                 class CMultiTermIterator :      public CTermIterator
00031                 {
00032                         class CTermIteratorEntry
00033                         {
00034                         public:
00035                                 CTermIteratorEntry(CTermIterator* iter):termIterator(iter),term(NULL){}
00036                                 ~CTermIteratorEntry()
00037                                 {
00038                                         if(termIterator)
00039                                         {
00040                                                 delete termIterator;
00041                                                 termIterator = NULL;
00042                                         }
00043                                         term = NULL;
00044                                 }
00045 
00046                                 bool next()
00047                                 {
00048                                         if(termIterator == NULL)
00049                                                 return false;
00050                                         bool ret = termIterator->next();
00051                                         if(ret == false)
00052                                                 return false;
00053                                         term = (CTerm*)termIterator->term();
00054                                         return true;
00055                                 }
00056                         public:
00057                                 CTermIterator*  termIterator;
00058                                 CTerm*                  term;
00059                         };
00060 
00061                         class CTermIteratorQueue : public CPriorityQueue<CMultiTermIterator::CTermIteratorEntry*>
00062                         {
00063                         public:
00064                                 CTermIteratorQueue(size_t size) 
00065                                 {
00066                                         initialize(size,false);
00067                                 }
00068                         protected:
00069                                 bool lessThan(CMultiTermIterator::CTermIteratorEntry* o1, CMultiTermIterator::CTermIteratorEntry* o2) 
00070                                 {
00071                                         return (o1->term->compare(o2->term) < 0);
00072                                 }
00073                         };
00074                 public:
00075                         CMultiTermIterator(void);
00076                         virtual ~CMultiTermIterator(void);
00077                 public:
00082                         bool    next();
00083 
00089                         bool    skipTo(const CTerm* target);
00090 
00094                         const CTerm*  term();
00095 
00099                         freq_t          docFreq();
00100 
00105                         void            addIterator(CTermIterator* iter);
00106                 protected:
00107                         void            initQueue();
00108                 private:
00109                         vector<CMultiTermIterator::CTermIteratorEntry*> m_iters;
00110                         CMultiTermIterator::CTermIteratorQueue* m_itersQueue;
00111                         CTerm*                          m_pTerm;
00112                         freq_t                          m_docFreq;
00113                 };
00114         }
00115 }
00116 
00117 #endif

http://www.firtex.org http://www.sourceforge.net/projects/firtex