// NodeTable.h #ifndef NODE_TABLE_H #define NODE_TABLE_H #include "AllocationInfo.h" #include "Node.h" #include "OpenHashTable.h" // NodeHashElement class NodeHashElement : public OpenHashElement { public: NodeHashElement() : OpenHashElement(), fNode(NULL) { fNext = -1; } static inline uint32 HashForID(ino_t id) { return uint32(id & 0xffffffff); } static inline uint32 HashForID(Node *node) { return HashForID(node->GetID()); } inline uint32 Hash() const { return HashForID(fNode); } inline bool operator==(const OpenHashElement &element) const { return (static_cast(element).fNode == fNode); } inline void Adopt(NodeHashElement &element) { fNode = element.fNode; } Node *fNode; }; // NodeTable class NodeTable { public: NodeTable(); ~NodeTable(); status_t InitCheck() const; status_t AddNode(Node *node); status_t RemoveNode(Node *node); status_t RemoveNode(ino_t id); Node *GetNode(ino_t id); // debugging void GetAllocationInfo(AllocationInfo &info); private: NodeHashElement *_FindElement(ino_t id) const; private: OpenHashElementArray fElementArray; OpenHashTable > fNodes; }; // undefine the PRINT from //#undef PRINT #endif // NODE_TABLE_H