QT-模拟电梯上下楼
QT-模拟电梯上下楼
- 一、演示效果
- 二、核心程序
- 三、下载链接
一、演示效果
二、核心程序
#include "ElevatorController.h"
#include <QGridLayout>
#include <QLabel>
#include <QGroupBox>
#include <QGridLayout>
#include <QPushButton>
#include <QDebug>
#include <QChar>
#include <QGuiApplication>
#include <QScreen>
#include <queue>ElevatorController::ElevatorController(Ui::MainWindow* u, int numElevators, int numFloors)
{// create/populate ui ComboBox elementsui = u;QStringList evs;for (int elevator = 1; elevator <= numElevators; ++elevator){evs << QString("Elevator: %1").arg(elevator);}ui->comboElevatorBox->addItems(evs);connect(ui->comboElevatorBox, qOverload<int>(&QComboBox::currentIndexChanged), this, &ElevatorController::elevatorSelected);evs.clear();for (int floorc = 1; floorc <= numFloors; ++floorc){evs << QString("Floor: %1").arg(floorc);}ui->comboFloorBox->addItems(evs);// buttons connectedconnect(ui->pushElevatorButton, &QPushButton::clicked, this, &ElevatorController::buttonElevatorSubmit);connect(ui->pushHelpButton, &QPushButton::clicked, this, &ElevatorController::buttonElevatorHelp);connect(ui->pushPlaceButton, &QPushButton::clicked, this, &ElevatorController::buttonPlaceOnFloor);connect(ui->pushMoveButton, &QPushButton::clicked, this, &ElevatorController::buttonMoveToElevator);connect(ui->pushAdd10FloorButton, &QPushButton::clicked, this, &ElevatorController::add10ToEachFloor);connect(ui->pushBuildingEmergencyButton, &QPushButton::clicked, this, &ElevatorController::triggerBuildingEmergency);connect(ui->pushEmergencyResetAllButton, &QPushButton::clicked, this, &ElevatorController::resetAllElevatorsEmergency);connect(ui->pushLeaveButton, &QPushButton::clicked, this, &ElevatorController::buttonLeaveElevator);// spin box buttons:connect(ui->spinBoxMove, qOverload<int>(&QSpinBox::valueChanged), this, &ElevatorController::moveComboBoxChange);connect(ui->spinBoxLeaveElevator, qOverload<int>(&QSpinBox::valueChanged), this, &ElevatorController::moveLeaveElevatorBoxChange);// combo box change:connect(ui->comboFloorBox, qOverload<int>(&QComboBox::currentIndexChanged), this, &ElevatorController::floorSelected);// keep in mind: "setWidget" and "setLayout" etc add to the ui tree, memory managed by Qt not Me :-)// widget to hold the grid layoutQWidget* elevatorWidget = new QWidget();ui->elevatorScrollArea->setWidget(elevatorWidget); // Set the content widget of the ElevatorController// QGridLayout* elevatorGridLayoutelevatorGridLayout = new QGridLayout(elevatorWidget);elevatorWidget->setLayout(elevatorGridLayout);// Add buttons or labels to the grid layout based on dimensionsfor (int floor = numFloors - 1; floor >= 0; floor--){for (int elevator = 1; elevator <= numElevators; ++elevator){// Create a QLabel for each positionQLabel* cube = new QLabel;cube->setText(" ");cube->setFixedSize(CUBE_SIZE, CUBE_SIZE);QString color = "gray";if(numFloors - floor - 1 == 0) // all ev's start at 0color = "red";cube->setStyleSheet(QString("background-color: %1").arg(color));// Add the widget to the grid layout at the specified positionelevatorGridLayout->addWidget(cube, floor, elevator);}Floor* flr = new Floor(floor + 1); // floor class is a part of the UI// Connect the signals from the Floor to the slots in the ElevatorControllerconnect(flr, &Floor::upButtonPressed, this, &ElevatorController::buttonPressedUp);connect(flr, &Floor::downButtonPressed, this, &ElevatorController::buttonPressedDown);// adds the floor at the start (far left)elevatorGridLayout->addWidget(flr, numFloors - floor - 1, 0);floors.push_back(flr);}// create elevatorsfor (int elevator = 1; elevator <= numElevators; ++elevator){Elevator* ev = new Elevator(elevator);elevators.push_back(ev);updateDisplays();// should be connecting slot in elevator to signals in elevator controllerconnect(this, &ElevatorController::resetEmergency, ev, &Elevator::resetEmergencyInElevator);connect(this, &ElevatorController::sendRequestToElevator, ev, &Elevator::pressButton);connect(this, &ElevatorController::helpButton, ev, &Elevator::helpButtonPressed);connect(this, &ElevatorController::moveElevatorToFloor, ev, &Elevator::moveTofloor);connect(this, &ElevatorController::removeElevatorPassengers, ev, &Elevator::removePassengers);connect(this, &ElevatorController::addElevatorPassengers, ev, &Elevator::addPassengers);connect(this, &ElevatorController::buildingEmergency, ev, &Elevator::emergency);connect(this, &ElevatorController::pressButton, ev, &Elevator::pressButton);connect(this, &ElevatorController::unpressButton, ev, &Elevator::unpressButton);connect(ev, &Elevator::floorChanged, this, &ElevatorController::elevatorFloorChanged);connect(ev, &Elevator::doorOpened, this, &ElevatorController::doorOpened);connect(ev, &Elevator::doorClosed, this, &ElevatorController::doorClosed);connect(ev, &Elevator::doorBlocked, this, &ElevatorController::doorBlocked);connect(ev, &Elevator::overloaded, this, &ElevatorController::overloaded);connect(ev, &Elevator::emergencyOnBoard, this, &ElevatorController::emergency);connect(ev, &Elevator::updateDisplays, this, &ElevatorController::updateDisplays);QThread* evThread = new QThread;ev->moveToThread(evThread);evThread->start();threads.push_back(evThread);}requestScanTimer = new QTimer(this);connect(requestScanTimer, &QTimer::timeout, this, &ElevatorController::scanRequestTree);requestScanTimer->start(SCAN_REQUEST_TREE_SECS); // Scan backup request tree every 15 seconds, in case overflowqDebug() << "Elevator Controller Initialized";
}ElevatorController::~ElevatorController() // clean up floors
{for(int i = 0; i < floors.size(); i++)delete floors[i];requestScanTimer->stop();delete requestScanTimer;for(int i = 0; i < threads.size(); i++){threads[i]->quit();threads[i]->wait();delete threads[i];}
}// --- UI INPUT & CALLBACK FUNCS ---void ElevatorController::handleScreenResized(int w, int h)
{int bufferGap = 10;ui->elevatorScrollArea->resize(w - ui->InputTerminal->width() - 3*bufferGap, h - bufferGap*6);qDebug() << "Reinit scale -- uiWidth: " << w << " uiHeight: " << h;ui->InputTerminal->move(ui->elevatorScrollArea->x() + w - ui->InputTerminal->width() - 2*bufferGap, ui->InputTerminal->y());ui->InputTerminal->resize(ui->InputTerminal->width(), h - bufferGap*5);
}void ElevatorController::updateDisplays()
{int ev = ui->comboElevatorBox->currentText().remove(0, 10).toInt(); // stored from 0QString buttonList = "";const std::set<int>& blist = elevators[ev - 1]->getButtonsPressed();for(const int& a : blist){buttonList += QString::number(a) + " ";}ui->textBrowserButtonsPressed->setPlainText(buttonList);const int flr = ui->comboFloorBox->currentText().remove(0, 7).toInt();ui->passengerOnFloorNumber->display(floors[flr - 1]->peopleOnFloor());ui->passengerNumber->display(elevators[ev - 1]->numPassengers());
}void ElevatorController::buttonElevatorSubmit()
{// get the int values from the combo boxesint ev = ui->comboElevatorBox->currentText().remove(0, 10).toInt();int fb = ui->comboFloorBox->currentText().remove(0, 7).toInt();qDebug() << "BUTTON - elevator submit pressed elev: " << ev << " floor button: " << fb;if(elevators[ev - 1]->getButtonsPressed().count(fb) > 0)emit unpressButton(ev, fb);elseemit pressButton(ev, fb);
}void ElevatorController::buttonPlaceOnFloor()
{qDebug() << "BUTTON buttonPlaceOnFloor.... spawning ppl on floor";const int flr = ui->comboFloorBox->currentText().remove(0, 7).toInt() - 1;floors[flr]->addPeople(ui->spinBoxPlace->value());ui->passengerOnFloorNumber->display(floors[flr]->peopleOnFloor());ui->spinBoxPlace->setValue(0);
}void ElevatorController::buttonMoveToElevator()
{qDebug() << "BUTTON: buttonMoveToElevator.... moving ppl ";const int flr = ui->comboFloorBox->currentText().remove(0, 7).toInt();int evweak = ui->comboElevatorBox->currentText().remove(0, 10).toInt() - 1; // if this is on the same floor its usedElevator* availableEv = nullptr;Elevator* weakEv = nullptr;bool potentialEvPassed = false;if(elevators[evweak]->currentFloor() == flr) // soft lock the current elevatorweakEv = elevators[evweak];for(Elevator* ev : elevators) // unless theres one that makes more sense{if(ev->currentFloor() == flr && ev->currentState() == Elevator::DoorsOpen){availableEv = ev;if(weakEv == ev && weakEv != nullptr){availableEv = weakEv;break;}}}if(!availableEv)return;const int val = ui->spinBoxMove->value(); //usr inputui->spinBoxMove->setValue(0);floors[flr - 1]->removePeople(val);// emit addElevatorPassengers(availableEv->getId(), flr, val);elevators[availableEv->getId() - 1]->addPassengers(availableEv->getId(), flr, val);// just set the combo box option to the one that people were put into automatically... for visibilityui->comboElevatorBox->setCurrentIndex(availableEv->getId() - 1);// update the floor on people displayupdateDisplays();
}void ElevatorController::buttonLeaveElevator()
{int ev = ui->comboElevatorBox->currentText().remove(0, 10).toInt();qDebug() << "BUTTON: buttonLeaveElevator.... moving ppl EV: " << ev << " FLR: " << elevators[ev - 1]->currentFloor();const int val = ui->spinBoxLeaveElevator->value(); //usr inputui->spinBoxLeaveElevator->setValue(0);emit removeElevatorPassengers(elevators[ev - 1]->getId(), elevators[ev - 1]->currentFloor(), val);floors[elevators[ev - 1]->currentFloor() - 1]->addPeople(val);// just set the combo box option to the one that people were put into automatically... for visibilityui->comboFloorBox->setCurrentIndex(elevators[ev - 1]->currentFloor() - 1);ui->passengerNumber->display(elevators[ev-1]->numPassengers());updateDisplays();const int flr = ui->comboFloorBox->currentText().remove(0, 7).toInt();if(elevators[ev - 1]->currentFloor() != flr)return;// update the floor on people displayui->passengerOnFloorNumber->display(floors[elevators[ev - 1]->currentFloor()]->peopleOnFloor());updateDisplays();controlMoveButtonActivated();
}void ElevatorController::add10ToEachFloor()
{qDebug() << "BUTTON add 10 To Each Floor.... spawning 10 ppl on each floor!";for(Floor* f : floors){f->addPeople(10);}const int flr = ui->comboFloorBox->currentText().remove(0, 7).toInt() - 1;ui->passengerOnFloorNumber->display(floors[flr]->peopleOnFloor());ui->spinBoxPlace->setValue(0);
}void ElevatorController::triggerBuildingEmergency()
{emit buildingEmergency(-1);
}void ElevatorController::buttonElevatorHelp()
{int ev = ui->comboElevatorBox->currentText().remove(0, 10).toInt();emit helpButton(ev);updateDisplays();
}void ElevatorController::resetAllElevatorsEmergency()
{emit resetEmergency(-1);updateDisplays();
}void ElevatorController::controlMoveButtonActivated(Elevator* availableEv)
{// we want to check if there is an elevator on the floor in door open state// & set the control button to active or not based on it//qDebug() << "BUTTON ACTIVATE: Activating/Deactivating the Move Button to allow moving ppl ";const int flr = ui->comboFloorBox->currentText().remove(0, 7).toInt();const int evNum = ui->comboElevatorBox->currentText().remove(0, 10).toInt();for(Elevator* ev : elevators){if(availableEv != nullptr)break;if(ev->currentFloor() == flr && ev->currentState() == Elevator::DoorsOpen || elevators[evNum - 1]->currentState() == Elevator::Overload)availableEv = ev;}if(elevators[evNum - 1]->currentState() == Elevator::DoorsOpen || elevators[evNum - 1]->currentState() == Elevator::Overload || elevators[evNum - 1]->currentState() == Elevator::Emergency)ui->pushLeaveButton->setEnabled(true);else if(ui->pushLeaveButton->isEnabled())ui->pushLeaveButton->setEnabled(false);if(availableEv != nullptr && flr == availableEv->currentFloor())ui->pushMoveButton->setEnabled(true);else if(ui->pushMoveButton->isEnabled())ui->pushMoveButton->setEnabled(false);
}void ElevatorController::elevatorSelected(int index)
{ui->passengerNumber->display(elevators[index]->numPassengers());updateDisplays();controlMoveButtonActivated(elevators[index]);qDebug() << "COMBO BOX: Elevator selected. Elevator: " << index;
}void ElevatorController::floorSelected(int index)
{// update the segment display for passangersui->passengerOnFloorNumber->display(floors[index]->peopleOnFloor());qDebug() << "COMBO BOX: Floor selected. Floor: " << index;ui->spinBoxMove->setValue(0); // wipe this since its different # pplcontrolMoveButtonActivated(); // potentially changes move buttons state
}void ElevatorController::moveComboBoxChange(int index)
{if(index > ui->passengerOnFloorNumber->value()){ui->spinBoxMove->setValue(ui->passengerOnFloorNumber->value());}
}void ElevatorController::moveLeaveElevatorBoxChange(int index)
{if(index > ui->passengerNumber->value()){ui->spinBoxLeaveElevator->setValue(ui->passengerNumber->value());}
}// --- UI UPDATE / EV SOCKET FUNCS ---void ElevatorController::elevatorFloorChanged(int floor, int ev, bool up)
{// each elevator emits this when the moved to new floorev -= 1;qDebug() << "EV signal: Elevator floor changed, floor: " << floor << " elevator: " << ev << " up dir: " << up;qDebug() << "(X, Y) : " << floor << ", " << (ev + 1);const int x = floors.size() - floor; // as the floors decrease, x increases (flr increase, x decrease)const int y = ev + 1;QLayoutItem* layoutItem = elevatorGridLayout->itemAtPosition(x, y); // check if we are looking at a valid evif (!layoutItem){qDebug() << "No layout item at this position.";return;}QWidget* widget = layoutItem->widget();if (!widget){qDebug() << "No widget at this position.";return;}const QMetaObject* metaObject = widget->metaObject();QString widgetType = QString::fromUtf8(metaObject->className());if (widgetType == "QLabel"){QLabel* square = qobject_cast<QLabel*>(widget);QLabel* squarePrev;squarePrev = qobject_cast<QLabel*>(elevatorGridLayout->itemAtPosition((x - 1 + floors.size()) % floors.size(), y)->widget());squarePrev->setStyleSheet(QString("background-color: gray;"));squarePrev = qobject_cast<QLabel*>(elevatorGridLayout->itemAtPosition((x + 1)%floors.size(), y)->widget());squarePrev->setStyleSheet(QString("background-color: gray;"));if(elevators[ev]->currentState() == Elevator::Emergency)square->setStyleSheet("background-color: yellow;");elsesquare->setStyleSheet("background-color: red;");}qDebug() << "Widget type: " << widgetType;
}void ElevatorController::doorOpened(int flr, int ev)
{// a door has openedqDebug() << "EV signal: Door opened! Elevator: " << ev;const int x = floors.size() - flr; // as the floors decrease, x increases (flr increase, x decrease)const int y = ev;if (!elevatorGridLayout->itemAtPosition(x, y)){qDebug() << "doorOpened(): No Item at position: (" << x << ", " << y << ")";return;}QWidget* wdg = elevatorGridLayout->itemAtPosition(x, y)->widget();if(QString::fromUtf8(wdg->metaObject()->className()) != "QLabel"){qDebug() << "doorOpened(): Item at position: (" << x << ", " << y << ") " << "is a: " << QString::fromUtf8(wdg->metaObject()->className());return;}QLabel* squarePrev = qobject_cast<QLabel*>(wdg);squarePrev->setStyleSheet(QString("background-color: green;"));controlMoveButtonActivated(elevators[ev - 1]);updateDisplays();
}void ElevatorController::doorClosed(int flr, int ev)
{// a door has closedqDebug() << "EV signal: Door closed!! Elevator: " << ev;const int x = floors.size() - flr; // as the floors decrease, x increases (flr increase, x decrease)const int y = ev;if (!elevatorGridLayout->itemAtPosition(x, y)){qDebug() << "doorClosed(): No Item at position: (" << x << ", " << y << ")";return;}QWidget* wdg = elevatorGridLayout->itemAtPosition(x, y)->widget();if(QString::fromUtf8(wdg->metaObject()->className()) != "QLabel"){qDebug() << "doorClosed(): Item at position: (" << x << ", " << y << ") " << "is a: " << QString::fromUtf8(wdg->metaObject()->className());return;}QLabel* squarePrev = qobject_cast<QLabel*>(wdg);squarePrev->setStyleSheet(QString("background-color: purple;"));
}void ElevatorController::doorBlocked(int flr, int ev)
{// a door has closedqDebug() << "EV signal: Alert! Door blocked... reopening door... Elevator: " << ev;const int x = floors.size() - flr; // as the floors decrease, x increases (flr increase, x decrease)const int y = ev;if (!elevatorGridLayout->itemAtPosition(x, y)){qDebug() << "doorBlocked(): No Item at position: (" << x << ", " << y << ")";return;}QWidget* wdg = elevatorGridLayout->itemAtPosition(x, y)->widget();if(QString::fromUtf8(wdg->metaObject()->className()) != "QLabel"){qDebug() << "doorBlocked(): Item at position: (" << x << ", " << y << ") " << "is a: " << QString::fromUtf8(wdg->metaObject()->className());return;}QLabel* squarePrev = qobject_cast<QLabel*>(wdg);squarePrev->setStyleSheet(QString("background-color: blue;"));
}void ElevatorController::overloaded(int flr, int ev)
{// a door has closedqDebug() << "EV signal: Elevator overloaded!! Elevator: " << ev;const int x = floors.size() - flr; // as the floors decrease, x increases (flr increase, x decrease)const int y = ev;if (!elevatorGridLayout->itemAtPosition(x, y)){qDebug() << "doorClosed(): No Item at position: (" << x << ", " << y << ")";return;}QWidget* wdg = elevatorGridLayout->itemAtPosition(x, y)->widget();if(QString::fromUtf8(wdg->metaObject()->className()) != "QLabel"){qDebug() << "overloaded(): Item at position: (" << x << ", " << y << ") " << "is a: " << QString::fromUtf8(wdg->metaObject()->className());return;}QLabel* squarePrev = qobject_cast<QLabel*>(wdg);squarePrev->setStyleSheet(QString("background-color: orange;"));
}void ElevatorController::emergency(int flr, int ev)
{// a door has closedqDebug() << "EV signal: Elevator emergency!! Elevator: " << ev;if(flr != SAFE_FLOOR)return;QLayoutItem* layoutItem = elevatorGridLayout->itemAtPosition(floors.size() - SAFE_FLOOR, ev); // check if we are looking at a valid evif (!layoutItem){qDebug() << "No layout item at this position.";return;}QWidget* widget = layoutItem->widget();if (!widget){qDebug() << "No widget at this position.";return;}const QMetaObject* metaObject = widget->metaObject();QString widgetType = QString::fromUtf8(metaObject->className());if (widgetType == "QLabel"){QLabel* square = qobject_cast<QLabel*>(widget);if(elevators[ev - 1]->currentState() == Elevator::Idle)square->setStyleSheet(QString("background-color: red;"));elsesquare->setStyleSheet(QString("background-color: yellow;"));} qDebug() << "Widget type: " << widgetType;
}// --- EV REQUEST FUNCS ---void ElevatorController::buttonPressedUp(int floor)
{// an up button on a floor has been pressedqDebug() << "Floor signal: Floor up button pressed: " << floor;handleFlrPressed(FloorDirection(floor, true));
}void ElevatorController::buttonPressedDown(int floor)
{// a down button on a floor has been pressedqDebug() << "Floor signal: Floor down button pressed: " << floor;handleFlrPressed(FloorDirection(floor, false));
}void ElevatorController::handleFlrPressed(FloorDirection fd)
{// maybe this had some use in some implementtation? ev->getNumFloorsReserved();Elevator* bestElevator = nullptr;Elevator* idleEv = nullptr; // lower priofor(Elevator* pEv : elevators){if(fd.up && pEv->lastDirMovingUp() && fd.num >= pEv->currentFloor()){bestElevator = pEv;break;}if(!fd.up && !pEv->lastDirMovingUp() && fd.num <= pEv->currentFloor()){bestElevator = pEv;break;}if(pEv->currentState() == Elevator::Idle)idleEv = pEv;}if(bestElevator)emit moveElevatorToFloor(bestElevator->getId(), fd.num);else if(idleEv)emit moveElevatorToFloor(idleEv->getId(), fd.num);elseearliestRequestTree.push(fd);
}void ElevatorController::scanRequestTree()
{// happen on a timer, scan request tree realloc elevators if freeif(AGGRESSIVE_LOGGING && !earliestRequestTree.empty())qDebug() << "scanRequestTree-> Request floor: " << earliestRequestTree.top().num << " up: " << earliestRequestTree.top().up; // << i++;if (earliestRequestTree.empty()){return;}FloorDirection fd = earliestRequestTree.top();earliestRequestTree.pop();handleFlrPressed(FloorDirection(fd.num, fd.up));
}
xt
三、下载链接
https://download.csdn.net/download/u013083044/88861542
相关文章:
![](https://img-blog.csdnimg.cn/direct/93b07d728c0d4a6da36541b7500d636f.png)
QT-模拟电梯上下楼
QT-模拟电梯上下楼 一、演示效果二、核心程序三、下载链接 一、演示效果 二、核心程序 #include "ElevatorController.h" #include <QGridLayout> #include <QLabel> #include <QGroupBox> #include <QGridLayout> #include <QPushButto…...
![](https://img-blog.csdnimg.cn/img_convert/d1384d89e5a6875b827b3acdade4bf2e.png)
基于springboot+vue的桂林旅游景点导游平台(前后端分离)
博主主页:猫头鹰源码 博主简介:Java领域优质创作者、CSDN博客专家、阿里云专家博主、公司架构师、全网粉丝5万、专注Java技术领域和毕业设计项目实战,欢迎高校老师\讲师\同行交流合作 主要内容:毕业设计(Javaweb项目|小程序|Pyt…...
![](https://img-blog.csdnimg.cn/direct/7d2378bbf8dd47049ef8516e816724c0.png#pic_center)
设计模式四:适配器模式
1、适配器模式的理解 适配器模式可以理解为有两个现成的类Adaptee和Target,它们两个是不能动的,要求必须使用B这个类来实现一个功能,但是A的内容是能复用的,这个时候我们需要编写一个转换器 适配器模式 Adaptee:被适…...
![](https://csdnimg.cn/release/blog_editor_html/release2.3.6/ckeditor/plugins/CsdnLink/icons/icon-default.png?t=N7T8)
【AI应用】SoraWebui——在线文生视频工具
SoraWebui 是一个开源项目,允许用户使用 OpenAI 的 Sora 模型使用文本在线生成视频,从而简化视频创建,并具有轻松的一键网站部署功能 在 Vercel 上部署 1. 克隆项目 git clone gitgithub.com:SoraWebui/SoraWebui.git 2. 安装依赖 cd So…...
![](https://csdnimg.cn/release/blog_editor_html/release2.3.6/ckeditor/plugins/CsdnLink/icons/icon-default.png?t=N7T8)
电路设计(27)——交通信号灯的multisim仿真
1.功能要求 使用数字芯片设计一款交通信号灯,使得: 主干道的绿灯时间为60S,红灯时间为45S 次干道的红灯时间为60S,绿灯时间为45S 主、次干道,绿灯的最后5S内,黄灯闪烁 使用数码管显示各自的倒计时时间。 按…...
![](https://www.ngui.cc/images/no-images.jpg)
Python Sanic 异步 Web 框架
Sanic 是一个基于 Python 3.6 的异步 Web 框架,它使用了 Python 的 async/await 语法来实现高效的非阻塞 IO 操作。 Sanic 的主要作用是提供一个快速、轻量级的方式来构建异步 Web 服务,适用于处理大量并发请求的场景。 以下是一个简单的示例代码&…...
![](https://img-blog.csdnimg.cn/img_convert/78c988b706dd5fafe2446d381fdb08d8.gif)
滚雪球学Java(70):深入理解Java中的PriorityQueue底层实现与源码分析
咦咦咦,各位小可爱,我是你们的好伙伴——bug菌,今天又来给大家普及Java SE相关知识点了,别躲起来啊,听我讲干货还不快点赞,赞多了我就有动力讲得更嗨啦!所以呀,养成先点赞后阅读的好…...
![](https://www.ngui.cc/images/no-images.jpg)
李宏毅2023机器学习作业1--homework1
一、前期准备 下载训练数据和测试数据 # dropbox link !wget -O covid_train.csv https://www.dropbox.com/s/lmy1riadzoy0ahw/covid.train.csv?dl0 !wget -O covid_test.csv https://www.dropbox.com/s/zalbw42lu4nmhr2/covid.test.csv?dl0 导入包 # Numerical Operation…...
![](https://www.ngui.cc/images/no-images.jpg)
Mysql的SQL调优-面试
面试SQL优化的具体操作: 1、在表中建立索引,优先考虑where、group by使用到的字段。 2、尽量避免使用select *,返回无用的字段会降低查询效率。错误如下: SELECT * FROM table 优化方式:使用具体的字段代替 *…...
![](https://img-blog.csdnimg.cn/direct/fcc7ec111d27478d958aec1f44505bcd.png)
Unity 2021.3发布WebGL设置以及nginx的配置
使用unity2021.3发布webgl 使用Unity制作好项目之后建议进行代码清理,这样会即将不用的命名空间去除,不然一会在发布的时候有些命名空间webgl会报错。 平台转换 将平台设置为webgl 设置色彩空间压缩方式 Compression Format 设置为DisabledDecompre…...
![](https://img-blog.csdnimg.cn/direct/745f26a9a380432395cf8f3c0eae7fb1.png)
【鸿蒙 HarmonyOS 4.0】数据持久化
一、数据持久化介绍 数据持久化是将内存数据(内存是临时的存储空间),通过文件或数据库的形式保存在设备中。 HarmonyOS提供两种数据持久化方案: 1.1、用户首选项(Preferences): 通常用于保存应用的配置信息。数据通…...
![](https://www.ngui.cc/images/no-images.jpg)
mysql mgr集群多主部署
一、前言 mgr多主集群是将集群中的所有节点都设为可写,减轻了单主节点的写压力,从而提高了mysql的写入性能 二、部署 基础部署与mgr集群单主部署一致,只是在创建mgr集群时有所不同 基础部署参考:mysql mgr集群部署-CSDN博客 设置…...
![](https://img-blog.csdnimg.cn/3a01dc60e62c415b812015851343f1c0.png#pic_center)
【开源】JAVA+Vue.js实现医院门诊预约挂号系统
目录 一、摘要1.1 项目介绍1.2 项目录屏 二、功能模块2.1 功能性需求2.1.1 数据中心模块2.1.2 科室医生档案模块2.1.3 预约挂号模块2.1.4 医院时政模块 2.2 可行性分析2.2.1 可靠性2.2.2 易用性2.2.3 维护性 三、数据库设计3.1 用户表3.2 科室档案表3.3 医生档案表3.4 医生放号…...
![](https://img-blog.csdnimg.cn/direct/0f81360553fe473f9c7bcaf5e3aa21e9.png#pic_center)
《图解设计模式》笔记(一)适应设计模式
图灵社区 - 图解设计模式 - 随书下载 评论区 雨帆 2017-01-11 16:14:04 对于设计模式,我个人认为,其实代码和设计原则才是最好的老师。理解了 SOLID,如何 SOLID,自然而然地就用起来设计模式了。Github 上有一个 tdd-training&…...
![](https://img-blog.csdnimg.cn/direct/04fa76db49bc4d068bd4cf37ee03856a.png)
图文说明Linux云服务器如何更改实例镜像
一、应用场景举例 在学习Linux的vim时,我们难免要对vim进行一些配置,这里我们提供一个vim插件的安装包: curl -sLf https://gitee.com/HGtz2222/VimForCpp/raw/master/install.sh -o./install.sh && bash ./install.sh 但是此安装包…...
![](https://img-blog.csdnimg.cn/20210109141525666.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzMyMjM4NjEx,size_16,color_FFFFFF,t_70)
RabbitMQ学习整理————基于RabbitMQ实现RPC
基于RabbitMQ实现RPC 前言什么是RPCRabbitMQ如何实现RPCRPC简单示例通过Spring AMQP实现RPC 前言 这边参考了RabbitMQ的官网,想整理一篇关于RabbitMQ实现RPC调用的博客,打算把两种实现RPC调用的都整理一下,一个是使用官方提供的一个Java cli…...
![](https://img-blog.csdnimg.cn/direct/c99b1b8a9493499f8fa3bbce63569c18.png)
Linux-基础知识(黑马学习笔记)
硬件和软件 我们所熟知的计算机是由:硬件和软件组成。 硬件:计算机系统中电子,机械和光电元件等组成的各种物理装置的总称。 软件:是用户和计算机硬件之间的接口和桥梁,用户通过软件与计算机进行交流。 而操作系统…...
![](https://img-blog.csdnimg.cn/img_convert/38c081dbe62aae2a8cc9056272b468ab.png)
SpringBoot项目启动报java.nio.charset.MalformedInputException Input length = 1解决方案
报错详情 SpringBoot启动报错java.nio.charset.MalformedInputException: Input length 1 报错原因 出现这个的原因,就是解析yml文件时,中文字符集不是utf-8的原因,这是maven在项目编译时,默认字符集编码是GBK。 解决方式 检…...
![](https://img-blog.csdnimg.cn/direct/cfd1d8a3e37a465ea6965f4874735e4b.png)
【Unity2019.4.35f1】配置JDK、NDK、SDK、Gradle
目录 JDK NDK SDK 环境变量 Gradle JDK JDK:jdk-1.8版本Java Downloads | Oracle 下载要登录,搜索JDK下载公用账号:Oracle官网 JDK下载 注册登录公共账号和密码_oracle下载账号-CSDN博客 路径:C:\Program Files\Java\jd…...
![](https://www.ngui.cc/images/no-images.jpg)
MySQL中的高级查询
通过条件查询可以查询到符合条件的数据,但如同要实现对字段的值进行计算、根据一个或多个字段对查询结果进行分组等操作时,就需要使用更高级的查询,MySQL提供了聚合函数、分组查询、排序查询、限量查询、内置函数以实现更复杂的查询需求。接下…...
![](https://www.ngui.cc/images/no-images.jpg)
leetcode383赎金信
用字符数组ch来记录magazine每个字母出现频率,用ransomNote的字母减去字符数组ch对应的字符出现频率,如果该字符对应的频率小于0,则不够,无法组成ransomNote! class Solution { public:bool canConstruct(string rans…...
![](https://img-blog.csdnimg.cn/direct/4feb89973ba24add86d3885f79ab2de0.png)
【Unity3D】ASE制作天空盒
找到官方shader并分析 下载对应资源包找到\DefaultResourcesExtra\Skybox-Cubed.shader找到\CGIncludes\UnityCG.cginc观察变量, 观察tag, 观察代码 需要注意的内容 ASE要处理的内容 核心修改 添加一个Custom Expression节点 code内容为: return DecodeHDR(In0, In1);outp…...
![](https://img-blog.csdnimg.cn/direct/911a6f63d1c5499ebde51c8ff799266c.png)
MyBatisPlus常用注解
目录 一、TableName 二、TableId 三、TableField 四、TableLogic 一、TableName 在使用MyBatis-Plus实现基本的CRUD时,我们并没有指定要操作的表,只是在Mapper接口继承BaseMapper时,设置了泛型User,而操作的表为user表 由此得出…...
![](https://www.ngui.cc/images/no-images.jpg)
Putty中运行matlab文件
首先使用命令 cd /home/ya/CodeTest/Matlab进入路径:到Matlab文件夹下 然后键入matlab,进入matlab环境,如果main.m文件在Matlab文件夹下,直接键入main即可运行该文件。细节代码如下: Unable to use key file "y…...
![](https://img-blog.csdnimg.cn/direct/c3b0a9f181d84fbfb66244147908fad6.png)
ES6 | (一)ES6 新特性(上) | 尚硅谷Web前端ES6教程
文章目录 📚ES6新特性📚let关键字📚const关键字📚变量的解构赋值📚模板字符串📚简化对象写法📚箭头函数📚函数参数默认值设定📚rest参数📚spread扩展运算符&a…...
![](https://img-blog.csdnimg.cn/direct/a97ccad548e6481c97833b5c623b75d4.png)
生产环境下,应用模式部署flink任务,通过hdfs提交
前言 通过通过yarn.provided.lib.dirs配置选项指定位置,将flink的依赖上传到hdfs文件管理系统 1. 实践 (1)生产集群为cdh集群,从cm上下载配置文件,设置环境 export HADOOP_CONF_DIR/home/conf/auth export HADOOP_CL…...
![](https://img-blog.csdnimg.cn/direct/62e73a30ca574bf1aac93cd3e9d309cc.png)
【lesson59】线程池问题解答和读者写者问题
文章目录 线程池问题解答什么是单例模式什么是设计模式单例模式的特点饿汉和懒汉模式的理解STL中的容器是否是线程安全的?智能指针是否是线程安全的?其他常见的各种锁 读者写者问题 线程池问题解答 什么是单例模式 单例模式是一种 “经典的, 常用的, 常考的” 设…...
![](https://www.ngui.cc/images/no-images.jpg)
【LeetCode每日一题】单调栈316去除重复字母
题目:去除重复字母 给你一个字符串 s ,请你去除字符串中重复的字母,使得每个字母只出现一次。需保证 返回结果的字典序最小(要求不能打乱其他字符的相对位置)。 示例 1: 输入:s “bcabc” 输…...
![](https://img-blog.csdnimg.cn/direct/08fc05b6034f4cadab1ae2d8d790c418.png)
【Git】Gitbash使用ssh 上传本地项目到github
SSH Git上传项目到GitHub(图文)_git ssh上传github-CSDN博客 前提 ssh-keygen -t rsa -C “自己的github电子邮箱” 生成密钥,公钥保存到自己的github的ssh里 1.先创建一个仓库,复制ssh地址 git init git add . git commit -m …...
![](https://img-blog.csdnimg.cn/direct/954074786a82467893a11dee7dff5910.png)
activeMq将mqtt发布订阅转成消息队列
1、activemq.xml置文件新增如下内容 2、mqttx测试发送: 主题(配置的模糊匹配,为了并发):VirtualTopic/device/sendData/12312 3、mqtt接收的结果 4、程序处理 package comimport cn.hutool.core.date.DateUtil; imp…...
![](https://img-blog.csdnimg.cn/img_convert/55b7aff15ab95fe7b497408ca7aa7802.png)
网站的惩罚期要怎么做/色盲测试图第六版
简介ES是一个基于RESTful web接口并且构建在Apache Lucene之上的开源分布式搜索引擎。同时ES还是一个分布式文档数据库,其中每个字段均可被索引,而且每个字段的数据均可被搜索,能够横向扩展至数以百计的服务器存储以及处理PB级的数据。可以在…...
![](/images/no-images.jpg)
企业名录搜索软件排行榜/如何seo搜索引擎优化
css3动画:弹出式菜单 今天主要来讲讲transition和transform结合做的动画,会举一些现在(2017年)常见的动画例子。 注:本人也接触css3不久,如果写的有纰漏请指出,不喜勿喷。 弹出式菜单 效果&…...
![](/images/no-images.jpg)
wordpress 主题banner/seo批量建站
• 命令用法 – rsync [选项...] 源目录 目标目录 • 同步与复制的差异 – 复制:完全拷贝源到目标 – 同步:增量拷贝,只传输变化过的数据 • rsync操作选项– -n:测试同步过程,不做实际修改– --delete:删除目标文件夹内多余的文档– -a:归档模式,相当于-rlptgoD– -v:显示详细…...
![](https://images2017.cnblogs.com/blog/602056/201710/602056-20171018214837256-1677096059.png)
免费网站模板网站/百度服务热线
一直都想参加下数学建模,通过几个月培训学到一些好的数学思想和方法,今年终于有时间有机会有队友一起参加了研究生数模,but,为啥今年说不培训直接参加国赛,泪目~_~~,然后比赛前也基本没看,直接硬…...
![](/images/no-images.jpg)
网站建设及规划方案/百度浏览器网页
亲密---我感觉,可以用和人和事处的时间长短,并用心 难?不去做? 前作业: 1.什么是微服务 将整个项目,按照功能拆分,拆分后能够更容易地部署,扩展,没有技术壁垒 2.微服务用什么优势,go或者py去做,怎么实现 …...
![](/images/no-images.jpg)
中山快速做网站服务/三只松鼠网络营销案例分析
思路 把公式拆开维护两个值,一个a[i]的总和,一个a[i]*i的总和 也可以用树状数组维护,模板题 代码 #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #inclu…...