基本功能函数 BaseFun.h

该博客主要展示了基本功能函数、堆栈功能函数和队列功能函数的代码实现。包含了如GRAPH、LIST等基本功能声明,以及堆栈的插入、出栈等操作,队列的插入、出队等操作,还可根据不同数据类型进行选择。
///////////////////////////
//    //
//  基本功能函数 BaseFun.h   //
//    //
//////////////////////////

void GRAPH();
void LIST();
void STACK();
void QUEUE();
void COMPOSITOR();
void BINTREE();

///////////////////////////
//    //
//   堆栈功能函数   Stack.cpp/ /
//    //
//////////////////////////



#include"Stack.h"
#include"iostream.h"


const int INT =13;
const double FLOAT= 13.33;
const char CHAR ='a';




template<class Type>
void Stack_Push(Stack<Type> &StackOPP)
{
cout<<"请输入要插入的数据项: ";
Type item;
cin>>item;
  StackOPP.Push(item);
}

template<class Type>
void Stack_Pop(Stack<Type> &StackOPP)
{
if(!StackOPP.ISEmpty())
{
   cout<<"出栈数据项: ";
    cout<<StackOPP.Pop()<<endl;
}
else
{
cout<<"堆栈已经为空!"<<endl;
}
}

template<class Type>
void Stack_ISEmpty(Stack<Type> &StackOPP)
{
if(!StackOPP.ISEmpty())
   cout<<"堆栈不空,还有"<<StackOPP.GetNum()<<"数据项!"<<endl;
else
cout<<"堆栈为空!"<<endl;
   
}

template<class Type>
void Stack_GetTop(Stack<Type> &StackOPP)
{
if(!StackOPP.ISEmpty())
  cout<<"栈顶元素为:"<<StackOPP.GetTop()<<endl;
else
  cout<<"堆栈为空!"<<endl;
}

template<class Type>
void Stack_MakeEmpty(Stack<Type> &StackOPP)
{
if(!StackOPP.ISEmpty())
{
StackOPP.MakeEmpty();
cout<<"堆栈已经销毁!"<<endl;
}
else
{
cout<<"销毁失败!"<<endl;
}
}


template<class Type>
void StackINI(Type temp)
{
Stack<Type> StackOPP;

do
{
cout<<"堆栈的操作: "<<endl
<<" 1) 插入堆栈"<<endl
<<" 2) 出栈"<<endl
<<" 3) 堆栈是否为空"<<endl
<<" 4) 得栈顶数据项"<<endl
<<" 5) 销毁堆栈"<<endl
<<" X) 退出堆栈操作"<<endl;
int item;
cin>>item;
switch(item)
{
case 1: Stack_Push(StackOPP); break;
case 2: Stack_Pop(StackOPP);  break;
case 3: Stack_ISEmpty(StackOPP);  break;
case 4: Stack_GetTop(StackOPP); break;
case 5: Stack_MakeEmpty(StackOPP); break;

default: return ;
}

}while(true);


}


void STACK()
{
int item;
cout<<"清选择数据类型: 1) 整型 2) 浮点型 3) 字符型 X) 退出: ";

cin>>item;
switch(item)
{
case 1: StackINI(INT); break; //根据不同的用户需要选择数据类型
case 2: StackINI(FLOAT); break;
case 3: StackINI(CHAR); break;
  default: return ; break;
}
}



///////////////////////////
//    //
//   队列功能函数 Queue.h  //
//    //
//////////////////////////



#include"Queue.h"

const int INT =13;
const double FLOAT= 13.33;
const char CHAR ='a';



template<class Type>
void Queue_Enter(Queue<Type> &QueueOPP)
{
cout<<"请输入要插入队列的数据: ";
Type item;
cin>>item;
QueueOPP.EnQueue(item);
}

template<class Type>
void Queue_Del(Queue<Type> &QueueOPP)
{
  if(!QueueOPP.ISEmpty())
  {
  cout<<"出队数据:"<<QueueOPP.DelQueue()<<endl;
  }
  else
  {
  cout<<"队列已为空!"<<endl;
  }
}

template<class Type>
void Queue_ISEmpty(Queue<Type> &QueueOPP)
{
if(QueueOPP.ISEmpty())
{
cout<<"队列已空!"<<endl;
}
else
{
cout<<"队列不空!"<<endl;
}
}


template<class Type>
void Queue_GetFront(Queue<Type> &QueueOPP)
{
if(!QueueOPP.ISEmpty())
{
cout<<"队头元素为: "<<QueueOPP.GetFront()<<endl;
}
else
{
cout<<"队列已空!"<<endl;
}
}

template<class Type>
void Queue_MakeEmpty(Queue<Type> &QueueOPP)
{
QueueOPP.MakeEmpty();
cout<<"队列清空!"<<endl;
}

template<class Type>
void QueueINI(Type temp)
{
Queue<Type> QueueOPP;

do
{
cout<<"队列的操作: "<<endl
<<" 1) 插入队列"<<endl
<<" 2) 出队"<<endl
<<" 3) 队列是否为空"<<endl
<<" 4) 得队头数据项"<<endl
<<" 5) 销毁队列"<<endl
<<" X) 退出队列操作"<<endl;
int item;
cin>>item;
switch(item)
{
case 1: Queue_Enter(QueueOPP); break;
case 2: Queue_Del(QueueOPP); break;
case 3: Queue_ISEmpty(QueueOPP);  break;
case 4: Queue_GetFront(QueueOPP); break;
case 5: Queue_MakeEmpty(QueueOPP); break;

default: return ;
}

}while(true);


}


void QUEUE()  //根据不同的用户需要选择数据类型
{
int item;
cout<<"清选择数据类型: 1) 整型 2) 浮点型 3) 字符型 X) 退出: ";


cin>>item;
switch(item)
{
case 1: QueueINI(INT); break;   
case 2: QueueINI(FLOAT); break;
case 3: QueueINI(CHAR); break;
  default: return ; break;
}
}
### BaseFun.showModal 的用法 `BaseFun.showModal` 是一种常见的编程方法,通常用于显示模态对话框或弹窗界面。以下是关于其具体用法以及可能的相关实现细节: #### 方法签名 一般情况下,该函数的定义如下所示: ```javascript BaseFun.showModal(options); ``` 参数 `options` 通常是对象形式,包含多个配置项以控制模态窗口的行为和外观。 #### 参数说明 以下是一些常用的选项及其功能描述[^1]: - **title**: 设置模态窗口的标题。 - **content**: 定义要展示的内容,可以是字符串或者 HTML 片段。 - **buttons**: 配置按钮数组,每个按钮可以通过对象指定名称、样式和回调逻辑。 - **width**: 调整模态窗口宽度,默认单位为像素(px)。 - **height**: 调整模态窗口高度。 - **onClose**: 当关闭模态窗口时触发的回调函数。 示例代码片段展示了如何调用此方法并传递必要的参数[^2]: ```javascript BaseFun.showModal({ title: '提示', content: '<p>这是一个测试消息。</p>', buttons: [ { text: '取消', style: 'default' }, { text: '确认', style: 'primary', callback: function() { console.log('用户点击了确认'); }} ], width: 400, height: 200, onClose: function() { console.log('模态窗口已关闭'); } }); ``` #### 返回值 如果成功执行,则返回一个表示当前模态实例的对象;失败则抛出错误信息。通过这个返回值可进一步操作模态框,比如动态更新内容或手动销毁它[^3]。 #### 注意事项 需要注意的是,在实际开发环境中,不同框架下的 API 可能存在差异,因此建议查阅官方文档获取最权威的信息源。此外,某些自定义库可能会扩展基础版本的功能集,增加额外特性支持。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值