%%
%% This is file `ccalgo.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% cc.dtx  (with options: `ccalgo,chartab')
%% 
%% This is a generated file.
%% 
%% Copyright 2000-2003
%% Michael N"usken, Joachim von zur Gathen, computational complexity
%% 
%% IMPORTANT NOTICE:
%% 
%% You are *not* allowed to modify this file.
%% 
%% You are *not* allowed to distribute this file.
%% For distribution of the original source see the terms
%% for copying and modification in the file cc.dtx.
%% 
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{ccalgo}[2005/08/27 v2.04
  algorithm environment for cc.  Michael Nuesken, Bonn.]
\let\namedalgorithm\@undefined
\let\endnamedalgorithm\@undefined
\let\algorithm\@undefined
\let\endalgorithm\@undefined
{\def\algonumerate@item[#1]{%
  \if@noparitem
    \@donoparitem
  \else
    \if@inlabel
      \indent \par
    \fi
    \ifhmode
      \unskip\unskip \par
    \fi
    \if@newlist
      \if@nobreak
        \@nbitem
      \else
        \addpenalty\@beginparpenalty
        \addvspace\@topsep
        \addvspace{-\parskip}%
      \fi
    \else
      \addpenalty\@itempenalty
      \addvspace\itemsep
    \fi
    \global\@inlabeltrue
  \fi
  \everypar{%
    \@minipagefalse
    \global\@newlistfalse
    \if@inlabel
      \global\@inlabelfalse
      {\setbox\z@\lastbox
       \ifvoid\z@
         \kern-\itemindent
       \fi}%
      \box\@labels
      \penalty\z@
    \fi
    \if@nobreak
      \@nobreakfalse
      \clubpenalty \@M
    \else
      \clubpenalty \@clubpenalty
      \everypar{}%
    \fi}%
  \if@noitemarg
    \@noitemargfalse
    \if@nmbrlist
      \refstepcounter\@listctr
    \fi
  \fi
  \sbox\@tempboxa{\makelabel{#1}}%
  \global\setbox\@labels\hbox{%
    \unhbox\@labels
    \hskip \itemindent
    \hskip -\labelwidth
    \hskip -\labelsep
    \ifdim \wd\@tempboxa >\labelwidth
      \box\@tempboxa
    \else
      \hbox to\labelwidth {\unhbox\@tempboxa}%
    \fi
    \hskip \labelsep}%
  \ignorespaces}
\ifx\algonumerate@item\@item\else
\PackageWarningNoLine{ccalgo}{%
  Command \protect\@item\space  has changed.\MessageBreak
  Check if current package is valid}
\fi}
\RequirePackage{theorem}
\RequirePackage{thcc}
\RequirePackage{relabel}
\def\list@parshape{%
  %%\typeout{parshape 1 \the\@totalleftmargin+\the\linewidth}%
  \parshape \@ne \@totalleftmargin \linewidth}
\newdimen\reinit@list@last
\def\reinit@list#1{%
  \advance\itemindent\reinit@list@last
  \advance\@totalleftmargin-\reinit@list@last
  \advance\linewidth\reinit@list@last
  \global\reinit@list@last#1\relax
  \ifdim\reinit@list@last>\algonumerate@maxindent
  \global\reinit@list@last\algonumerate@maxindent\fi
  \advance\itemindent-\reinit@list@last
  \advance\@totalleftmargin\reinit@list@last
  \advance\linewidth-\reinit@list@last
  %%\typeout{\the\@totalleftmargin + \the\linewidth}%
  \list@parshape}
\def\reinit@list@label{%
  \reinit@list{\wd\@tempboxa}%
  }
\newcommand{\makealgolabel}[1]{#1.}
\newcommand{\makeoptalgolabel}[1]{(#1)}
\let\makeoptalgocurrentlabel\makeoptalgolabel
\newcounter{algonumerate}
\defprefix{algonumerate}{}
\newcount\algonumerate@items
\renewcommand{\thealgonumerate}{%
  \expandafter\ifnum\value{algonumerate}<\@ne
  \algonumfield%
  \else
  \arabic{algonumerate}\fi}%
\def\algonumfield{\ignorespaces
  \ifx\@algonumfield\relax\else
  \expandafter\@algonumfield\csname c@algonumerate\endcsname\fi
  \unskip}
\newif\if@speciallabel
\newcommand{\labelalgonumerate}{%
  \count@\value{algonumerate}%
  \ifnum\count@<\z@
  \algonumfield:%
  \else
  \makealgolabel{\thealgonumerate}\fi
  }%
\newdimen\algo@labelsep
\newdimen\steplabelwidth
\newtoks\AtNextItem
\newif\if@requireditemscomplete
\newcommand{\algonumerate@label}[1]{%
  \def\@tempa{#1}\def\@tempc{\@itemlabel}%
  %%\show\@tempa\show\@tempc
  \ifx\@tempa\@tempc\global\@speciallabelfalse
  \else\global\@speciallabeltrue\fi
  \expandafter\ifnum\value{algonumerate}<\z@
  #1\hskip\algo@labelsep%
  \else
  \ifx\@tempa\@empty
  \hskip\steplabelwidth\hskip\algo@labelsep
  \else
  \hb@xt@\steplabelwidth{\hss
    \hb@xt@\steplabelwidth{\hfill
      \if@speciallabel
      \makeoptalgolabel{#1}%
      \else
      #1%
      \fi
      }}\hskip\algo@labelsep%
  \fi\fi
  \global\let\algonumerate@global\global
  \gdef\global{\algonumerate@global\let\global\algonumerate@global
    \expandafter\count@\value{algonumerate}%
    %%{\tracingall\nonstopmode\showbox\@tempboxa}%
    \ifnum\count@=\m@ne
    \stepcounter{algonumerate}%
    \fi
    \ifnum\count@=\z@
    \if@requireditemscomplete\else
    \global\@requireditemscompletetrue
    \ifnum\algonumerate@items>\z@\medskip\fi
    \fi
    \fi
    \ifnum\count@=\@ne
    \if@requireditemscomplete\else
    \global\@requireditemscompletetrue
    \ifnum\algonumerate@items>\z@\medskip\fi
    \fi
    \fi
    \if@speciallabel
    \protected@edef\@currentlabel{\csname p@\@listctr\endcsname
      {\makeoptalgocurrentlabel{#1}}}%
    \protected@edef\@bare@currentlabel{#1}%
    \fi
    \global\let\latest@item@currentlabel\@currentlabel
    \global\let\latest@item@bare@currentlabel\@bare@currentlabel
    \global\@speciallabeltrue
    \the\AtNextItem \global\AtNextItem{}%
    \reinit@list@label
    \global}%
  }
\newdimen\algonumerate@maxindent
\AtBeginDocument{\ifdim\algonumerate@maxindent=\z@
  \algonumerate@maxindent.2\textwidth\fi}
\def\algonumerateinit#1{%
  \def\@algonumfield{}%
  \let\ccorg@or\or\let\or\relax
  \algonumerate@items\z@
  \@for\@tempa:=#1\do{%
    \advance\algonumerate@items\@ne
    \@temptokena\expandafter{\@tempa}%
    \toks@\expandafter{\@algonumfield}%
    \edef\@algonumfield{\the\@temptokena\or\the\toks@}%
    }%
  \let\or\ccorg@or
  \toks@\expandafter{\@algonumfield}%
  \edef\@algonumfield##1{\noexpand\ifcase-##1\noexpand\or
    \the\toks@\noexpand\fi}%
  }
\newenvironment{algonumerate}{%
  \if@inlabel~\fi\par
  \list{\labelalgonumerate}{%
    \usecounter{algonumerate}%
    \let\makelabel\algonumerate@label
    \parsep\z@%
    \topsep\z@%
    \itemsep\z@%
    \parskip\z@%
    %\leftmargin\z@
    %\algo@labelsep\labelsep
    %\labelsep\z@
    \leftmargin\labelsep
    \algo@labelsep\z@
    \settowidth\steplabelwidth{\makealgolabel{99}}%
    \labelwidth\z@
    \global\reinit@list@last\z@
    }%
  \setcounter{algonumerate}{-\algonumerate@items}%
  \ifnum\algonumerate@items>\z@
  \addtocounter{algonumerate}\m@ne
  \global\@requireditemscompletefalse
  \else
  \global\@requireditemscompletetrue
  \fi
  \setcounter{block@cnt}\z@
  \let\step\algo@step
  \let\block\algo@block
  \let\endblock\endalgo@block
  \let\range\algo@range
  \let\endrange\endalgo@range
  \let\indention\algo@indention
  \let\endindention\endalgo@indention
  \let\body\algo@block
  \let\endbody\endalgo@block
  \let\meta\algo@meta
  \let\endmeta\endalgo@meta
  }{%
  \endlist\vskip\topskip}
\newdimen\blockindent \blockindent\parindent
\newcounter{block@cnt}
\newcommand{\nextblock}{%
  \stepcounter{block@cnt}\edef\currentblock{\arabic{block@cnt}}%
  }
\newif\if@trivialrange
\newcommand{\refsetrange}[2]{%
  {\shortlabeltrue
    \let\@tempa\relax
    \protected@edef\@tempa{%
      \csname r@\the\algorithmmasterkey-#1\endcsname}%
    %%\show\@tempa
    \let\@tempc\relax
    \protected@edef\@tempc{%
      \csname r@\the\algorithmmasterkey-#2\endcsname}%
    %%\show\@tempc
    \ifx\@tempa\@tempc\global\@trivialrangetrue
    \else\global\@trivialrangefalse\fi
    }%
  \if@trivialrange
  \protected@edef\@currentlabel{}%
  \else
  \protected@edef\@currentlabel{%
    \csname p@\@listctr\endcsname{%
    \protect\short\protect\ref{\the\algorithmmasterkey-#1}%
    --%
    \protect\short\protect\ref{\the\algorithmmasterkey-#2}%
    }}%
  \fi
  \protected@edef\@bare@currentlabel{%
    \protect\bare\protect\ref{\the\algorithmmasterkey-#1}%
    --%
    \protect\bare\protect\ref{\the\algorithmmasterkey-#2}%
    }%
  }
\newenvironment{algo@range}{%
  \par
  \stepcounter{block@cnt}\edef\block@{\arabic{block@cnt}}%
  \refsetrange{bob\block@}{eob\block@}%
  \AtNextItem{\algolabel{bob\block@}}%
  }{%
  \algolabel{eob\block@}%
  \par
  \global\let\algo@block@currentlabel\@currentlabel
  \global\let\algo@block@bare@currentlabel\@bare@currentlabel
  \aftergroup\algo@endrange@aftergroup
  }
\def\algo@endrange@aftergroup{%
  \let\@currentlabel\latest@item@currentlabel
  \let\@bare@currentlabel\latest@item@bare@currentlabel
  }
\newenvironment{algo@indention}{%
  \par
  \if@requireditemscomplete
  \advance\leftmargin\blockindent
  \advance\labelsep\blockindent
  \advance\@totalleftmargin\blockindent
  \advance\linewidth-\blockindent
  \def\algo@indention@undo{%
    \advance\leftmargin-\blockindent
    \advance\labelsep-\blockindent
    \advance\@totalleftmargin-\blockindent
    \advance\linewidth\blockindent
    }
  \list@parshape
  \else
  \let\algo@indention@undo\relax
  \fi
  }{%
  \par
  \algo@indention@undo
  \list@parshape
  \aftergroup\list@parshape
  \global\let\algo@block@currentlabel\@currentlabel
  \global\let\algo@block@bare@currentlabel\@bare@currentlabel
  \aftergroup\algo@endrange@aftergroup
  }
\newif\ifindented@block
\newenvironment{algo@block}{%
  \indented@blockfalse
  \if@requireditemscomplete\indented@blocktrue\fi
  \ifindented@block\algo@indention
  \else
  \sbox\@tempboxa{\makelabel{}}%
  \fi
  \algo@range}{%
  \endalgo@range
  \ifindented@block\endalgo@indention\fi
  }
\newdimen\meta@indent
\newenvironment{algo@meta}{%
  \@newlistfalse
  \vskip\topskip
  \par
  %%\meta@indent\leftmargin
  %%\advance\meta@indent\algo@labelsep
  %%\advance\meta@indent\steplabelwidth
  \meta@indent\@totalleftmargin
  \advance\labelsep-\meta@indent
  \advance\@totalleftmargin-\meta@indent
  \advance\linewidth\meta@indent
  \advance\leftmargin-\meta@indent
  \list@parshape
  }{%
  \vskip\topskip
  \par
  \advance\labelsep\meta@indent
  \advance\@totalleftmargin\meta@indent
  \advance\linewidth-\meta@indent
  \advance\leftmargin\meta@indent
  \aftergroup\list@parshape
  }
\newcommand{\algo@step}[2][]{%
  \expandafter\ifnum\value{algonumerate}<\m@ne
  \PackageError{ccalgo}{Missing \protect\item}{}%
  \fi
  \cc@ifempty{#1}{\item}{\item[#1]}%
  \def\@tempa{#2}\ifx\@tempa\@empty\else\algolabel{#2}\fi%
  }
\newtoks\algotitle
\theorembodyfont{}%
\theoremstyle{ccalgonn}
\newtheorem{named@lg@r@thm*}{\the\algotitle}
\defprefix{named@lg@r@thm*}#1{\the\algotitle}
\theoremstyle{ccalgo}
\newtheorem{named@lg@r@thm}{\the\algotitle}
\defprefix{named@lg@r@thm}#1{\the\algotitle~#1}
\let\c@named@lg@r@thm\c@namedth@@r@m
\let\thenamed@lg@r@thm\thenamedth@@r@m
\babel\def\babelInput{Input}[german=Eingabe,french=Entr\'ee]
\babel\def\babelOutput{Output}[german=Ausgabe,french=Sortie]
\babel\def\babelstep{step}[german=Schritt,french=pas]%% ??? pas?
\babel\def\babelStep{Step}[german=Schritt,french=Pas]%% ??? pas?
\newtoks\algorithmmasterkey
\newenvironment{namedalgorithm}[1]{%
  \pagebreak[3]%
  \def\algo@theorem{named@lg@r@thm}%
  \algotitle{#1}%
  \n@medalgorithm}
{\endalgonumerate\csname end\algo@theorem\endcsname}
\newenvironment{namedalgorithm*}[1]{%
  \def\algo@theorem{named@lg@r@thm*}%
  \algotitle{#1}%
  \n@medalgorithm}
{\endalgonumerate\csname end\algo@theorem\endcsname}
\newcommand{\n@medalgorithm}[2][\babelInput,\protect\babelOutput]{%
  \algonumerateinit{#1}%
  \algorithmmasterkey{#2}%
  \edef\@tempa{\the\algorithmmasterkey}\ifx\@tempa\@empty
  \PackageError{ccalgo}{Empty key for algorithm like environment}{}\fi%
  \n@m@d@lgorithm}
\newcommand{\n@m@d@lgorithm}[1][]{%
  \def\@tempa{#1}%
  \ifx\@tempa\@empty\csname\algo@theorem\endcsname
  \else\csname\algo@theorem\endcsname[#1]\fi%
  \label{\the\algorithmmasterkey}%
  \algo@keywords
  \defprefix{algonumerate}{%
    \Iflabelchanged{\algo@theorem}{\uselabel{\algo@theorem} %
      \ifnum\c@algonumerate>\z@ \babelstep~\fi}}%
  \algonumerate
  }%
\def\algolabel#1{\label{\the\algorithmmasterkey-#1}}%
\newcommand{\stepref}[2]{\babelStep~\short\ref{#1-#2} in \whole\ref{#1}}
\newcommand{\newalgorithm}[2]{%
  \def\newalgo@name{#1}%
  \def\newalgo@title{#2}%
  \n@walgorithm}
\newcommand{\n@walgorithm}[1][\babelInput,\protect\babelOutput]{%
  \protected@edef\@tempa{%
    \noexpand\newenvironment{\newalgo@name}%
    {\noexpand\namedalgorithm{\newalgo@title}[\noexpand#1]}%
    {\noexpand\endnamedalgorithm}%
    \noexpand\newenvironment{\newalgo@name*}%
    {\noexpand\csname namedalgorithm*\endcsname
      {\newalgo@title}[\noexpand#1]}%
    {\noexpand\csname endnamedalgorithm*\endcsname}%
    }\@tempa
  }
\babel\def\algorithmname{Algorithm}[%
  german=Algorithmus,french=Algorithme]
\newalgorithm{algorithm}{\protect\algorithmname}
\def\algo@keywords{%
  \def\keyword##1{\textsf{##1} \ignorespaces}%
  \babel\def\FOR{\keyword{For}}[german=\keyword{F{\"{u}}r}]%
  \babel\def\DO{\keyword{do}}[german=\keyword{erledige}]%
  \babel\def\endFOR{}[]%
  \babel\def\WHILE{\keyword{While}}[german=\keyword{Solange}]%
  \babel\def\endWHILE{}[]%
  \babel\def\REPEAT{\keyword{Repeat}}[german=\keyword{Wiederhole}]%
  \babel\def\UNTIL{\keyword{Until}}[german=\keyword{Bis}]%
  \babel\def\IF{\keyword{If}}[german=\keyword{Falls}]%
  \babel\def\THEN{\keyword{then}}[german=\keyword{dann}]%
  \babel\def\ELIF{\keyword{Else if}}[german=\keyword{Sonst wenn}]%
  \babel\def\ELSE{\keyword{Else}}[german=\keyword{Sonst}]%
  \babel\def\endIF{}[]%
  \babel\def\CALL{\keyword{Call}}[german=\keyword{Rufe}]%
  \babel\def\RETURN{\keyword{Return}}[german=\keyword{Antworte}]%
  \expandafter\selectlanguage\expandafter{\languagename}
  \def\COMMENT##1{$\{$ ##1 $\}$}%
  }
\newcommand{\optitem}[1]{%
  \cc@ifempty{#1}{\if@inlabel\par\else\item\fi}{\item[#1]}%
  }
\newcommand{\algoprettify}[3]{%
  \setbox2\hbox{#1}%
  \setbox4\hbox{#2}%
  \setbox6\hbox{#3}%
  \setbox0\hbox{\unhcopy2\unhcopy4{ }\unhcopy6}%
  \ifdim\wd0<\linewidth
  \unhbox0
  \else
  \dimen0=\linewidth \advance\dimen0 by -\wd2
  \unhbox2\parbox[t]{\dimen0}{\unhbox4\strut}\par\unhbox6
  \fi
  }
\newenvironment{ifblock}[2][]
{%
  \optitem{#1}%
  \nextblock
  \algolabel{if\currentblock}%
  \algoprettify{\IF}{#2}{\THEN}
  \indention
  \refsetrange{if\currentblock}{endif\currentblock}%
  }
{%
  \algolabel{endif\currentblock}%
  \endindention}
\newenvironment{elifblock}[2][]{%
  \optitem{#1}%
  \nextblock
  \algoprettify{\ELIF}{#2}{\THEN}
  \algolabel{elif\currentblock}%
  \indention
  \refsetrange{elif\currentblock}{endelif\currentblock}%
  }{%
  \algolabel{endelif\currentblock}%
  \endindention}
\newenvironment{elseblock}[1][]{%
  \optitem{#1}%
  \nextblock
  \ELSE%
  \algolabel{else\currentblock}%
  \indention
  \refsetrange{else\currentblock}{endelse\currentblock}%
  }{%
  \algolabel{endelse\currentblock}%
  \endindention}
\newenvironment{forblock}[2][]{%
  \optitem{#1}%
  \nextblock
  \algoprettify{\FOR}{#2}{%
    \DO \short\ref{\the\algorithmmasterkey-body\currentblock}}%
  \algolabel{for\currentblock}%
  \block\algolabel{body\currentblock}%
  \refsetrange{for\currentblock}{endfor\currentblock}%
  }{%
  \algolabel{endfor\currentblock}%
  \endblock}
\newenvironment{whileblock}[2][]{%
  \optitem{#1}%
  \nextblock
  \algoprettify{\WHILE}{#2}{%
    \DO \short\ref{\the\algorithmmasterkey-body\currentblock}}%
  \algolabel{while\currentblock}%
  \block
  \algolabel{body\currentblock}%
  \refsetrange{while\currentblock}{endwhile\currentblock}%
  }{%
  \algolabel{endwhile\currentblock}%
  \endblock}
\newenvironment{untilblock}[2][]{%
  \optitem{#1}%
  \nextblock
  \algoprettify{\UNTIL}{#2}{%
    \DO \short\ref{\the\algorithmmasterkey-body\currentblock}}%
  \algolabel{until\currentblock}%
  \block
  \algolabel{body\currentblock}%
  \refsetrange{until\currentblock}{enduntil\currentblock}%
  }{%
  \algolabel{enduntil\currentblock}%
  \endblock}
\newenvironment{blockuntil}[2][]{%
  \optitem{#1}%
  \nextblock
  \def\repeat@cond{#2}%
  \REPEAT \short\ref{\the\algorithmmasterkey-body\currentblock}%
  \algolabel{repeat\currentblock}%
  \block
    \algolabel{body\currentblock}%
    \refsetrange{repeat\currentblock}{endrepeat\currentblock}%
    }{%
  \endblock
\item
  \algolabel{endrepeat\currentblock}%
  \algoprettify{\UNTIL}{\repeat@cond}{}}
\newenvironment{blockwhile}[2][]{%
  \optitem{#1}%
  \nextblock
  \def\repeat@cond{#2}%
  \REPEAT \short\ref{\the\algorithmmasterkey-body\currentblock}%
  \algolabel{repeat\currentblock}%
  \block
    \algolabel{body\currentblock}%
    \refsetrange{repeat\currentblock}{endrepeat\currentblock}%
    }{%
  \endblock
\item
  \algolabel{endrepeat\currentblock}%
  \algoprettify{\WHILE}{\repeat@cond}{}}
\endinput
%%
%% End of file `ccalgo.sty'.
