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

📄 mgctlist.h

📁 3D Game Engine Design Source Code非常棒
💻 H
字号:
// Magic Software, Inc.
// http://www.magic-software.com
// Copyright (c) 2000, All Rights Reserved
//
// Source code from Magic Software is supplied under the terms of a license
// agreement and may not be copied or disclosed except in accordance with the
// terms of that agreement.  The various license agreements may be found at
// the Magic Software web site.  This file is subject to the license
//
// FREE SOURCE CODE
// http://www.magic-software.com/License/free.pdf

#ifndef MGCTLIST_H
#define MGCTLIST_H

#include "MgcRTLib.h"

// The TList class represents a singly linked list with header node.  The
// class T is intended to be native data (int, float, char*, etc.).  All
// list insertions occur at the front of the list.  If the list values were
// dynamically allocated by the application, it is the application's
// responsibility to delete those values.  This can be done by iterating
// over the list using GetFirst/GetNext and explicitly deleting the values.

template <class T>
class MgcTList
{
public:
    // construction and destruction
    MgcTList ();
    ~MgcTList ();

    // element access
    unsigned int GetQuantity () const;
    void Add (T tValue);
    bool Remove (T tValue);
    bool RemoveFront (T& rtValue);
    void RemoveAll ();

    // linear traversal of list
    bool GetFirst (T& rtValue);
    bool GetNext (T& rtValue);

protected:
    class Node
    {
    public:
        Node (T tValue, Node* pkNext)
        {
            m_tValue = tValue;
            m_pkNext = pkNext;
        }

        ~Node ()
        {
            delete m_pkNext;
        }

        T m_tValue;
        Node* m_pkNext;
    };

    unsigned int m_uiQuantity;
    Node* m_pkFront;

    // iterator for traversal
    Node* m_pkIterator;
};

#include "MgcTList.inl"

#endif

⌨️ 快捷键说明

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