1 Star 0 Fork 0

snow-boy/visualgo-sort

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
operationstation.cpp 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
1589221904@qq.com 提交于 2016-09-04 20:43 . 可视化排序
#include "operationstation.h"
#include "ui_operationstation.h"
#include "bubblesort.h"
#include "insertsort.h"
#include "mergesort.h"
#include "selectsort.h"
#include "quicksort.h"
#include "heapsort.h"
#include "shellsort.h"
Operationstation::Operationstation(VisualData *pVisualData,
QWidget *parent) :
QDockWidget(parent),
ui(new Ui::Operationstation),
_visual_data(pVisualData)
{
ui->setupUi(this);
setupConnection();
setupAlgo();
}
Operationstation::~Operationstation()
{
delete ui;
}
void Operationstation::setupAlgo()
{
addAlgo(new BubbleSort(this));
addAlgo(new InsertSort(this));
addAlgo(new MergeSort(this));
addAlgo(new SelectSort(this));
addAlgo(new QuickSort(this));
addAlgo(new HeapSort(this));
addAlgo(new ShellSort(this));
}
void Operationstation::addAlgo(IAlgo *algo)
{
ui->comboBox_algo->addItem(algo->name());
ui->comboBox_algo->setCurrentText(algo->name());
_algos[algo->name()] = algo;
algo->setData(_visual_data);
}
void Operationstation::setupConnection()
{
connect(ui->pushButton_init, &QPushButton::clicked, this, [&](){
_visual_data->Init(ui->lineEdit_num_count->text().toInt());
IAlgo *pAlgo = _algos[ui->comboBox_algo->currentText()];
pAlgo->setInterval(ui->lineEdit_interval->text().toInt());
});
connect(ui->pushButton_sort, &QPushButton::clicked, this, [&](){
IAlgo *pAlgo = _algos[ui->comboBox_algo->currentText()];
pAlgo->run();
ui->lineEdit_run_count->setText(QString::number(pAlgo->runTime()));
});
connect(ui->pushButton_reverse, &QPushButton::clicked, this, [&](){
QVector<int> rdata;
QVector<int> &data = _visual_data->GetData();
rdata.reserve(data.size());
for(int i = data.size() - 1; i >= 0; --i){
rdata.append(data[i]);
}
data = rdata;
_visual_data->Refresh();
});
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/softlord/visualgo-sort.git
git@gitee.com:softlord/visualgo-sort.git
softlord
visualgo-sort
visualgo-sort
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385