/
QueuePictures.tex
47 lines (41 loc) · 1.08 KB
/
QueuePictures.tex
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
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\def\cells#1#2#3{%
% #1 = total number of cells
% #2 = number of grey cells
% #3 = index for "front" ("back" is mod(#3+#2-1, #1))
\foreach [count=\i from 0] \j in {1,...,#1} {
% \node[cell,label=above:\i] (cell\i) at (\i,0) {};
\node[cell] (cell\i) at (\i,0) {};
}
\pgfmathsetmacro{\last}{#3+#2-1}
\foreach \i in {#3,...,\last} {
\pgfmathsetmacro{\back}{mod(\i,#1)}
\node[shaded cell] (back) at (\back,0) {};
}
\node[below] at (cell#3.south) {front};
\node[below] at (back.south) {back};
}
\tikzset{
cell/.style = {draw, minimum width=1cm, minimum height=0.8cm},
shaded cell/.style = {cell, fill=black!30},
}
\begin{document}
%\begin{tikzpicture}
%\cells{6}{3}{0}
%\end{tikzpicture} \\
%
%\begin{tikzpicture}
%\cells{6}{3}{3}
%\end{tikzpicture} \\
%
%\begin{tikzpicture}
%\cells{6}{3}{4}
%\end{tikzpicture} \\
\begin{tikzpicture}
\cells{8}{7}{0}
\foreach [count=\i from 0] \number in {$P_1[0]$, $P_2[0]$, $P_3[0]$, 299, 8, 14, 53, 78}
\node at (cell\i) {\number};
\end{tikzpicture}
\end{document}