[Tex/LaTex] Drawing a diagram of a data structure (`std::vector` from C++)

data structures

I'm looking for a way to show data structures in my slides (Beamer). My first task is to show something that looks like a C++ vector.

Something like this:

enter image description here

Note that the final arrow points "one past" the end.

Thanks in advance!

Best Answer

This should get you started....

enter image description here

\documentclass{article}

\usepackage[svgnames]{xcolor}
\usepackage{tikz}



\begin{document}
\begin{tikzpicture}
\node[draw,fill=LightSteelBlue!60,minimum width=3cm,minimum height=1cm] (a) at (2,0) {capacity};
\node[draw,fill=LightSteelBlue!60,minimum width=3cm,minimum height=1cm] (b) at (2,1) {end};
\node[draw,rectangle, fill=LightSteelBlue!60,minimum width=3cm,minimum height=1cm] (c) at (2,2) {begin};
\foreach \x in {0,1,2,3}
 \node[draw,rectangle, fill=LightSteelBlue!60,minimum width=2cm,minimum height=1cm]  (d\x) at (10,\x-2){};
\foreach \x in {0,...,4}
\node[draw,rectangle, fill=White,minimum width=2cm,minimum height=1cm]  (e\x) at (10,\x-7){};
\node[minimum width=2cm,minimum height=1cm] (f) at (10,-8){};
\draw[->,very thick] (c.east)--(d3.west);
\draw[->,very thick] (b.east)--(e4.west);
\draw[->,very thick] (a.east)--(f.west);
\end{tikzpicture}
\end{document}
Related Question