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> 7PeekingIterator (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"> 15function 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> </TD> 41 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 42 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 43 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/PeekingIterator.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 44 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 45 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 46 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 47 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </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 <A HREF="../../../../com/google/common/collect/Ordering.html" title="class in com.google.common.collect"><B>PREV CLASS</B></A> 59 <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> 62 <A HREF="PeekingIterator.html" target="_top"><B>NO FRAMES</B></A> 63 <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: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> 80<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 81DETAIL: FIELD | CONSTR | <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"> 91com.google.common.collect</FONT> 92<BR> 93Interface PeekingIterator<E></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><E></DD> 96</DL> 97<HR> 98<DL> 99<DT><PRE>public interface <B>PeekingIterator<E></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><E></DL> 100</PRE> 101 102<P> 103An 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> <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 </TD> 132</TR> 133<TR BGCOLOR="white" CLASS="TableRowColor"> 134<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 135<CODE> <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 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> 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 </TD> 148</TR> 149</TABLE> 150 <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 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> 173peek</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> 196next</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><<A HREF="../../../../com/google/common/collect/PeekingIterator.html" title="type parameter in PeekingIterator">E</A>></CODE></DL> 206</DD> 207<DD><DL> 208</DL> 209</DD> 210</DL> 211<HR> 212 213<A NAME="remove()"><!-- --></A><H3> 214remove</H3> 215<PRE> 216void <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><<A HREF="../../../../com/google/common/collect/PeekingIterator.html" title="type parameter in PeekingIterator">E</A>></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> </TD> 247 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 248 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 249 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/PeekingIterator.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 250 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 251 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 252 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 253 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </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 <A HREF="../../../../com/google/common/collect/Ordering.html" title="class in com.google.common.collect"><B>PREV CLASS</B></A> 265 <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> 268 <A HREF="PeekingIterator.html" target="_top"><B>NO FRAMES</B></A> 269 <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: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> 286<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 287DETAIL: FIELD | CONSTR | <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