MCPcopy
hub / github.com/careercup/ctci / assignCall

Method assignCall

java/Chapter 8/Question8_2/CallHandler.java:97–112  ·  view source on GitHub ↗
(Employee emp)

Source from the content-addressed store, hash-verified

95 /* An employee got free. Look for a waiting call that he/she can serve. Return true
96 * if we were able to assign a call, false otherwise. */
97 public boolean assignCall(Employee emp) {
98 /* Check the queues, starting from the highest rank this employee can serve. */
99 for (int rank = emp.getRank().getValue(); rank >= 0; rank--) {
100 List<Call> que = callQueues.get(rank);
101
102 /* Remove the first call, if any */
103 if (que.size() > 0) {
104 Call call = que.remove(0);
105 if (call != null) {
106 emp.receiveCall(call);
107 return true;
108 }
109 }
110 }
111 return false;
112 }
113}
114
115

Callers 1

assignNewCallMethod · 0.80

Calls 6

receiveCallMethod · 0.80
getValueMethod · 0.45
getRankMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected