2016-09-25 22:14:36 +08:00
|
|
|
/*=============================================================================
|
|
|
|
# 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);
|
2016-09-25 22:14:36 +08:00
|
|
|
|
|
|
|
//check whether _id exists in this IDList.
|
2017-03-24 20:10:43 +08:00
|
|
|
bool isExistID(unsigned _id) const;
|
|
|
|
unsigned size() const;
|
2016-09-25 22:14:36 +08:00
|
|
|
bool empty() const;
|
2017-03-24 20:10:43 +08:00
|
|
|
const std::vector<unsigned>* getList()const;
|
|
|
|
unsigned& operator[] (const unsigned & _i);
|
2016-09-25 22:14:36 +08:00
|
|
|
std::string to_str();
|
|
|
|
int sort();
|
|
|
|
void clear();
|
2017-03-24 20:10:43 +08:00
|
|
|
void copy(const std::vector<unsigned>& _new_idlist);
|
2016-09-25 22:14:36 +08:00
|
|
|
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);
|
2016-09-25 22:14:36 +08:00
|
|
|
private:
|
2017-03-24 20:10:43 +08:00
|
|
|
std::vector<unsigned> id_list;
|
|
|
|
bool erase(unsigned i);
|
2016-09-25 22:14:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //_QUERY_IDLIST_H
|
|
|
|
|