📄 adapter.cpp
字号:
// Adapter.cpp: implementation of the Adapter class.
//
//////////////////////////////////////////////////////////////////////
#include "Adapter.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Adapter::Adapter()
{
m_pStack=new Stack;
}
Adapter::Adapter(Stack *p)
{
m_pStack=p;
}
Adapter::~Adapter()
{
if(m_pStack!=NULL)
delete m_pStack;
}
void Adapter::EnQueue(int a)
{
m_pStack->Push(a);
}
int Adapter::DeQueue()
{
if(IsEmpty())
{
return 0;
}
else
{
int value;
int length=m_pStack->GetLength();
int *temp=new int[length];
int i=0;
while(m_pStack->IsEmpty()==false)
{
temp[i++]=m_pStack->Pop();
}
value=temp[i-1];
i=i-2;
for(;i>=0;i--)
m_pStack->Push(temp[i]);
delete temp;
return value;
}
}
bool Adapter::IsEmpty()
{
return m_pStack->IsEmpty();
}
bool Adapter::IsFull()
{
return m_pStack->IsFull();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -