?? mergeableheap.html
字號(hào):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Fri Aug 23 13:18:10 EDT 2002 --><TITLE>: Interface MergeableHeap</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><a href=../copyright.html target=_top>© 1998-2002 McGraw-Hill</a></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../structure/Map.html"><B>PREV CLASS</B></A> <A HREF="../structure/OrderedMap.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="MergeableHeap.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">structure</FONT><BR>Interface MergeableHeap</H2><DL><DT><B>All Superinterfaces:</B> <DD><A HREF="../structure/PriorityQueue.html">PriorityQueue</A></DD></DL><DL><DT><B>All Known Implementing Classes:</B> <DD><A HREF="../structure/SkewHeap.html">SkewHeap</A></DD></DL><HR><DL><DT>public interface <B>MergeableHeap</B><DT>extends <A HREF="../structure/PriorityQueue.html">PriorityQueue</A></DL><P>Interface describing mergeable min heaps. Min heaps are collections of Comparable data that guarantee efficient access to the smallest element in the structure. Mergeable Min heaps, also provide an efficient technique for merging two mergeable heaps of the same type. Mergeable heaps are quite similar to <A HREF="../structure/PriorityQueue.html"><CODE>PriorityQueue</CODE></A>. <P> Example Usage: </P> <pre> public static void main(String[] argv){ //initialize a new fib heap MergeableHeap programmers = new <CODE>FibHeap()</CODE>; //add programmers and their ages to heap //ages current of 7/22/2002 programmers.<A HREF="../structure/MergeableHeap.html#add(java.lang.Comparable)"><CODE>add(new ComparableAssociation(new Integer(22), "Evan"))</CODE></A>; programmers.add(new ComparableAssociation(new Integer(19), "Chris")); programmers.add(new ComparableAssociation(new Integer(20), "Shimon")); programmers.add(new ComparableAssociation(new Integer(21), "Diane")); programmers.add(new ComparableAssociation(new Integer(21), "Lida")); programmers.add(new ComparableAssociation(new Integer(20), "Rob")); programmers.add(new ComparableAssociation(new Integer(20), "Sean")); //print out programmers while(!programmers.<A HREF="../structure/PriorityQueue.html#isEmpty()"><CODE>PriorityQueue.isEmpty()</CODE></A>){ ComparableAssociation p = (ComparableAssociation)programmers.<A HREF="../structure/MergeableHeap.html#remove()"><CODE>remove()</CODE></A>; System.out.println(p.getValue() + " is " + p.getKey() + " years old."); } } </pre><P><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../structure/MergeableHeap.html#add(java.lang.Comparable)">add</A></B>(<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Comparable.html">Comparable</A> value)</CODE><BR> Add an item to this heap.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Comparable.html">Comparable</A></CODE></FONT></TD><TD><CODE><B><A HREF="../structure/MergeableHeap.html#getFirst()">getFirst</A></B>()</CODE><BR> Return the minimum value in the heap.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../structure/MergeableHeap.html#merge(structure.MergeableHeap)">merge</A></B>(<A HREF="../structure/MergeableHeap.html">MergeableHeap</A> otherHeap)</CODE><BR> Merge this heap with <code>otherHeap</code>, destroying <code>otherHeap</code> in the process.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Comparable.html">Comparable</A></CODE></FONT></TD><TD><CODE><B><A HREF="../structure/MergeableHeap.html#remove()">remove</A></B>()</CODE><BR> Returns the minimum value in the heap and deletes this value from the heap.</TD></TR></TABLE> <A NAME="methods_inherited_from_class_structure.PriorityQueue"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from interface structure.<A HREF="../structure/PriorityQueue.html">PriorityQueue</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../structure/PriorityQueue.html#clear()">clear</A>, <A HREF="../structure/PriorityQueue.html#isEmpty()">isEmpty</A>, <A HREF="../structure/PriorityQueue.html#size()">size</A></CODE></TD></TR></TABLE> <P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="merge(structure.MergeableHeap)"><!-- --></A><H3>merge</H3><PRE>public void <B>merge</B>(<A HREF="../structure/MergeableHeap.html">MergeableHeap</A> otherHeap)</PRE><DL><DD>Merge this heap with <code>otherHeap</code>, destroying <code>otherHeap</code> in the process.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>otherHeap</CODE> - Heap to be merged into this heap.<DT><B>Postcondition:</B><DD>This heap contains all of the elements formerly contained by <code>otherHeap</code>. <code>otherHeap</code> is destroyed in in the process.</DL></DD></DL><HR><A NAME="add(java.lang.Comparable)"><!-- --></A><H3>add</H3><PRE>public void <B>add</B>(<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Comparable.html">Comparable</A> value)</PRE><DL><DD>Add an item to this heap.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../structure/PriorityQueue.html#add(java.lang.Comparable)">add</A></CODE> in interface <CODE><A HREF="../structure/PriorityQueue.html">PriorityQueue</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>value</CODE> - The value to be added to the heap<DT><B>Precondition:</B><DD>value is non-null<DT><B>Postcondition:</B><DD>value is added to the heap.</DL></DD></DL><HR><A NAME="remove()"><!-- --></A><H3>remove</H3><PRE>public <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Comparable.html">Comparable</A> <B>remove</B>()</PRE><DL><DD>Returns the minimum value in the heap and deletes this value from the heap.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../structure/PriorityQueue.html#remove()">remove</A></CODE> in interface <CODE><A HREF="../structure/PriorityQueue.html">PriorityQueue</A></CODE></DL></DD><DD><DL><DT><B>Postcondition:</B><DD>Heap no longer contains the minimum value.<DT><B>Returns:</B><DD>The minumum value in the heap, or null if the heap is empty.</DL></DD></DL><HR><A NAME="getFirst()"><!-- --></A><H3>getFirst</H3><PRE>public <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Comparable.html">Comparable</A> <B>getFirst</B>()</PRE><DL><DD>Return the minimum value in the heap.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../structure/PriorityQueue.html#getFirst()">getFirst</A></CODE> in interface <CODE><A HREF="../structure/PriorityQueue.html">PriorityQueue</A></CODE></DL></DD><DD><DL><DT><B>Postcondition:</B><DD>The minimum value is returned.<DT><B>Returns:</B><DD>The minimum value in the heap.</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><a href=../copyright.html target=_top>© 1998-2002 McGraw-Hill</a></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../structure/Map.html"><B>PREV CLASS</B></A> <A HREF="../structure/OrderedMap.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="MergeableHeap.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR></BODY></HTML>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -