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

📄 mgctclasslist.h

📁 《3D游戏引擎设计》的源码
💻 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 MGCTCLASSLIST_H
#define MGCTCLASSLIST_H

#include "MgcRTLib.h"

// The TClassList class represents a singly linked list with header node.
// The class T is intended to be class data and must have the following
// member functions
//   T::T (const T&);
//   T& T::operator= (const T&)
//   bool T::operator== (const T&) const
//   bool T::operator!= (const T&) const
// 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 MgcTClassList
{
public:
    // construction and destruction
    MgcTClassList ();
    ~MgcTClassList ();

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

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

protected:
    class Node
    {
    public:
        Node (const T& rtValue, Node* pkNext) : m_tValue(rtValue)
        {
            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 "MgcTClassList.inl"

#endif

⌨️ 快捷键说明

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