/* */ #ifndef _D_BNODE_H_ #define _D_BNODE_H_ #include "common.h" #include "SharedHandle.h" #include namespace aria2 { class DHTBucket; class DHTNode; class BNode { private: SharedHandle _bucket; BNode* _up; BNode* _left; BNode* _right; public: BNode(const SharedHandle& bucket = SharedHandle()); ~BNode(); SharedHandle getBucket() const; void setBucket(const SharedHandle& bucket); BNode* getLeft() const; void setLeft(BNode* left); BNode* getRight() const; void setRight(BNode* right); BNode* getUp() const; void setUp(BNode* up); bool isInRange(const unsigned char* key) const; static BNode* findBNodeFor(BNode* b, const unsigned char* key); static SharedHandle findBucketFor(BNode* b, const unsigned char* key); static void findClosestKNodes(std::deque >& nodes, BNode* b, const unsigned char* key); static void enumerateBucket(std::deque >& buckets, const BNode* b); }; } // namespace aria2 #endif // _D_BNODE_H_