-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPincodes.cpp
45 lines (44 loc) · 1.44 KB
/
Pincodes.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "Pincodes.h"
Pincodes::Pincodes(void)
{
regions = nullptr;
}
bool Pincodes::add(Seller *user, unsigned int pin)
{
unsigned int insider_pin = (pin / 10000) - 11;
if (regions == nullptr)
{
regions = new Region[75];
}
return regions[insider_pin].add(user, pin % 10000);
}
std::vector<unsigned long int> Pincodes::showSellers(unsigned int pin)
{
std::vector<unsigned long int> output;
unsigned int level1, level2, level3;
level1 = (pin / 10000) - 11;
level3 = pin % 100;
level2 = (pin / 100) % 100;
// if ((regions != nullptr) && (regions[level1].districts != nullptr) &&
// (regions[level1].districts[level2].locals != nullptr) &&
// (regions[level1].districts[level2].locals[level3].data != nullptr))
if (regions != nullptr)
{
if (regions[level1].districts != nullptr)
{
if (regions[level1].districts[level2].locals != nullptr)
{
if ((regions[level1].districts[level2].locals[level3].data != nullptr))
{
PinSeller *traverse = regions[level1].districts[level2].locals[level3].data;
while (traverse != nullptr)
{
output.push_back(traverse->seller_info->id);
traverse = traverse->next;
}
}
}
}
}
return output;
}