00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __P2P_COMPACT_LIST_HPP__
00027 #define __P2P_COMPACT_LIST_HPP__
00028
00029 #include <utility>
00030 #include <boost/scoped_array.hpp>
00031 #include <boost/utility.hpp>
00032 #include <p2p/list.hpp>
00033 #include <p2p/range.hpp>
00034
00035 namespace p2p {
00036 class compact_list : boost::noncopyable {
00037 public:
00038 typedef std::pair<unsigned int,unsigned int> range_type;
00039
00040 private:
00041 boost::scoped_array<range_type> _ranges;
00042 int _rangecount;
00043
00044 public:
00045 compact_list(const class list &l);
00046
00047 int size() const { return _rangecount; }
00048 unsigned int ip_count() const;
00049
00050 const range_type& operator[](int index) const { return _ranges[index]; }
00051
00052 const range_type *operator()(unsigned int ip) const;
00053 const range_type *operator()(const range_type &r) const;
00054 const range_type *operator()(const struct range &r) const;
00055 };
00056 }
00057
00058 #endif