summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgfplots/liststructure
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-07-16 23:47:14 +0000
committerKarl Berry <karl@freefriends.org>2010-07-16 23:47:14 +0000
commit0c242425bcb89cc3af3064b8b895608a7f5ec3bb (patch)
treec9e2e2a0cd90b875325b6ef0cc06edada1b5f4ec /Master/texmf-dist/tex/generic/pgfplots/liststructure
parenta77f52d8c904326838bc0523faffdc79bdff0f6e (diff)
pgfplots 1.4 (14jul10)
git-svn-id: svn://tug.org/texlive/trunk@19488 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/liststructure')
-rw-r--r--Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex64
-rw-r--r--Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex84
2 files changed, 99 insertions, 49 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex
index 7464dc43876..d62273eca51 100644
--- a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex
+++ b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsarray.code.tex
@@ -96,6 +96,15 @@
\fi
}
+% #1 the array's name (a macro name
+% #2 a list created by \pgfplotslistnew
+\def\pgfplotsarrayfrompgfplotslist#1#2{%
+ \pgfplotsarraynewempty#1%
+ \pgfplotslistforeachungrouped#2\as\pgfplotsarray@TMPa{%
+ \expandafter\pgfplotsarraypushback\expandafter{\pgfplotsarray@TMPa}\to#1%
+ }%
+}%
+
\def\pgfplotsarraynew@backslash#1#2{%
\pgfplotsarraynewempty{#1}%
\long\def\pgfplotsarraynew@impl@rest{#2}%
@@ -199,6 +208,9 @@
\def\pgfplotsarrayselect#1\of#2\to#3{%
\c@pgfplotsarray@tmp=#1\relax
\expandafter\let\expandafter#3\csname\string#2@\the\c@pgfplotsarray@tmp\endcsname%
+ \ifx#3\relax
+ \pgfplotsthrow{no such element}{#1}{No such element: \string\pgfplotsarrayselect\the\c@pgfplotsarray@tmp\string\of{\string#2}}\pgfeov%
+ \fi
}
% Expands to the value at index #1 of array #2.
@@ -315,12 +327,7 @@
\let\pgfplotsarrayforeachindex=\relax%
}
-% #1: arg1 (possibly not fully expanded)
-% #2: arg2 (possibly not fully expanded)
-% #3: code to invoke in case arg1<arg2
-% #4: code to invoke in case arg1>=arg2
\pgfkeys{%
- /pgfplots/array/iflessthan/.code args={#1#2#3#4}{\ifnum#1<#2\relax#3\else#4\fi},%
/pgfplots/array/unscope pre/.code={%
% That's more or less efficient (although some runtime factors
% could be saved).
@@ -349,7 +356,8 @@
% Sorts array '#1' using N log N time.
%
% The sort key is provided as argument in
-% /pgfplots/array/iflessthan/.code args={#1#2#3#4}, see above.
+% /pgfplots/iflessthan/.code args={#1#2#3#4}, see docs in
+% pgfplotsutil.code.tex.
%
% Remarks:
% - the sorting algorithm is a sub-optimal mergesort currently -
@@ -400,13 +408,22 @@
% [\pgfplotsarrayforeach\testarray\as\elem{\elem\space}]
%
%--------------------------------------------------
-\def\pgfplotsarraysort#1{%
+\def\pgfplotsarraysort{%
+ \pgfutil@ifnextchar[{\pgfplotsarraysort@opt}{\pgfplotsarraysort@opt[]}%
+}%
+\def\pgfplotsarraysort@opt[#1]#2{%
% I admit, the implementation is more-or less copy-paste of an
% experiment I had done at university. It does its job, but it is
- % certainly not optimal.
+ % certainly not optimal (that means: it is slow).
\begingroup
- \pgfkeysgetvalue{/pgfplots/array/iflessthan/.@cmd}\pgfplotsarraysort@iflt
- \pgfplotsarraysize{#1}\to\c@pgfplotsarray@tmp
+ \pgfqkeys{/pgfplots/array}{#1}%
+ \pgfkeysifdefined{/pgfplots/array/iflessthan/.@cmd}{%
+ \pgfplots@warning{Warning: /pgfplots/array/iflessthan/.@cmd is deprecated. Please use /pgfplots/iflessthan/.@cmd instead.}%
+ \pgfkeysgetvalue{/pgfplots/array/iflessthan/.@cmd}\pgfplotsarraysort@iflt
+ }{%
+ \pgfkeysgetvalue{/pgfplots/iflessthan/.@cmd}\pgfplotsarraysort@iflt
+ }%
+ \pgfplotsarraysize{#2}\to\c@pgfplotsarray@tmp
\pgfplotsarrayresizeglobal{pgfparraytmp}{\the\c@pgfplotsarray@tmp}%
\countdef\c@pgfplotsarraysort@m=0
\countdef\c@pgfplotsarraysort@k=1
@@ -414,15 +431,15 @@
\countdef\c@pgfplotsarraysort@l=3
\countdef\c@pgfplotsarraysort@j=4
\countdef\c@pgfplotsarraysort@q=5
- \def\pgfplotsarray@mergesort@{\pgfplotsarray@mergesort{#1}}%
- \def\pgfplotsarray@mergesort@recurse@{\pgfplotsarray@mergesort@recurse{#1}}%
+ \def\pgfplotsarray@mergesort@{\pgfplotsarray@mergesort{#2}}%
+ \def\pgfplotsarray@mergesort@recurse@{\pgfplotsarray@mergesort@recurse{#2}}%
\edef\pgfplotsarray@mergesort@@{{0}{\the\c@pgfplotsarray@tmp}}%
\expandafter\pgfplotsarray@mergesort@\pgfplotsarray@mergesort@@
%
% copy the complete, sorted result outside of the current scope.
- \pgfkeysvalueof{/pgfplots/array/unscope pre/.@cmd}#1\pgfeov
+ \pgfkeysvalueof{/pgfplots/array/unscope pre/.@cmd}#2\pgfeov
\endgroup
- \pgfkeysvalueof{/pgfplots/array/unscope post/.@cmd}#1\pgfeov
+ \pgfkeysvalueof{/pgfplots/array/unscope post/.@cmd}#2\pgfeov
}%
% #1: array name,
@@ -473,20 +490,27 @@
\c@pgfplotsarraysort@j=\c@pgfplotsarraysort@k
\advance\c@pgfplotsarraysort@j by#2
\pgfplotsarrayselect{\c@pgfplotsarraysort@j}\of{#1}\to\pgfplotsarray@x@k
+ \begingroup
\pgfplotsarraysort@iflt
{\pgfplotsarray@x@mpl}%
{\pgfplotsarray@x@k}%
{% x[m+l] < x[k]
- \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplotsarray@x@mpl
- \advance\c@pgfplotsarraysort@i by1
- \advance\c@pgfplotsarraysort@l by1
+ \aftergroup\pgfplots@loc@tmptrue
}%
{% x[k] <= x[m+l]
- \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplotsarray@x@k
- \advance\c@pgfplotsarraysort@i by1
- \advance\c@pgfplotsarraysort@k by1
+ \aftergroup\pgfplots@loc@tmpfalse
}%
\pgfeov
+ \endgroup
+ \ifpgfplots@loc@tmp
+ \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplotsarray@x@mpl
+ \advance\c@pgfplotsarraysort@i by1
+ \advance\c@pgfplotsarraysort@l by1
+ \else
+ \pgfplotsarrayletentryglobal\c@pgfplotsarraysort@i\of{pgfparraytmp}=\pgfplotsarray@x@k
+ \advance\c@pgfplotsarraysort@i by1
+ \advance\c@pgfplotsarraysort@k by1
+ \fi
\pgfutil@repeat
%
% append:
diff --git a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex
index 87ce40e586b..b60ff65c4f7 100644
--- a/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex
+++ b/Master/texmf-dist/tex/generic/pgfplots/liststructure/pgfplotsliststructure.code.tex
@@ -78,59 +78,85 @@
% Use braces '{}' to use '\\' or ',' as arguments.
%
\long\def\pgfplotslistnew#1#2{%
- \pgfplots@check@backwards@compatible@list@format #2\\\pgfplots@EOI
- \ifpgfplots@is@old@list@format
- \pgfplotslistnew@backslash{#1}{#2}%
+ \pgfplotslist@check@backslash@list #2\\\pgfplotslist@EOI
+ \ifpgfplotslist@is@backslash@terminated
+ \pgfplotslistnew@backslash@{#1}{#2}%
\else
\pgfplots@foreach@to@list{#2}\to#1%
\fi
}
+% Is this here *ever* used!? I guess not.
\long\def\pgfplotslistnew@backslash#1#2{%
\pgfplotslistnewempty{#1}%
- \long\def\pgfplotslistnew@impl@rest{#2}%
\pgfplotslist@check@backslash@list #2\\\pgfplotslist@EOI
\ifpgfplotslist@is@backslash@terminated
+ \long\def\pgfplotslistnew@impl@rest{#2\pgfplotslist@EOI\\}%
+ \def\pgfplotslistnew@backslash@loop{\pgfplotslistnew@impl{#1}}%
\else
- \expandafter\def\expandafter\pgfplotslistnew@impl@rest\expandafter{\pgfplotslistnew@impl@rest,}%
+ \def\pgfplotslistnew@backslash@loop{\pgfplotslistnew@impl@comma{#1}}%
+ \long\def\pgfplotslistnew@impl@rest{#2\pgfplotslist@EOI,}%
\fi
- \pgfutil@loop
- \ifx\pgfplotslistnew@impl@rest\pgfutil@empty
- \pgfplots@loop@CONTINUEfalse
+ \expandafter\pgfplotslistnew@backslash@loop\pgfplotslistnew@impl@rest
+}%
+\long\def\pgfplotslistnew@backslash@#1#2{%
+ \pgfplotslistnewempty{#1}%
+ \def\pgfplotslistnew@backslash@loop{\pgfplotslistnew@impl{#1}}%
+ \pgfplotslistnew@backslash@loop#2\pgfplotslist@EOI\\%
+}%
+
+% helper macro for \pgfplotslistnew
+\long\def\pgfplotslistnew@impl#1#2\\{%
+ \def\pgfplotslist@loc@TMPa{#2}%
+ \ifx\pgfplotslist@loc@TMPa\pgfplotslist@EOI
\else
- \pgfplots@loop@CONTINUEtrue
+ \pgfplotslistpushback{#2}\to#1\relax%
+ \expandafter\pgfplotslistnew@backslash@loop
\fi
- \ifpgfplots@loop@CONTINUE
- \ifpgfplotslist@is@backslash@terminated
- \expandafter\pgfplotslistnew@impl\pgfplotslistnew@impl@rest\tolist#1\relax
- \else
- \expandafter\pgfplotslistnew@impl@comma\pgfplotslistnew@impl@rest\tolist#1\relax
- \fi
- \pgfutil@repeat
-}%
+}
+\long\def\pgfplotslistnew@impl@comma#1#2,{%
+ \def\pgfplotslist@loc@TMPa{#2}%
+ \ifx\pgfplotslist@loc@TMPa\pgfplotslist@EOI
+ \else
+ \pgfplotslistpushback{#2}\to#1\relax%
+ \expandafter\pgfplotslistnew@backslash@loop
+ \fi
+}
\def\pgfplotslist@EOI{\pgfplotslist@EOI}
+\def\pgfplotslist@backslashsep{\\}
\long\def\pgfplotslist@check@backslash@list#1\\#2\pgfplotslist@EOI{%
- \def\pgfplotslist@loc@TMPa{#2}%
- \ifx\pgfplotslist@loc@TMPa\pgfutil@empty
+ \def\pgfplotslist@loc@TMPx{#2}%
+ \ifx\pgfplotslist@loc@TMPx\pgfutil@empty
\pgfplotslist@is@backslash@terminatedfalse
+ \let\pgfplotslist@check@backslash@list@next=\relax
\else
- \pgfplotslist@is@backslash@terminatedtrue
+ \def\pgfplotslist@loc@TMPy{ }%
+ \ifx\pgfplotslist@loc@TMPx\pgfplotslist@loc@TMPy
+ \pgfplotslist@is@backslash@terminatedfalse
+ \let\pgfplotslist@check@backslash@list@next=\relax
+ \else
+ \ifx\pgfplotslist@loc@TMPx\pgfplotslist@backslashsep
+ % ok. The list is something like 'a\\b\\' so the
+ % complete input is
+ % 'a\\b\\ \\ \EOI'
+ % we have iterated long enough to find only the '\\'
+ % right before the \EOI. It is thus backslash
+ % terminated.
+ \pgfplotslist@is@backslash@terminatedtrue
+ \let\pgfplotslist@check@backslash@list@next=\relax
+ \else
+ % Iterate. We want to check the last list element.
+ \long\def\pgfplotslist@check@backslash@list@next{\pgfplotslist@check@backslash@list#2\pgfplotslist@EOI}%
+ \fi
+ \fi
\fi
+ \pgfplotslist@check@backslash@list@next
}%
% Copies list #1 to list #2.
\def\pgfplotslistcopy#1\to#2{\let#2=#1}
-% helper macro for \pgfplotslistnew
-\long\def\pgfplotslistnew@impl#1\\#2\tolist#3{%
- \pgfplotslistpushback#1\to#3\relax%
- \def\pgfplotslistnew@impl@rest{#2}%
-}
-\long\def\pgfplotslistnew@impl@comma#1,#2\tolist#3{%
- \pgfplotslistpushback#1\to#3\relax%
- \def\pgfplotslistnew@impl@rest{#2}%
-}
% #1: the item to prepend