parent
3a30b05375
commit
3769768be1
@ -0,0 +1,16 @@
|
||||
#include "machine.hpp"
|
||||
|
||||
Machine::Machine(const std::string& ip,unsigned int connectionsMax): ip{ip}, connections{0},connectionsMax{connectionsMax}
|
||||
{}
|
||||
|
||||
void Machine::addConnection(){
|
||||
connections+=1;
|
||||
}
|
||||
|
||||
unsigned int Machine::getNbConnections() const{
|
||||
return connections;
|
||||
}
|
||||
|
||||
unsigned int Machine::getNbConnectionsMax() const{
|
||||
return connectionsMax;
|
||||
}
|
@ -1,8 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
class Machine{
|
||||
unsigned int connection;
|
||||
unsigned int connectionMax;
|
||||
std::string ip;
|
||||
|
||||
}
|
||||
unsigned int connections;
|
||||
unsigned int connectionsMax;
|
||||
|
||||
public:
|
||||
Machine(const std::string& ip,unsigned int connectionsMax);
|
||||
void addConnection();
|
||||
unsigned int getNbConnections() const;
|
||||
unsigned int getNbConnectionsMax() const;
|
||||
|
||||
bool operator<(const Machine& other) const {
|
||||
return (connectionsMax-connections) < other.getNbConnectionsMax() - other.getNbConnections();
|
||||
}
|
||||
};
|
@ -1,16 +1,35 @@
|
||||
#include <iostream>
|
||||
#include <queue>
|
||||
#include "programme.hpp"
|
||||
#include "machine.hpp"
|
||||
|
||||
#include <vector>
|
||||
int main()
|
||||
{
|
||||
Programme prog1({"file1.txt","file2.txt","file3.txt"}, "image1");
|
||||
std::queue<Programme> file;
|
||||
file.push(prog1);
|
||||
|
||||
//Programme prog1({"file1.txt","file2.txt","file3.txt"}, "image1");
|
||||
//std::queue<Programme> file;
|
||||
//file.push(prog1);
|
||||
|
||||
//while true{
|
||||
//}
|
||||
|
||||
Machine m1("101.00.00.00",11);
|
||||
Machine m2("102.00.00.00",12);
|
||||
Machine m3("103.00.00.00",13);
|
||||
Machine m4("104.00.00.00",10);
|
||||
Machine m5("105.00.00.00",9);
|
||||
|
||||
std::priority_queue<Machine> machines;
|
||||
machines.push(m1);
|
||||
machines.push(m2);
|
||||
machines.push(m3);
|
||||
machines.push(m4);
|
||||
machines.push(m5);
|
||||
|
||||
while (!machines.empty()) {
|
||||
Machine top = machines.top();
|
||||
machines.pop();
|
||||
std::cout << "Connections: " << top.getNbConnectionsMax() << std::endl;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue