00001 #ifndef TAGCOLL_INT_INDEX_H
00002 #define TAGCOLL_INT_INDEX_H
00003
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <tagcoll/Exception.h>
00027 #include <tagcoll/MMapIndex.h>
00028 #include <vector>
00029 #include <set>
00030
00031 namespace Tagcoll
00032 {
00033
00051 class IntIndex : public MMapIndex
00052 {
00053 protected:
00054 inline int* buf() const { return (int*)m_buf; }
00055 inline size_t ofs(int val) const { return buf()[val]; }
00056
00057 public:
00058 IntIndex() {}
00059 IntIndex(const MasterMMapIndex& master, int idx) : MMapIndex(master, idx) {}
00060
00061 const int* data(int val) const { return (val >= 0 && (unsigned)val < size()) ? buf() + ofs(val) + 1 : 0; }
00062 size_t size(int val) const { return (val >= 0 && (unsigned)val < size()) ? buf()[ofs(val)] : 0; }
00063 size_t size() const { return ofs(0); }
00064 };
00065
00069 class IntIndexer : public MMapIndexer, public std::vector<std::set<int> >
00070 {
00071 public:
00073 void map(unsigned int key, int val)
00074 {
00075 if (size() <= key)
00076 resize(key + 1);
00077 (*this)[key].insert(val);
00078 }
00079
00081 virtual int encodedSize() const;
00082
00085 virtual void encode(char* buf) const;
00086 };
00087
00088 };
00089
00090
00091 #endif