# Drawing a diagram of a data structure (std::vector from C++)

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:

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

• Since you are using Beamer, TikZ seems the right tool for the job (there are others, but TikZ is automatically loaded by Beamer). It's easy to draw arrows, create nodes with text, draw rectangles, and colour them. – Manuel Feb 14 '17 at 0:36
• @Manuel I don't think that's true. It loads pgf but not tikz. – cfr Feb 14 '17 at 1:47

This should get you started....

\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}