Home | History | Annotate | Download | only in collect
      1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      2 <!--NewPage-->
      3 <HTML>
      4 <HEAD>
      5 <!-- Generated by javadoc (build 1.6.0-google-internal) on Mon Jan 04 20:47:59 PST 2010 -->
      6 <TITLE>
      7 PeekingIterator (Guava Libraries 2010.01.04)
      8 </TITLE>
      9 
     10 <META NAME="date" CONTENT="2010-01-04">
     11 
     12 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
     13 
     14 <SCRIPT type="text/javascript">
     15 function windowTitle()
     16 {
     17     if (location.href.indexOf('is-external=true') == -1) {
     18         parent.document.title="PeekingIterator (Guava Libraries 2010.01.04)";
     19     }
     20 }
     21 </SCRIPT>
     22 <NOSCRIPT>
     23 </NOSCRIPT>
     24 
     25 </HEAD>
     26 
     27 <BODY BGCOLOR="white" onload="windowTitle();">
     28 <HR>
     29 
     30 
     31 <!-- ========= START OF TOP NAVBAR ======= -->
     32 <A NAME="navbar_top"><!-- --></A>
     33 <A HREF="#skip-navbar_top" title="Skip navigation links"></A>
     34 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
     35 <TR>
     36 <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
     37 <A NAME="navbar_top_firstrow"><!-- --></A>
     38 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
     39   <TR ALIGN="center" VALIGN="top">
     40   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
     41   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
     42   <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
     43   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/PeekingIterator.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
     44   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
     45   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
     46   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
     47   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
     48   </TR>
     49 </TABLE>
     50 </TD>
     51 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
     52 </EM>
     53 </TD>
     54 </TR>
     55 
     56 <TR>
     57 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
     58 &nbsp;<A HREF="../../../../com/google/common/collect/Ordering.html" title="class in com.google.common.collect"><B>PREV CLASS</B></A>&nbsp;
     59 &nbsp;<A HREF="../../../../com/google/common/collect/SetMultimap.html" title="interface in com.google.common.collect"><B>NEXT CLASS</B></A></FONT></TD>
     60 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
     61   <A HREF="../../../../index.html?com/google/common/collect/PeekingIterator.html" target="_top"><B>FRAMES</B></A>  &nbsp;
     62 &nbsp;<A HREF="PeekingIterator.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
     63 &nbsp;<SCRIPT type="text/javascript">
     64   <!--
     65   if(window==top) {
     66     document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
     67   }
     68   //-->
     69 </SCRIPT>
     70 <NOSCRIPT>
     71   <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
     72 </NOSCRIPT>
     73 
     74 
     75 </FONT></TD>
     76 </TR>
     77 <TR>
     78 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
     79   SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
     80 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
     81 DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
     82 </TR>
     83 </TABLE>
     84 <A NAME="skip-navbar_top"></A>
     85 <!-- ========= END OF TOP NAVBAR ========= -->
     86 
     87 <HR>
     88 <!-- ======== START OF CLASS DATA ======== -->
     89 <H2>
     90 <FONT SIZE="-1">
     91 com.google.common.collect</FONT>
     92 <BR>
     93 Interface PeekingIterator&lt;E&gt;</H2>
     94 <DL>
     95 <DT><B>All Superinterfaces:</B> <DD><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Iterator.html?is-external=true" title="class or interface in java.util">Iterator</A>&lt;E&gt;</DD>
     96 </DL>
     97 <HR>
     98 <DL>
     99 <DT><PRE>public interface <B>PeekingIterator&lt;E&gt;</B><DT>extends <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Iterator.html?is-external=true" title="class or interface in java.util">Iterator</A>&lt;E&gt;</DL>
    100 </PRE>
    101 
    102 <P>
    103 An iterator that supports a one-element lookahead while iterating.
    104 <P>
    105 
    106 <P>
    107 <DL>
    108 <DT><B>Since:</B></DT>
    109   <DD>2010.01.04 <b>stable</b> (imported from Google Collections Library)</DD>
    110 <DT><B>Author:</B></DT>
    111   <DD>Mick Killianey</DD>
    112 </DL>
    113 <HR>
    114 
    115 <P>
    116 
    117 <!-- ========== METHOD SUMMARY =========== -->
    118 
    119 <A NAME="method_summary"><!-- --></A>
    120 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
    121 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
    122 <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
    123 <B>Method Summary</B></FONT></TH>
    124 </TR>
    125 <TR BGCOLOR="white" CLASS="TableRowColor">
    126 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
    127 <CODE>&nbsp;<A HREF="../../../../com/google/common/collect/PeekingIterator.html" title="type parameter in PeekingIterator">E</A></CODE></FONT></TD>
    128 <TD><CODE><B><A HREF="../../../../com/google/common/collect/PeekingIterator.html#next()">next</A></B>()</CODE>
    129 
    130 <BR>
    131 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
    132 </TR>
    133 <TR BGCOLOR="white" CLASS="TableRowColor">
    134 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
    135 <CODE>&nbsp;<A HREF="../../../../com/google/common/collect/PeekingIterator.html" title="type parameter in PeekingIterator">E</A></CODE></FONT></TD>
    136 <TD><CODE><B><A HREF="../../../../com/google/common/collect/PeekingIterator.html#peek()">peek</A></B>()</CODE>
    137 
    138 <BR>
    139 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the next element in the iteration, without advancing the iteration.</TD>
    140 </TR>
    141 <TR BGCOLOR="white" CLASS="TableRowColor">
    142 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
    143 <CODE>&nbsp;void</CODE></FONT></TD>
    144 <TD><CODE><B><A HREF="../../../../com/google/common/collect/PeekingIterator.html#remove()">remove</A></B>()</CODE>
    145 
    146 <BR>
    147 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
    148 </TR>
    149 </TABLE>
    150 &nbsp;<A NAME="methods_inherited_from_class_java.util.Iterator"><!-- --></A>
    151 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
    152 <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
    153 <TH ALIGN="left"><B>Methods inherited from interface java.util.<A HREF="http://java.sun.com/javase/6/docs/api/java/util/Iterator.html?is-external=true" title="class or interface in java.util">Iterator</A></B></TH>
    154 </TR>
    155 <TR BGCOLOR="white" CLASS="TableRowColor">
    156 <TD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Iterator.html?is-external=true#hasNext()" title="class or interface in java.util">hasNext</A></CODE></TD>
    157 </TR>
    158 </TABLE>
    159 &nbsp;
    160 <P>
    161 
    162 <!-- ============ METHOD DETAIL ========== -->
    163 
    164 <A NAME="method_detail"><!-- --></A>
    165 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
    166 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
    167 <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
    168 <B>Method Detail</B></FONT></TH>
    169 </TR>
    170 </TABLE>
    171 
    172 <A NAME="peek()"><!-- --></A><H3>
    173 peek</H3>
    174 <PRE>
    175 <A HREF="../../../../com/google/common/collect/PeekingIterator.html" title="type parameter in PeekingIterator">E</A> <B>peek</B>()</PRE>
    176 <DL>
    177 <DD>Returns the next element in the iteration, without advancing the iteration.
    178 
    179  <p>Calls to <code>peek()</code> should not change the state of the iteration,
    180  except that it <i>may</i> prevent removal of the most recent element via
    181  <A HREF="../../../../com/google/common/collect/PeekingIterator.html#remove()"><CODE>remove()</CODE></A>.
    182 <P>
    183 <DD><DL>
    184 </DL>
    185 </DD>
    186 <DD><DL>
    187 
    188 <DT><B>Throws:</B>
    189 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/NoSuchElementException.html?is-external=true" title="class or interface in java.util">NoSuchElementException</A></CODE> - if the iteration has no more elements
    190      according to <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Iterator.html?is-external=true#hasNext()" title="class or interface in java.util"><CODE>Iterator.hasNext()</CODE></A></DL>
    191 </DD>
    192 </DL>
    193 <HR>
    194 
    195 <A NAME="next()"><!-- --></A><H3>
    196 next</H3>
    197 <PRE>
    198 <A HREF="../../../../com/google/common/collect/PeekingIterator.html" title="type parameter in PeekingIterator">E</A> <B>next</B>()</PRE>
    199 <DL>
    200 <DD>
    201 
    202  <p>The objects returned by consecutive calls to <A HREF="../../../../com/google/common/collect/PeekingIterator.html#peek()"><CODE>peek()</CODE></A> then <A HREF="../../../../com/google/common/collect/PeekingIterator.html#next()"><CODE>next()</CODE></A> are guaranteed to be equal to each other.
    203 <P>
    204 <DD><DL>
    205 <DT><B>Specified by:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Iterator.html?is-external=true#next()" title="class or interface in java.util">next</A></CODE> in interface <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Iterator.html?is-external=true" title="class or interface in java.util">Iterator</A>&lt;<A HREF="../../../../com/google/common/collect/PeekingIterator.html" title="type parameter in PeekingIterator">E</A>&gt;</CODE></DL>
    206 </DD>
    207 <DD><DL>
    208 </DL>
    209 </DD>
    210 </DL>
    211 <HR>
    212 
    213 <A NAME="remove()"><!-- --></A><H3>
    214 remove</H3>
    215 <PRE>
    216 void <B>remove</B>()</PRE>
    217 <DL>
    218 <DD>
    219 
    220  <p>Implementations may or may not support removal when a call to <A HREF="../../../../com/google/common/collect/PeekingIterator.html#peek()"><CODE>peek()</CODE></A> has occurred since the most recent call to <A HREF="../../../../com/google/common/collect/PeekingIterator.html#next()"><CODE>next()</CODE></A>.
    221 <P>
    222 <DD><DL>
    223 <DT><B>Specified by:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Iterator.html?is-external=true#remove()" title="class or interface in java.util">remove</A></CODE> in interface <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Iterator.html?is-external=true" title="class or interface in java.util">Iterator</A>&lt;<A HREF="../../../../com/google/common/collect/PeekingIterator.html" title="type parameter in PeekingIterator">E</A>&gt;</CODE></DL>
    224 </DD>
    225 <DD><DL>
    226 
    227 <DT><B>Throws:</B>
    228 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if there has been a call to <A HREF="../../../../com/google/common/collect/PeekingIterator.html#peek()"><CODE>peek()</CODE></A>
    229      since the most recent call to <A HREF="../../../../com/google/common/collect/PeekingIterator.html#next()"><CODE>next()</CODE></A> and this implementation
    230      does not support this sequence of calls (optional)</DL>
    231 </DD>
    232 </DL>
    233 <!-- ========= END OF CLASS DATA ========= -->
    234 <HR>
    235 
    236 
    237 <!-- ======= START OF BOTTOM NAVBAR ====== -->
    238 <A NAME="navbar_bottom"><!-- --></A>
    239 <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
    240 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
    241 <TR>
    242 <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
    243 <A NAME="navbar_bottom_firstrow"><!-- --></A>
    244 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
    245   <TR ALIGN="center" VALIGN="top">
    246   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
    247   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
    248   <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
    249   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/PeekingIterator.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
    250   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
    251   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
    252   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
    253   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
    254   </TR>
    255 </TABLE>
    256 </TD>
    257 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
    258 </EM>
    259 </TD>
    260 </TR>
    261 
    262 <TR>
    263 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
    264 &nbsp;<A HREF="../../../../com/google/common/collect/Ordering.html" title="class in com.google.common.collect"><B>PREV CLASS</B></A>&nbsp;
    265 &nbsp;<A HREF="../../../../com/google/common/collect/SetMultimap.html" title="interface in com.google.common.collect"><B>NEXT CLASS</B></A></FONT></TD>
    266 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
    267   <A HREF="../../../../index.html?com/google/common/collect/PeekingIterator.html" target="_top"><B>FRAMES</B></A>  &nbsp;
    268 &nbsp;<A HREF="PeekingIterator.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
    269 &nbsp;<SCRIPT type="text/javascript">
    270   <!--
    271   if(window==top) {
    272     document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
    273   }
    274   //-->
    275 </SCRIPT>
    276 <NOSCRIPT>
    277   <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
    278 </NOSCRIPT>
    279 
    280 
    281 </FONT></TD>
    282 </TR>
    283 <TR>
    284 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
    285   SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
    286 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
    287 DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
    288 </TR>
    289 </TABLE>
    290 <A NAME="skip-navbar_bottom"></A>
    291 <!-- ======== END OF BOTTOM NAVBAR ======= -->
    292 
    293 <HR>
    294 
    295 </BODY>
    296 </HTML>
    297