-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathqueue.sol
More file actions
104 lines (73 loc) · 1.95 KB
/
queue.sol
File metadata and controls
104 lines (73 loc) · 1.95 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
pragma solidity >=0.4.22 <0.6.0;
contract Deque {
mapping(uint256 => bytes) deque;
uint256 first = 2**255;
uint256 last = first - 1;
function pushLeft(bytes memory data) public {
first -= 1;
deque[first] = data;
}
function pushRight(bytes memory data) public {
last += 1;
deque[last] = data;
}
function popLeft() public returns (bytes memory data) {
require(last >= first); // non-empty deque
data = deque[first];
delete deque[first];
first += 1;
}
function popRight() public returns (bytes memory data) {
require(last >= first); // non-empty deque
data = deque[last];
delete deque[last];
last -= 1;
}
}
contract Queue {
mapping (address => Patient) receptionists;
address[] public receptionistAccts;
struct Patient {
string name;
int value1;
}
mapping(uint256 => string) queue;
uint256 first = 0;
uint256 last = 0;
uint256 size = 0;
function greet() public returns (string greet) {
greet = "Hello World!";
}
function enqueue(string memory data) public {
last += 1;
size += 1;
queue[last] = data;
}
function dequeue() public returns (string memory data) {
require(last >= first); // non-empty queue
data = queue[first];
delete queue[first];
first += 1;
size -= 1;
}
function lenght() public returns(uint256) {
return size;
}
function end() public returns(uint256) {
return last;
}
function start() public returns(uint256) {
return first;
}
function get_patient(uint256 position) public returns(string) {
require(size > 0);
return queue[position];
}
}
contract MedicalQueue is Queue {
address creator;
mapping(address => string) roles;
constructor() public {
creator = msg.sender;
}
}