Advertisement
meta1211

Untitled

Aug 13th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. void EmployeesTree::AddEmployees(std::queue<Employee> employees)
  2. {
  3.     while (!employees.empty())
  4.     {
  5.         Employee newEmployee = employees.front();
  6.         employees.pop();
  7.         Node *curentNode = root;
  8.         root->undersCount++;
  9.         while (curentNode->positionID + 1 != newEmployee.GetPositionID() && !curentNode->subordinates.empty())
  10.         {
  11.             int minSubsIndex = FindLowestEmpCount(curentNode->subordinates);
  12.             curentNode = curentNode->subordinates[minSubsIndex];
  13.             curentNode->undersCount++;
  14.         }
  15.         if (curentNode->positionID + 1 != newEmployee.GetPositionID() && curentNode->subordinates.empty())
  16.         {
  17.             std::cout << "Can't find position for " << newEmployee.GetName() << " (position: " << newEmployee.GetPosition() << ")\n";
  18.             continue;
  19.         }
  20.         curentNode->subordinates.push_back(new Node(newEmployee));
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement