-
Notifications
You must be signed in to change notification settings - Fork 1
/
csctex.linkedlist.sty
48 lines (39 loc) · 1.08 KB
/
csctex.linkedlist.sty
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
48
\ProvidesPackage{csctex.linkedlist}
\usepackage{xparse}
\usepackage{pgf, pgffor, fmtcount, tikz, circuitikz, qtree}
\usetikzlibrary{fit,arrows,calc,positioning,shapes.multipart,chains}
\newcounter{llbranchcount}
\setcounter{llbranchcount}{0}
\newcounter{llnodecount}
\setcounter{llnodecount}{0}
\NewDocumentCommand\llnode{O{} D(){} m}{%
\ifnum\the\value{llnodecount}=0
\llnodeInternal[#1] (#2) {#3};
\else
\llnodeInternal[join,#1] (#2) {#3};
\fi
}
\NewDocumentCommand\llnodeInternal{O{} D(){} m}{%
\addtocounter{llnodecount}{1};
\node[rectangle split,
rectangle split parts=2,
rectangle split horizontal,
draw,
on chain,
#1] (#2) {#3};
}
\newenvironment{linkedlist}
{%
\addtocounter{llbranchcount}{1};
\setcounter{llnodecount}{0}
\tikzset{
every join/.style={ *->,
shorten <=-0.75em
}
}
\node[on chain]{};
\begin{scope}[start branch=linkedlist\the\value{llbranchcount} going right, node distance=1.5em]
}%
{%
\end{scope}
}