the entry owner inserts a newer update into the queue.}\r
\item Queue state entry: Includes queue size \newline {The purpose \r
of this is for the client to tell if the server lies about the number \r
-of slots in the queue, e.g. if there are 2 queue state entry in the queue, \r
+of slots in the queue, e.g. if there are 2 queue state entries in the queue, \r
e.g. 50 and 70, the client knows that when it sees 50, it should expect \r
at most 50 slots in the queue and after it sees 70, it should expect \r
50 slots before that queue state entry slot 50 and at most 70 slots. \r
\textbf{State} \\\r
\textit{SL = set of live slots on server} \\\r
\textit{max = maximum number of slots (input only for resize message)} \\\r
-\textit{n = number of slots} \\\r
+\textit{n = number of slots} \\ \\\r
+\textbf{Helper Function} \\\r
+$MaxSlot(SL')= \langle s, sv \rangle \mid \langle s, sv \rangle \r
+\in SL' \wedge \forall \langle s', sv' \rangle \in SL', s \geq s'$ \\\r
+$MinSlot(SL')= \langle s, sv \rangle \mid \langle s, sv \rangle \r
+\in SL' \wedge \forall \langle s', sv' \rangle \in SL', s \leq s'$ \\\r
+$SeqN(\langle s, sv \rangle)=s$ \\\r
+$SlotVal(\langle s, sv \rangle)=sv$ \\\r
\r
\begin{algorithmic}[1]\r
\Function{GetSlot}{$s_g$}\r
\If{$(max' \neq \emptyset)$}\Comment{Resize}\r
\State $max \gets max'$\r
\EndIf\r
-\State $s_n \gets \{\langle s,sv \rangle \in SL \mid \r
- \forall \langle s_i,sv_i \rangle \in SL, s \geq s_i\}$\Comment{Last s}\r
+\State $\langle s_n,sv_n \rangle \gets MaxSlot(SL)$\Comment{Last sv}\r
+\State $s_n \gets SeqN(\langle s_n,sv_n \rangle)$\r
\If{$(s_p = s_n + 1)$}\r
\If{$n = max$}\r
- \State $SL \gets SL - \{\langle s,sv \rangle \in SL \mid \r
- \forall \langle s_i,sv_i \rangle \in SL, s \leq s_i\}$\Comment{First s}\r
+ \State $\langle s_m,sv_m \rangle \gets MinSlot(SL)$\Comment{First sv}\r
+ \State $SL \gets SL - \{\langle s_m,sv_m \rangle\}$\r
\Else \Comment{$n < max$}\r
\State $n \gets n + 1$\r
\EndIf\r