PageRenderTime 84ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/javadoc/edu/stanford/nlp/util/Heap.html

https://github.com/thisandagain/stanford-ner
HTML | 366 lines | 303 code | 43 blank | 20 comment | 0 complexity | 805a7ffd3f72e04575d5bd6d9397912f MD5 | raw file
  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_07) on Fri Jan 16 20:00:56 PST 2009 -->
  6. <TITLE>
  7. Heap (Stanford JavaNLP API)
  8. </TITLE>
  9. <META NAME="date" CONTENT="2009-01-16">
  10. <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
  11. <SCRIPT type="text/javascript">
  12. function windowTitle()
  13. {
  14. if (location.href.indexOf('is-external=true') == -1) {
  15. parent.document.title="Heap (Stanford JavaNLP API)";
  16. }
  17. }
  18. </SCRIPT>
  19. <NOSCRIPT>
  20. </NOSCRIPT>
  21. </HEAD>
  22. <BODY BGCOLOR="white" onload="windowTitle();">
  23. <HR>
  24. <!-- ========= START OF TOP NAVBAR ======= -->
  25. <A NAME="navbar_top"><!-- --></A>
  26. <A HREF="#skip-navbar_top" title="Skip navigation links"></A>
  27. <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
  28. <TR>
  29. <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
  30. <A NAME="navbar_top_firstrow"><!-- --></A>
  31. <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  32. <TR ALIGN="center" VALIGN="top">
  33. <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  34. <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  35. <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  36. <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  37. <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  38. <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  39. <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  40. </TR>
  41. </TABLE>
  42. </TD>
  43. <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
  44. </EM>
  45. </TD>
  46. </TR>
  47. <TR>
  48. <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  49. &nbsp;<A HREF="../../../../edu/stanford/nlp/util/HasIntegerIdentity.html" title="interface in edu.stanford.nlp.util"><B>PREV CLASS</B></A>&nbsp;
  50. &nbsp;<A HREF="../../../../edu/stanford/nlp/util/Index.html" title="class in edu.stanford.nlp.util"><B>NEXT CLASS</B></A></FONT></TD>
  51. <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  52. <A HREF="../../../../index.html?edu/stanford/nlp/util/Heap.html" target="_top"><B>FRAMES</B></A> &nbsp;
  53. &nbsp;<A HREF="Heap.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
  54. &nbsp;<SCRIPT type="text/javascript">
  55. <!--
  56. if(window==top) {
  57. document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  58. }
  59. //-->
  60. </SCRIPT>
  61. <NOSCRIPT>
  62. <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
  63. </NOSCRIPT>
  64. </FONT></TD>
  65. </TR>
  66. <TR>
  67. <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  68. SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
  69. <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  70. DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
  71. </TR>
  72. </TABLE>
  73. <A NAME="skip-navbar_top"></A>
  74. <!-- ========= END OF TOP NAVBAR ========= -->
  75. <HR>
  76. <!-- ======== START OF CLASS DATA ======== -->
  77. <H2>
  78. <FONT SIZE="-1">
  79. edu.stanford.nlp.util</FONT>
  80. <BR>
  81. Interface Heap&lt;E&gt;</H2>
  82. <DL>
  83. <DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../../edu/stanford/nlp/util/ArrayHeap.html" title="class in edu.stanford.nlp.util">ArrayHeap</A></DD>
  84. </DL>
  85. <HR>
  86. <DL>
  87. <DT><PRE>public interface <B>Heap&lt;E&gt;</B></DL>
  88. </PRE>
  89. <P>
  90. Heap interface.
  91. These heaps implement a decreaseKey operation, which requires
  92. a separate Object to Index map, and for objects to be unique in the Heap.
  93. <p/>
  94. An interface cannot specify constructors, but it is nevertheless
  95. expected that an implementation of this interface has a constructor
  96. that takes a Comparator, which is used for ordering ("scoring")
  97. objects:
  98. <code>public Heap(Comparator cmp) {}</code>
  99. <P>
  100. <P>
  101. <DL>
  102. <DT><B>Author:</B></DT>
  103. <DD>Dan Klein</DD>
  104. </DL>
  105. <HR>
  106. <P>
  107. <!-- ========== METHOD SUMMARY =========== -->
  108. <A NAME="method_summary"><!-- --></A>
  109. <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
  110. <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
  111. <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
  112. <B>Method Summary</B></FONT></TH>
  113. </TR>
  114. <TR BGCOLOR="white" CLASS="TableRowColor">
  115. <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
  116. <CODE>&nbsp;boolean</CODE></FONT></TD>
  117. <TD><CODE><B><A HREF="../../../../edu/stanford/nlp/util/Heap.html#add(E)">add</A></B>(<A HREF="../../../../edu/stanford/nlp/util/Heap.html" title="type parameter in Heap">E</A>&nbsp;o)</CODE>
  118. <BR>
  119. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Adds the object to the heap.</TD>
  120. </TR>
  121. <TR BGCOLOR="white" CLASS="TableRowColor">
  122. <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
  123. <CODE>&nbsp;int</CODE></FONT></TD>
  124. <TD><CODE><B><A HREF="../../../../edu/stanford/nlp/util/Heap.html#decreaseKey(E)">decreaseKey</A></B>(<A HREF="../../../../edu/stanford/nlp/util/Heap.html" title="type parameter in Heap">E</A>&nbsp;o)</CODE>
  125. <BR>
  126. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Raises the priority of an object in the heap.</TD>
  127. </TR>
  128. <TR BGCOLOR="white" CLASS="TableRowColor">
  129. <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
  130. <CODE>&nbsp;<A HREF="../../../../edu/stanford/nlp/util/Heap.html" title="type parameter in Heap">E</A></CODE></FONT></TD>
  131. <TD><CODE><B><A HREF="../../../../edu/stanford/nlp/util/Heap.html#extractMin()">extractMin</A></B>()</CODE>
  132. <BR>
  133. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the minimum object, then removes that object from the heap.</TD>
  134. </TR>
  135. <TR BGCOLOR="white" CLASS="TableRowColor">
  136. <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
  137. <CODE>&nbsp;boolean</CODE></FONT></TD>
  138. <TD><CODE><B><A HREF="../../../../edu/stanford/nlp/util/Heap.html#isEmpty()">isEmpty</A></B>()</CODE>
  139. <BR>
  140. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns true iff the heap is empty.</TD>
  141. </TR>
  142. <TR BGCOLOR="white" CLASS="TableRowColor">
  143. <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
  144. <CODE>&nbsp;<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Iterator.html?is-external=true" title="class or interface in java.util">Iterator</A>&lt;<A HREF="../../../../edu/stanford/nlp/util/Heap.html" title="type parameter in Heap">E</A>&gt;</CODE></FONT></TD>
  145. <TD><CODE><B><A HREF="../../../../edu/stanford/nlp/util/Heap.html#iterator()">iterator</A></B>()</CODE>
  146. <BR>
  147. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an iterator over its elements, in order.</TD>
  148. </TR>
  149. <TR BGCOLOR="white" CLASS="TableRowColor">
  150. <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
  151. <CODE>&nbsp;<A HREF="../../../../edu/stanford/nlp/util/Heap.html" title="type parameter in Heap">E</A></CODE></FONT></TD>
  152. <TD><CODE><B><A HREF="../../../../edu/stanford/nlp/util/Heap.html#min()">min</A></B>()</CODE>
  153. <BR>
  154. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the minimum Object in this heap.</TD>
  155. </TR>
  156. <TR BGCOLOR="white" CLASS="TableRowColor">
  157. <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
  158. <CODE>&nbsp;int</CODE></FONT></TD>
  159. <TD><CODE><B><A HREF="../../../../edu/stanford/nlp/util/Heap.html#size()">size</A></B>()</CODE>
  160. <BR>
  161. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The number of elements currently in the heap.</TD>
  162. </TR>
  163. </TABLE>
  164. &nbsp;
  165. <P>
  166. <!-- ============ METHOD DETAIL ========== -->
  167. <A NAME="method_detail"><!-- --></A>
  168. <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
  169. <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
  170. <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
  171. <B>Method Detail</B></FONT></TH>
  172. </TR>
  173. </TABLE>
  174. <A NAME="extractMin()"><!-- --></A><H3>
  175. extractMin</H3>
  176. <PRE>
  177. <A HREF="../../../../edu/stanford/nlp/util/Heap.html" title="type parameter in Heap">E</A> <B>extractMin</B>()</PRE>
  178. <DL>
  179. <DD>Returns the minimum object, then removes that object from the heap.
  180. <P>
  181. <DD><DL>
  182. <DT><B>Returns:</B><DD>the minimum object</DL>
  183. </DD>
  184. </DL>
  185. <HR>
  186. <A NAME="min()"><!-- --></A><H3>
  187. min</H3>
  188. <PRE>
  189. <A HREF="../../../../edu/stanford/nlp/util/Heap.html" title="type parameter in Heap">E</A> <B>min</B>()</PRE>
  190. <DL>
  191. <DD>Returns the minimum Object in this heap. The heap is not modified.
  192. <P>
  193. <DD><DL>
  194. <DT><B>Returns:</B><DD>the minimum object</DL>
  195. </DD>
  196. </DL>
  197. <HR>
  198. <A NAME="add(java.lang.Object)"><!-- --></A><A NAME="add(E)"><!-- --></A><H3>
  199. add</H3>
  200. <PRE>
  201. boolean <B>add</B>(<A HREF="../../../../edu/stanford/nlp/util/Heap.html" title="type parameter in Heap">E</A>&nbsp;o)</PRE>
  202. <DL>
  203. <DD>Adds the object to the heap. If the object is in the heap, this
  204. should act as a decrease-key (if the new version has better
  205. priority) or a no-op (otherwise).
  206. <P>
  207. <DD><DL>
  208. <DT><B>Parameters:</B><DD><CODE>o</CODE> - a new element
  209. <DT><B>Returns:</B><DD>true, always</DL>
  210. </DD>
  211. </DL>
  212. <HR>
  213. <A NAME="size()"><!-- --></A><H3>
  214. size</H3>
  215. <PRE>
  216. int <B>size</B>()</PRE>
  217. <DL>
  218. <DD>The number of elements currently in the heap.
  219. <P>
  220. <DD><DL>
  221. <DT><B>Returns:</B><DD>the heap's size</DL>
  222. </DD>
  223. </DL>
  224. <HR>
  225. <A NAME="isEmpty()"><!-- --></A><H3>
  226. isEmpty</H3>
  227. <PRE>
  228. boolean <B>isEmpty</B>()</PRE>
  229. <DL>
  230. <DD>Returns true iff the heap is empty.
  231. <P>
  232. <DD><DL>
  233. <DT><B>Returns:</B><DD>a <code>boolean</code> value</DL>
  234. </DD>
  235. </DL>
  236. <HR>
  237. <A NAME="decreaseKey(java.lang.Object)"><!-- --></A><A NAME="decreaseKey(E)"><!-- --></A><H3>
  238. decreaseKey</H3>
  239. <PRE>
  240. int <B>decreaseKey</B>(<A HREF="../../../../edu/stanford/nlp/util/Heap.html" title="type parameter in Heap">E</A>&nbsp;o)</PRE>
  241. <DL>
  242. <DD>Raises the priority of an object in the heap. This works in a
  243. somewhat unusual way -- the object <code>o</code> should have
  244. changed with respect to the comparator passed in to the heap on
  245. construction. However, it should NOT have changed with respect
  246. to its equals() method. This is unlike the Java SortedSet where
  247. the comparator should be consistent with equals(); here they
  248. should not match.
  249. <P>
  250. <DD><DL>
  251. <DT><B>Parameters:</B><DD><CODE>o</CODE> - an <code>Object</code> value which has changed wrt the heap's ordering
  252. <DT><B>Returns:</B><DD>the cost of the decrease-key operation, for analysis</DL>
  253. </DD>
  254. </DL>
  255. <HR>
  256. <A NAME="iterator()"><!-- --></A><H3>
  257. iterator</H3>
  258. <PRE>
  259. <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Iterator.html?is-external=true" title="class or interface in java.util">Iterator</A>&lt;<A HREF="../../../../edu/stanford/nlp/util/Heap.html" title="type parameter in Heap">E</A>&gt; <B>iterator</B>()</PRE>
  260. <DL>
  261. <DD>Returns an iterator over its elements, in order.
  262. <P>
  263. <DD><DL>
  264. <DT><B>Returns:</B><DD>an <code>Iterator</code> value</DL>
  265. </DD>
  266. </DL>
  267. <!-- ========= END OF CLASS DATA ========= -->
  268. <HR>
  269. <!-- ======= START OF BOTTOM NAVBAR ====== -->
  270. <A NAME="navbar_bottom"><!-- --></A>
  271. <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
  272. <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
  273. <TR>
  274. <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
  275. <A NAME="navbar_bottom_firstrow"><!-- --></A>
  276. <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  277. <TR ALIGN="center" VALIGN="top">
  278. <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  279. <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  280. <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  281. <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  282. <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  283. <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  284. <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  285. </TR>
  286. </TABLE>
  287. </TD>
  288. <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
  289. </EM>
  290. </TD>
  291. </TR>
  292. <TR>
  293. <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  294. &nbsp;<A HREF="../../../../edu/stanford/nlp/util/HasIntegerIdentity.html" title="interface in edu.stanford.nlp.util"><B>PREV CLASS</B></A>&nbsp;
  295. &nbsp;<A HREF="../../../../edu/stanford/nlp/util/Index.html" title="class in edu.stanford.nlp.util"><B>NEXT CLASS</B></A></FONT></TD>
  296. <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  297. <A HREF="../../../../index.html?edu/stanford/nlp/util/Heap.html" target="_top"><B>FRAMES</B></A> &nbsp;
  298. &nbsp;<A HREF="Heap.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
  299. &nbsp;<SCRIPT type="text/javascript">
  300. <!--
  301. if(window==top) {
  302. document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  303. }
  304. //-->
  305. </SCRIPT>
  306. <NOSCRIPT>
  307. <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
  308. </NOSCRIPT>
  309. </FONT></TD>
  310. </TR>
  311. <TR>
  312. <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  313. SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
  314. <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  315. DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
  316. </TR>
  317. </TABLE>
  318. <A NAME="skip-navbar_bottom"></A>
  319. <!-- ======== END OF BOTTOM NAVBAR ======= -->
  320. <HR>
  321. <FONT SIZE=2><A HREF="http://nlp.stanford.edu">Stanford NLP Group</A></FONT>
  322. </BODY>
  323. </HTML>