Debian Codegraph @

texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructureext.code.tex

raw
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %
3 % This is a helper package with an elementary list datastructure.
4 % In contrast to \pgfplotslist, this one features fast append and fast
5 % copy-to-macro.
6 %
7 % The 'pgfplotsapplist' is a list which has ONLY the features
8 %
9 % \pgfplotsapplistnewempty
10 % \pgfplotsapplistpushback O(1)
11 % \pgfplotsapplistedefcontenttomacro (N)
12 % \pgfplotsapplistxdefcontenttomacro (N)
13 %
14 % It has been designed to accumulate macro content in O(N) (in
15 % contrast to TeX's macro append routines which lead to O(N^2)
16 % runtime).
17 %
18 % Furthermore, there is the
19 %
20 % \pgfplotsapplistXnewempty
21 % \pgfplotsapplistXpushback
22 % \pgfplotsapplistXedefcontenttomacro (N)
23 % \pgfplotsapplistXxdefcontenttomacro (N)
24 % \pgfplotsapplistXlet (N)
25 %
26 % structure which features **preasymptotical** constant runtime for
27 % pushback. That means, as long as N < 80000, the runtime is linear.
28 % It is only slightly slower than \pgfplotsapplist, and that only due
29 % to its generality. It could easily be adopted to be FASTER than
30 % \pgfplotsapplist.
31 %
32 % Credits for \pgfplotsapplist go to Till Tantau: he developed it for
33 % the PGF kernel.
34 %
35 %
36 % Copyright 2007/2008 by Christian Feuersänger.
37 %
38 % This program is free software: you can redistribute it and/or modify
39 % it under the terms of the GNU General Public License as published by
40 % the Free Software Foundation, either version 3 of the License, or
41 % (at your option) any later version.
42 %
43 % This program is distributed in the hope that it will be useful,
44 % but WITHOUT ANY WARRANTY; without even the implied warranty of
45 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46 % GNU General Public License for more details.
47 %
48 % You should have received a copy of the GNU General Public License
49 % along with this program. If not, see <http://www.gnu.org/licenses/>.
50 %
51 %
52 %
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54
55
56
57
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 % the applist defines one macro for each element, like
60 %
61 % \def\element<i>{<content>\element<i+1>}
62 % \def\element<i+1>{<content>\element<i+2>}
63 % \def\element<i+2>{}
64 %
65 % The '<i>' value belongs to the private interface and is part of the
66 % macro name.
67 %
68 % It features:
69 % - real O(1) pushback
70 % - O(N) edef to macro
71 % - O(N) execute
72 % - it requires O(N) different macros.
73 % - it ***can't*** be copied outside of the current TeX group!
74 %
75 % I have never used it (besides early tests)
76 %
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78
79
80 % Time: O(1), number of macros: 3
81 \def\pgfplotsapplistnewempty#1{%
82 \expandafter\def\csname\string#1@endno\endcsname{0}%
83 \edef#1{\expandafter\noexpand\csname\string#1@0\endcsname}%
84 \expandafter\def\csname\string#1@0\endcsname{}%
85 }%
86
87 % Time: O(1), number of macros per list: about N
88 % #1: the item to append
89 % #2: the list as macro name
90 \long\def\pgfplotsapplistpushback#1\to#2{%
91 \expandafter\let\expandafter\pgfplots@loc@TMPa\csname\string#2@endno\endcsname
92 \begingroup
93 \c@pgf@counta=\pgfplots@loc@TMPa\relax
94 \advance\c@pgf@counta by1
95 \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
96 \endgroup
97 \expandafter\let\csname\string#2@endno\endcsname=\pgfplots@glob@TMPa%
98 \t@pgfplots@toka={#1}%
99 \t@pgfplots@tokb=\expandafter{\csname\string#2@\pgfplots@glob@TMPa\endcsname}%
100 \expandafter\edef\csname\string#2@\pgfplots@loc@TMPa\endcsname{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
101 \expandafter\let\the\t@pgfplots@tokb=\pgfutil@empty
102 }%
103
104 % time O(N)
105 % Expands the complete content of list #1 as-is into the macro #2.
106 \def\pgfplotsapplistedefcontenttomacro#1\to#2{\edef#2{#1}}
107 \def\pgfplotsapplistxdefcontenttomacro#1\to#2{\xdef#2{#1}}
108
109 % Foreach list element, the stored value will simply be processed by
110 % TeX. Characters will be printed and commands will be executed.
111 % time O(N)
112 \def\pgfplotsapplistexecute#1{#1}%
113
114
115
116
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
118 %
119 % This list here is a general re-implementation of the list used in
120 % the PGF system layer.
121 % It employs two collect-buffers to reduce the runtime.
122 %
123 % - It has preasymptotical runtime O(N), but is O(N^2) asymptotically.
124 % - It requires only 5 macros per list.
125 %
126 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127
128 % Usage:
129 % \pgfplotsapplistXnewempty\macro
130 % \pgfplotsapplistXnewempty[to global]\macro
131 %
132 % The 'to global' flag will configure the list such that all
133 % assignments to \macro are global. The list accumulation is
134 % LOCAL, however: 'to global' is to be used inside of a local
135 % group such that the final result, when all buffers are flushed,
136 % is assigned globally.
137 %
138 % ATTENTION: maybe that [to global] thing is useless.
139 % Consider using the \pgfplotsapplistXglobal list (see below)
140 \def\pgfplotsapplistXnewempty{%
141 \pgfutil@ifnextchar[{%
142 \pgfplotsapplistXnewempty@opt
143 }{%
144 \pgfplotsapplistXnewempty@opt[]%
145 }%
146 }
147
148 \def\pgfplotsapplistXnewempty@opt@TOGLOBAL{to global}
149
150 \def\pgfplotsapplistXnewempty@opt[#1]#2{%
151 \def\pgfplots@loc@TMPa{#1}%
152 \ifx\pgfplots@loc@TMPa\pgfutil@empty
153 \expandafter\let\csname\string#2@let\endcsname=\let%
154 \expandafter\let\csname\string#2@edef\endcsname=\edef
155 \else
156 \ifx\pgfplots@loc@TMPa\pgfplotsapplistXnewempty@opt@TOGLOBAL
157 \expandafter\def\csname\string#2@let\endcsname{\global\let}%
158 \expandafter\let\csname\string#2@edef\endcsname=\xdef
159 \else
160 \pgfplots@error{Sorry, the argument '#1' to \string\pgfplotsapplistXnewempty\ is unknown. Accepted is 'to global' or empty.}%
161 \fi
162 \fi
163 \pgfplotsapplistXnewempty@{#2}%
164 }%
165
166 \def\pgfplotsapplistXnewempty@#1{%
167 \csname\string#1@let\endcsname#1=\pgfutil@empty
168 \expandafter\let\csname\string#1@smallbuf\endcsname=\pgfutil@empty
169 \expandafter\let\csname\string#1@bigbuf\endcsname=\pgfutil@empty
170 \expandafter\def\csname\string#1@smallbuf@c\endcsname{0}%
171 \expandafter\def\csname\string#1@bigbuf@c\endcsname{0}%
172 }%
173
174 % #1: the item to append
175 % #2: the list as macro name
176 \long\def\pgfplotsapplistXpushback#1\to#2{%
177 \begingroup
178 \c@pgf@counta=\csname\string#2@smallbuf@c\endcsname\relax
179 \advance\c@pgf@counta by1
180 \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
181 \endgroup
182 \expandafter\let\csname\string#2@smallbuf@c\endcsname=\pgfplots@glob@TMPa
183 \ifnum\csname\string#2@smallbuf@c\endcsname<40
184 \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}%
185 \expandafter\edef\csname\string#2@smallbuf\endcsname{\the\t@pgfplots@toka}%
186 \else
187 \pgfplotsapplistXpushback@smallbufoverfl{#1}{#2}%
188 \fi
189 }%
190 \long\def\pgfplotsapplistXpushback@smallbufoverfl#1#2{%
191 \begingroup
192 \c@pgf@counta=\csname\string#2@bigbuf@c\endcsname\relax
193 \advance\c@pgf@counta by1
194 \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
195 \endgroup
196 \expandafter\let\csname\string#2@bigbuf@c\endcsname=\pgfplots@glob@TMPa
197 %
198 \ifnum\csname\string#2@bigbuf@c\endcsname<30
199 \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname\string#2@bigbuf\endcsname}%
200 \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}%
201 \expandafter\edef\csname\string#2@bigbuf\endcsname{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
202 \expandafter\let\csname\string#2@smallbuf\endcsname=\pgfutil@empty
203 \expandafter\def\csname\string#2@smallbuf@c\endcsname{0}%
204 \else%
205 \t@pgfplots@toka=\expandafter{#2}%
206 \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#2@bigbuf\endcsname}%
207 \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}%
208 \csname\string#2@edef\endcsname#2{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
209 \expandafter\let\csname\string#2@smallbuf\endcsname=\pgfutil@empty
210 \expandafter\def\csname\string#2@smallbuf@c\endcsname{0}%
211 \expandafter\let\csname\string#2@bigbuf\endcsname=\pgfutil@empty
212 \expandafter\def\csname\string#2@bigbuf@c\endcsname{0}%
213 \fi%
214 }%
215 \def\pgfplotsapplistXflushbuffers#1{%
216 \t@pgfplots@toka=\expandafter{#1}%
217 \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#1@bigbuf\endcsname}%
218 \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname\string#1@smallbuf\endcsname}%
219 \csname\string#1@edef\endcsname#1{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
220 \expandafter\let\csname\string#1@smallbuf\endcsname=\pgfutil@empty
221 \expandafter\def\csname\string#1@smallbuf@c\endcsname{0}%
222 \expandafter\let\csname\string#1@bigbuf\endcsname=\pgfutil@empty
223 \expandafter\def\csname\string#1@bigbuf@c\endcsname{0}%
224 }%
225
226
227 % Expands the complete content of list #1 as-is into the macro #2.
228 \def\pgfplotsapplistXedefcontenttomacro#1\to#2{%
229 \pgfplotsapplistXflushbuffers#1%
230 \edef#2{#1}}
231 \def\pgfplotsapplistXxdefcontenttomacro#1\to#2{%
232 \pgfplotsapplistXflushbuffers#1%
233 \xdef#2{#1}}
234 \def\pgfplotsapplistXlet#1=#2{%
235 \pgfplotsapplistXflushbuffers#2%
236 \let#1=#2}
237
238 % Foreach list element, the stored value will simply be processed by
239 % TeX. Characters will be printed and commands will be executed.
240 \def\pgfplotsapplistXexecute#1{%
241 \pgfplotsapplistXflushbuffers#1%
242 #1}%
243
244
245 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
246 %
247 % A variant of applist which has the same runtime requirements, but
248 % does PUSH FRONT only.
249 %
250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
251
252
253 % Usage:
254 % \pgfplotsprependlistXnewempty{liste}
255 \def\pgfplotsprependlistXnewempty#1{%
256 \expandafter\let\csname pgfpPRP@#1\endcsname=\pgfutil@empty
257 \expandafter\let\csname pgfpPRP@#1@smallbuf\endcsname=\pgfutil@empty
258 \expandafter\let\csname pgfpPRP@#1@bigbuf\endcsname=\pgfutil@empty
259 \expandafter\def\csname pgfpPRP@#1@smallbuf@c\endcsname{0}%
260 \expandafter\def\csname pgfpPRP@#1@bigbuf@c\endcsname{0}%
261 }%
262
263 % #1: the item to append
264 % #2: the list as macro name
265 \long\def\pgfplotsprependlistXpushfront#1\to#2{%
266 \begingroup
267 \c@pgf@counta=\csname pgfpPRP@#2@smallbuf@c\endcsname\relax
268 \advance\c@pgf@counta by1
269 \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
270 \endgroup
271 \expandafter\let\csname pgfpPRP@#2@smallbuf@c\endcsname=\pgfplots@glob@TMPa
272 \ifnum\csname pgfpPRP@#2@smallbuf@c\endcsname<40
273 \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2@smallbuf\endcsname}%
274 \t@pgfplots@tokb={#1}%
275 \expandafter\edef\csname pgfpPRP@#2@smallbuf\endcsname{\the\t@pgfplots@tokb\the\t@pgfplots@toka}%
276 \else
277 \pgfplotsprependlistXpushfront@smallbufoverfl{#1}{#2}%
278 \fi
279 }%
280 \long\def\pgfplotsprependlistXpushfront@smallbufoverfl#1#2{%
281 \begingroup
282 \c@pgf@counta=\csname pgfpPRP@#2@bigbuf@c\endcsname\relax
283 \advance\c@pgf@counta by1
284 \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
285 \endgroup
286 \expandafter\let\csname pgfpPRP@#2@bigbuf@c\endcsname=\pgfplots@glob@TMPa
287 %
288 \ifnum\csname pgfpPRP@#2@bigbuf@c\endcsname<30
289 \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2@bigbuf\endcsname}%
290 \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2@smallbuf\endcsname}%
291 \t@pgfplots@tokc={#1}%
292 \expandafter\edef\csname pgfpPRP@#2@bigbuf\endcsname{\the\t@pgfplots@tokc\the\t@pgfplots@tokb\the\t@pgfplots@toka}%
293 \expandafter\let\csname pgfpPRP@#2@smallbuf\endcsname=\pgfutil@empty
294 \expandafter\def\csname pgfpPRP@#2@smallbuf@c\endcsname{0}%
295 \else%
296 \pgfplotsprependlistXflushbuffers{#2}%
297 \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#2\endcsname}%
298 \t@pgfplots@tokb={#1}%
299 \expandafter\edef\csname pgfpPRP@#2\endcsname{\the\t@pgfplots@tokb\the\t@pgfplots@toka}%
300 \fi%
301 }%
302 \def\pgfplotsprependlistXflushbuffers#1{%
303 \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfpPRP@#1\endcsname}%
304 \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname pgfpPRP@#1@bigbuf\endcsname}%
305 \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname pgfpPRP@#1@smallbuf\endcsname}%
306 \expandafter\edef\csname pgfpPRP@#1\endcsname{\the\t@pgfplots@tokc\the\t@pgfplots@tokb\the\t@pgfplots@toka}%
307 \expandafter\let\csname pgfpPRP@#1@smallbuf\endcsname=\pgfutil@empty
308 \expandafter\def\csname pgfpPRP@#1@smallbuf@c\endcsname{0}%
309 \expandafter\let\csname pgfpPRP@#1@bigbuf\endcsname=\pgfutil@empty
310 \expandafter\def\csname pgfpPRP@#1@bigbuf@c\endcsname{0}%
311 }%
312
313 \def\pgfplotsprependlistXlet#1=#2{%
314 \pgfplotsprependlistXflushbuffers{#2}%
315 \expandafter\let\expandafter#1\csname pgfpPRP@#2\endcsname}
316
317
318 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
319 %
320 % This list \pgfplotsapplistXX here is essentially the SAME as \pgfplotslistX.
321 %
322 % But there can only be one such list at a time, so it is faster than
323 % \pgfplotslistX.
324 %
325 % This here is probably the fastest list.
326 %
327 % It is nothing else but a copy of Till Tantau's pgf kernel list.
328 %
329 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
330
331
332
333 % WARNING: call \pgfplotsapplistclear if there is another list active.
334 \def\pgfplotsapplistXXnewempty{%
335 \pgfutil@ifundefined{pgfplotsapplistXX}{}{%
336 \ifx\pgfplotsapplistXX\pgfutil@empty
337 \else
338 \pgfplots@error{\string\pgfplotsapplistXXnewempty: there is already another list which is *not* empty. It currently contains '\meaning\pgfplotsapplistXX'. Please call '\string\pgfplotsapplistXXclear' before using a new list to ensure clean separations.}%
339 \fi
340 }%
341 \let\pgfplotsapplistXX=\pgfutil@empty
342 \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty
343 \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty
344 \def\pgfplotsapplistXX@smallbuf@c{0}%
345 \def\pgfplotsapplistXX@bigbuf@c{0}%
346 }%
347
348
349 \def\pgfplotsapplistXXclear{%
350 \pgfutil@ifundefined{pgfplotsapplistXX}{}{%
351 \let\pgfplotsapplistXX=\pgfutil@empty
352 \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty
353 \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty
354 \def\pgfplotsapplistXX@smallbuf@c{0}%
355 \def\pgfplotsapplistXX@bigbuf@c{0}%
356 }%
357 }%
358
359 % #1: the item to append
360 % #2: the list as macro name
361 \long\def\pgfplotsapplistXXpushback#1{%
362 \begingroup
363 \c@pgf@counta=\pgfplotsapplistXX@smallbuf@c\relax
364 \advance\c@pgf@counta by1
365 \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
366 \endgroup
367 \let\pgfplotsapplistXX@smallbuf@c=\pgfplots@glob@TMPa
368 \ifnum\pgfplotsapplistXX@smallbuf@c<40
369 \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX@smallbuf#1}%
370 \edef\pgfplotsapplistXX@smallbuf{\the\t@pgfplots@toka}%
371 \else
372 \pgfplotsapplistXXpushback@smallbufoverfl{#1}%
373 \fi
374 }%
375 \long\def\pgfplotsapplistXXpushback@smallbufoverfl#1{%
376 \begingroup
377 \c@pgf@counta=\pgfplotsapplistXX@bigbuf@c\relax
378 \advance\c@pgf@counta by1
379 \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
380 \endgroup
381 \let\pgfplotsapplistXX@bigbuf@c=\pgfplots@glob@TMPa
382 %
383 \ifnum\pgfplotsapplistXX@bigbuf@c<30
384 \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX@bigbuf}%
385 \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXX@smallbuf#1}%
386 \edef\pgfplotsapplistXX@bigbuf{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
387 \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty
388 \def\pgfplotsapplistXX@smallbuf@c{0}%
389 \else%
390 \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX}%
391 \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXX@bigbuf}%
392 \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXX@smallbuf#1}%
393 \edef\pgfplotsapplistXX{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
394 \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty
395 \def\pgfplotsapplistXX@smallbuf@c{0}%
396 \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty
397 \def\pgfplotsapplistXX@bigbuf@c{0}%
398 \fi%
399 }%
400 \def\pgfplotsapplistXXflushbuffers{%
401 \t@pgfplots@toka=\expandafter{\pgfplotsapplistXX}%
402 \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXX@bigbuf}%
403 \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXX@smallbuf}%
404 \edef\pgfplotsapplistXX{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
405 \let\pgfplotsapplistXX@smallbuf=\pgfutil@empty
406 \def\pgfplotsapplistXX@smallbuf@c{0}%
407 \let\pgfplotsapplistXX@bigbuf=\pgfutil@empty
408 \def\pgfplotsapplistXX@bigbuf@c{0}%
409 }%
410
411
412 % Expands the complete content of list #1 as-is into the macro #2.
413 \def\pgfplotsapplistXXedefcontenttomacro#1{%
414 \pgfplotsapplistXXflushbuffers
415 \edef#1{\pgfplotsapplistXX}}
416 \def\pgfplotsapplistXXxdefcontenttomacro#1{%
417 \pgfplotsapplistXXflushbuffers%
418 \xdef#1{\pgfplotsapplistXX}}
419 \def\pgfplotsapplistXXlet#1{%
420 \pgfplotsapplistXXflushbuffers%
421 \let#1=\pgfplotsapplistXX}
422
423 % Foreach list element, the stored value will simply be processed by
424 % TeX. Characters will be printed and commands will be executed.
425 \def\pgfplotsapplistXXexecute#1{%
426 \pgfplotsapplistXXflushbuffers
427 #1}%
428
429
430 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
431 %
432 % \pgfplotslistXXglobal assigns to a global list.
433 %
434 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
435 \def\pgfplotsapplistXXglobalnewempty{%
436 \pgfutil@ifundefined{pgfplotsapplistXXglobal}{}{%
437 \ifx\pgfplotsapplistXXglobal\pgfutil@empty
438 \else
439 \pgfplots@error{\string\pgfplotsapplistXXglobalnewempty: there is already another list which is *not* empty. It currently contains '\meaning\pgfplotsapplistXXglobal'. Please call '\string\pgfplotsapplistXXglobalclear' before using a new list to ensure clean separations.}%
440 \fi
441 }%
442 \global\let\pgfplotsapplistXXglobal=\pgfutil@empty
443 \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty
444 \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty
445 \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}%
446 \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}%
447 }%
448
449
450 \def\pgfplotsapplistXXglobalclear{%
451 \pgfutil@ifundefined{pgfplotsapplistXXglobal}{}{%
452 \global\let\pgfplotsapplistXXglobal=\pgfutil@empty
453 \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty
454 \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty
455 \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}%
456 \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}%
457 }%
458 }%
459
460 % #1: the item to append
461 % #2: the list as macro name
462 \long\def\pgfplotsapplistXXglobalpushback#1{%
463 \begingroup
464 \c@pgf@counta=\pgfplotsapplistXXglobal@smallbuf@c\relax
465 \advance\c@pgf@counta by1
466 \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
467 \endgroup
468 \global\let\pgfplotsapplistXXglobal@smallbuf@c=\pgfplots@glob@TMPa
469 \ifnum\pgfplotsapplistXXglobal@smallbuf@c<40
470 \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal@smallbuf#1}%
471 \xdef\pgfplotsapplistXXglobal@smallbuf{\the\t@pgfplots@toka}%
472 \else
473 \pgfplotsapplistXXglobalpushback@smallbufoverfl{#1}%
474 \fi
475 }%
476 \long\def\pgfplotsapplistXXglobalpushback@smallbufoverfl#1{%
477 \begingroup
478 \c@pgf@counta=\pgfplotsapplistXXglobal@bigbuf@c\relax
479 \advance\c@pgf@counta by1
480 \xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}%
481 \endgroup
482 \global\let\pgfplotsapplistXXglobal@bigbuf@c=\pgfplots@glob@TMPa
483 %
484 \ifnum\pgfplotsapplistXXglobal@bigbuf@c<30
485 \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal@bigbuf}%
486 \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXXglobal@smallbuf#1}%
487 \xdef\pgfplotsapplistXXglobal@bigbuf{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
488 \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty
489 \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}%
490 \else%
491 \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal}%
492 \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXXglobal@bigbuf}%
493 \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXXglobal@smallbuf#1}%
494 \xdef\pgfplotsapplistXXglobal{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
495 \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty
496 \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}%
497 \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty
498 \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}%
499 \fi%
500 }%
501 \def\pgfplotsapplistXXglobalflushbuffers{%
502 \t@pgfplots@toka=\expandafter{\pgfplotsapplistXXglobal}%
503 \t@pgfplots@tokb=\expandafter{\pgfplotsapplistXXglobal@bigbuf}%
504 \t@pgfplots@tokc=\expandafter{\pgfplotsapplistXXglobal@smallbuf}%
505 \xdef\pgfplotsapplistXXglobal{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
506 \global\let\pgfplotsapplistXXglobal@smallbuf=\pgfutil@empty
507 \gdef\pgfplotsapplistXXglobal@smallbuf@c{0}%
508 \global\let\pgfplotsapplistXXglobal@bigbuf=\pgfutil@empty
509 \gdef\pgfplotsapplistXXglobal@bigbuf@c{0}%
510 }%
511
512
513 % Expands the complete content of list #1 as-is into the macro #2.
514 %
515 % this assigns locally into #1.
516 \def\pgfplotsapplistXXglobaledefcontenttomacro#1{%
517 \pgfplotsapplistXXglobalflushbuffers
518 \edef#1{\pgfplotsapplistXXglobal}}
519 % this assigns locally into #1.
520 \def\pgfplotsapplistXXglobalxdefcontenttomacro#1{%
521 \pgfplotsapplistXXglobalflushbuffers%
522 \xdef#1{\pgfplotsapplistXXglobal}}
523 % this assigns locally into #1.
524 \def\pgfplotsapplistXXgloballet#1{%
525 \pgfplotsapplistXXglobalflushbuffers%
526 \let#1=\pgfplotsapplistXXglobal}
527
528 % Foreach list element, the stored value will simply be processed by
529 % TeX. Characters will be printed and commands will be executed.
530 % this assigns locally into #1.
531 \def\pgfplotsapplistXXglobalexecute#1{%
532 \pgfplotsapplistXXglobalflushbuffers
533 #1}%
534
535
536 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
537 %
538 % \pgfplotsapplistXglobalnewempty --> same as \pgfplotsapplistX, but
539 % it always assigns everything *globally*.
540 %
541 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
542
543 \def\pgfplotsgloballet{\global\let}%
544
545 % Usage:
546 % \pgfplotsapplistXglobalnewempty\macro
547 % \pgfplotsapplistXglobalnewempty[to global]\macro
548 %
549 % The 'to global' flag will configure the list such that all
550 % assignments to \macro are global. The list accumulation is
551 % LOCAL, however: 'to global' is to be used inside of a local
552 % group such that the final result, when all buffers are flushed,
553 % is assigned globally.
554 \def\pgfplotsapplistXglobalnewempty#1{%
555 \pgfplotsgloballet#1=\pgfutil@empty
556 \expandafter\pgfplotsgloballet\csname\string#1@smallbuf\endcsname=\pgfutil@empty
557 \expandafter\pgfplotsgloballet\csname\string#1@bigbuf\endcsname=\pgfutil@empty
558 \expandafter\gdef\csname\string#1@smallbuf@c\endcsname{0}%
559 \expandafter\gdef\csname\string#1@bigbuf@c\endcsname{0}%
560 }%
561
562 % #1: the item to append
563 % #2: the list as macro name
564 \long\def\pgfplotsapplistXglobalpushback#1\to#2{%
565 \begingroup
566 \c@pgf@counta=\csname\string#2@smallbuf@c\endcsname\relax
567 \advance\c@pgf@counta by1
568 \expandafter\xdef\csname\string#2@smallbuf@c\endcsname{\the\c@pgf@counta}%
569 \endgroup
570 \ifnum\csname\string#2@smallbuf@c\endcsname<40
571 \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}%
572 \expandafter\xdef\csname\string#2@smallbuf\endcsname{\the\t@pgfplots@toka}%
573 \else
574 \pgfplotsapplistXglobalpushback@smallbufoverfl{#1}{#2}%
575 \fi
576 }%
577 \long\def\pgfplotsapplistXglobalpushback@smallbufoverfl#1#2{%
578 \begingroup
579 \c@pgf@counta=\csname\string#2@bigbuf@c\endcsname\relax
580 \advance\c@pgf@counta by1
581 \expandafter\xdef\csname\string#2@bigbuf@c\endcsname{\the\c@pgf@counta}%
582 \endgroup
583 %
584 \ifnum\csname\string#2@bigbuf@c\endcsname<30
585 \t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname\string#2@bigbuf\endcsname}%
586 \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}%
587 \expandafter\xdef\csname\string#2@bigbuf\endcsname{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
588 \expandafter\pgfplotsgloballet\csname\string#2@smallbuf\endcsname=\pgfutil@empty
589 \expandafter\gdef\csname\string#2@smallbuf@c\endcsname{0}%
590 \else%
591 \t@pgfplots@toka=\expandafter{#2}%
592 \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#2@bigbuf\endcsname}%
593 \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname\string#2@smallbuf\endcsname#1}%
594 \xdef#2{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
595 \expandafter\pgfplotsgloballet\csname\string#2@smallbuf\endcsname=\pgfutil@empty
596 \expandafter\gdef\csname\string#2@smallbuf@c\endcsname{0}%
597 \expandafter\pgfplotsgloballet\csname\string#2@bigbuf\endcsname=\pgfutil@empty
598 \expandafter\gdef\csname\string#2@bigbuf@c\endcsname{0}%
599 \fi%
600 }%
601 \def\pgfplotsapplistXglobalflushbuffers#1{%
602 \t@pgfplots@toka=\expandafter{#1}%
603 \t@pgfplots@tokb=\expandafter\expandafter\expandafter{\csname\string#1@bigbuf\endcsname}%
604 \t@pgfplots@tokc=\expandafter\expandafter\expandafter{\csname\string#1@smallbuf\endcsname}%
605 \xdef#1{\the\t@pgfplots@toka\the\t@pgfplots@tokb\the\t@pgfplots@tokc}%
606 \expandafter\pgfplotsgloballet\csname\string#1@smallbuf\endcsname=\pgfutil@empty
607 \expandafter\gdef\csname\string#1@smallbuf@c\endcsname{0}%
608 \expandafter\pgfplotsgloballet\csname\string#1@bigbuf\endcsname=\pgfutil@empty
609 \expandafter\gdef\csname\string#1@bigbuf@c\endcsname{0}%
610 }%
611
612
613 \def\pgfplotsapplistXgloballet#1=#2{%
614 \pgfplotsapplistXglobalflushbuffers#2%
615 \let#1=#2}