gStore/Query/IDList.h

47 lines
1.5 KiB
C
Raw Normal View History

/*=============================================================================
# Filename: IDList.h
# Author: Bookug Lobert
# Mail: 1181955272@qq.com
# Last Modified: 2015-10-23 15:03
# Description: originally written by liyouhuan, modified by zengli
=============================================================================*/
#include "../Util/Util.h"
#ifndef _QUERY_IDLIST_H
#define _QUERY_IDLIST_H
class IDList
{
public:
IDList();
2017-03-24 20:10:43 +08:00
unsigned getID(unsigned _i) const;
bool addID(unsigned _id);
//check whether _id exists in this IDList.
2017-03-24 20:10:43 +08:00
bool isExistID(unsigned _id) const;
unsigned size() const;
bool empty() const;
2017-03-24 20:10:43 +08:00
const std::vector<unsigned>* getList()const;
unsigned& operator[] (const unsigned & _i);
std::string to_str();
int sort();
void clear();
2017-03-24 20:10:43 +08:00
void copy(const std::vector<unsigned>& _new_idlist);
void copy(const IDList* _new_idlist);
// intersect/union _id_list to this IDList, note that the two list must be ordered before using these two functions.
2017-03-24 20:10:43 +08:00
unsigned intersectList(const unsigned* _id_list, unsigned _list_len);
unsigned intersectList(const IDList&);
unsigned unionList(const unsigned* _id_list, unsigned _list_len, bool only_literal=false);
unsigned unionList(const IDList&, bool only_literal=false);
unsigned bsearch_uporder(unsigned _key);
static IDList* intersect(const IDList&, const unsigned*, unsigned);
private:
2017-03-24 20:10:43 +08:00
std::vector<unsigned> id_list;
bool erase(unsigned i);
};
#endif //_QUERY_IDLIST_H