[Tex/LaTex] Algorithm in new ACM Large format

acmalgorithms

I am using new ACM acmart template for my paper. In the new paper, I have a problem with the algorithm section:

\documentclass[acmlarge]{acmart}

\usepackage{booktabs} % For formal tables

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{rotating}
\usepackage{booktabs}
\usepackage{listings}


\usepackage[ruled]{algorithm2e} % For algorithms
\renewcommand{\algorithmcfname}{ALGORITHM}

\SetAlFnt{\small}
\SetAlCapFnt{\small}
\SetAlCapNameFnt{\small}
\SetAlCapHSkip{0pt}
\IncMargin{-\parindent}

% Metadata Information
\acmJournal{POMACS}
\acmVolume{9}
\acmNumber{4}
\acmArticle{39}
\acmYear{2010}
\acmMonth{3}
\acmArticleSeq{11}

%\acmBadgeR[http://ctuning.org/ae/ppopp2016.html]{ae-logo}
%\acmBadgeL[http://ctuning.org/ae/ppopp2016.html]{ae-logo}


% Copyright
%\setcopyright{acmcopyright}
%\setcopyright{acmlicensed}
%\setcopyright{rightsretained}
%\setcopyright{usgov}
\setcopyright{usgovmixed}
%\setcopyright{cagov}
%\setcopyright{cagovmixed}

% DOI
\acmDOI{0000001.0000001}

% Paper history
\received{February 2007}
\received{March 2009}
\received[accepted]{June 2009}


\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\newtheorem{myDefine}{Definition}
\newcommand{\img}{\includegraphics[width=.15\linewidth,height=20pt]{example-image}}


\lstset{language=Java,  breaklines=true, captionpos=b, numbers=left, keywordstyle=\color{blue}, numbersep=3pt, basicstyle=\footnotesize, %or \small or \footnotesize etc.
}


% Document starts
\begin{document}
% Title portion
\title{Your title} 
\author{Your name}
\orcid{1234-5678-9012-3456}
\affiliation{%
  \institution{College of William and Mary}
  \streetaddress{104 Jamestown Rd}
  \city{Williamsburg}
  \state{VA}
  \postcode{23185}
  \country{USA}}
\author{Tian He}
\affiliation{%
  \institution{University of Minnesota}
  \country{USA}}
\author{Chengdu Huang}
\author{John A. Stankovic}
\author{Tarek F. Abdelzaher}
\affiliation{%
  \institution{University of Virginia}
  \department{School of Engineering}
  \city{Charlottesville}
  \state{VA}
  \postcode{22903}
  \country{USA}
}


\begin{abstract}
helkoi 
\end{abstract}


%
% The code below should be generated by the tool at
% http://dl.acm.org/ccs.cfm
% Please copy and paste the code instead of the example below. 
%

\ccsdesc[500]{Computer systems organization~Embedded systems}
\ccsdesc[300]{Computer systems organization~Redundancy}
\ccsdesc{Computer systems organization~Robotics}
\ccsdesc[100]{Networks~Network reliability}

%
% End generated code
%

% We no longer use \terms command
\terms{Design, Algorithms, Performance}

\keywords{Wireless sensor networks, media access control,
multi-channel, radio interference, time synchronization}


\thanks{This work is supported by the National Science Foundation,
  under grant CNS-0435060, grant CCR-0325197 and grant EN-CS-0329609.

  Author's addresses: G. Zhou, Computer Science Department, College of
  William and Mary; Y. Wu {and} J. A. Stankovic, Computer Science
  Department, University of Virginia; T. Yan, Eaton Innovation Center;
  T. He, Computer Science Department, University of Minnesota; C.
  Huang, Google; T. F. Abdelzaher, (Current address) NASA Ames
  Research Center, Moffett Field, California 94035.}


\maketitle

% The default list of authors is too long for headers}
\renewcommand{\shortauthors}{G. Zhou et al.}

\section{Introduction}
.....
\begin{algorithm}[H]
\caption{Bytecode Generation Overview}
\label{alg:generator}
%\begin{algorithmic}[1]
Map store=new Map(obj, queue)
\function{\textit{generate}}{Object pivot}
     \ForAll{child $c$ in pivot}{
     \If{ $c$'s FieldContext is not set and $c$ is fusible}{
          generate($c$);
      }
     }
     build pivot's fieldContext $fc$;
     EmitClassName;
     EmitFields($fc$);
     EmitMethods($fc$);

%\end{algorithmic}

\end{algorithm}

\end{document}

The compilation latex file.tex fails with message:

! Missing } inserted.
<inserted text> 
                }
l.464 \end{algorithm}

If I added a } after EmitMethods($fc$);, then the error message becomes:

Overfull \hbox (1.5003pt too wide) detected at line 464
[][] 
! Extra }, or forgotten \endgroup.
\@algocf@finish ... {\skipalgocfslide }}{}\egroup 
                                                  \end {lrbox}\algocf@maketh...
l.464 \end{algorithm}

I read this message, but did not find issue half day? Where is wrong? Can anyone help?

Best Answer

Algorithm2e defines function as an alternative to algortihm. I guess you want something like

\begin{algorithm}[H]
\caption{Bytecode Generation Overview}
\label{alg:generator}
\SetKwProg{generate}{Function \emph{generate}}{}{end}

Map store=new Map(obj, queue)\;
\generate{Object pivot}{
     \ForAll{child $c$ in pivot}{
     \If{ $c$'s FieldContext is not set and $c$ is fusible}{
          generate($c$)\;
      }
     }
     build pivot's fieldContext $fc$\;
     EmitClassName\;
     EmitFields($fc$)\;
     EmitMethods($fc$)\;
}
\end{algorithm}

enter image description here

Related Question