⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nhashnode.h

📁 奇迹世界公用文件源代码,研究网络游戏的朋友可以研究下
💻 H
字号:
#ifndef N_HASHNODE_H
#define N_HASHNODE_H
//------------------------------------------------------------------------------
/**
    @brief A node element in a nHashList.

    @author
    - RadonLabs GmbH 

    @since
    - 2005.6.30
    @remarks
    - 瘤肯 眠啊 
*/

#include "../ProgramCommon/Define.h"
#include "nstrnode.h"
#include "nhashtable.h"

//------------------------------------------------------------------------------
class nHashNode : public nNode 
{
public:
    /// default constructor
    nHashNode();
    /// constructor with given name
    nHashNode(const char* name);
    /// sets hash table for this node
    void SetHashTable(nHashTable* t);
    /// return next hash node
    nHashNode* GetSucc() const;
    /// return previous hash node
    nHashNode* GetPred() const;
    /// remove this node from list
    void Remove();
    /// get name of the node
    const char* GetName() const;
    /// set name of node
    void SetName(const char* name);

private:
    friend class nHashList;
    nStrNode str_node;
    nHashTable *h_table;
};

//------------------------------------------------------------------------------
/**
*/
inline
nHashNode::nHashNode() :
    str_node((void*)this),
    h_table(0)
{
    // empty
}

//------------------------------------------------------------------------------
/**
*/
inline
nHashNode::nHashNode(const char* name) :
    str_node(name, (void*) this),
    h_table(0)
{
    // empty
}

//------------------------------------------------------------------------------
/**
*/
inline
void 
nHashNode::SetHashTable(nHashTable* t)
{
    // t can be 0!
    this->h_table = t;
}

//------------------------------------------------------------------------------
/**
*/
inline
nHashNode*
nHashNode::GetSucc() const
{
    return (nHashNode*) nNode::GetSucc();
}

//------------------------------------------------------------------------------
/**
*/
inline
nHashNode*
nHashNode::GetPred() const
{
    return (nHashNode *) nNode::GetPred();
}

//------------------------------------------------------------------------------
/**
*/
inline
void
nHashNode::Remove()
{
    this->str_node.Remove();
    nNode::Remove();
    this->h_table = 0;
}

//------------------------------------------------------------------------------
/**
*/
inline
const char*
nHashNode::GetName() const
{
    return this->str_node.GetName();
}

//------------------------------------------------------------------------------
/**
*/
inline
void 
nHashNode::SetName(const char* name) 
{
    if (this->IsLinked()) 
    {
        n_assert(this->h_table);
        this->str_node.Remove();
        this->str_node.SetName(name);
        this->h_table->Add(&(this->str_node));
    } 
    else 
    {
        this->str_node.SetName(name);
    }
}

//------------------------------------------------------------------------------
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -