栈(Stack)
Stack示意图
Stack.cpp
#pragma once
#include "ListStu.cpp"template<typename T>
class Stack
{
public:
void push(const T& tDate);void pop();T& GetTopDate();int GetCount();private:ListStu<T> m_Stack;
};template<typename T>
void Stack<T>::push(const T& tDate)
{m_Stack.HeadInsert(tDate);
}template<typename T>
void Stack<T>::pop()
{m_Stack.DeleteHead();
}template<typename T>
T& Stack<T>::GetTopDate()
{return *(m_Stack.begin());
}template<typename T>
int Stack<T>::GetCount()
{return m_Stack.Size();
}
队列(queue)
queue 示意图
queue.cpp
#pragma once
#include "ListStu.cpp"
template<typename T>
class Queue
{
public:void push(const T& tDate);void pop();T& GetTopDate();int GetCount();private:ListStu<T> m_Queue;
};template<typename T>
void Queue<T>::push(const T& tDate)
{m_Queue.VailInsert(tDate);
}template<typename T>
void Queue<T>::pop()
{m_Queue.DeleteHead();
}template<typename T>
T& Queue<T>::GetTopDate()
{return *(m_Queue.begin());
}template<typename T>
int Queue<T>::GetCount()
{return m_Queue.Size();
}