?? queuearray.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:18 EDT 2002 --><TITLE>: Class QueueArray</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/PriorityVector.html"><B>PREV CLASS</B></A> <A HREF="../structure/QueueList.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="QueueArray.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <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>Class QueueArray</H2><PRE><A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html">java.lang.Object</A> | +--<A HREF="../structure/AbstractStructure.html">structure.AbstractStructure</A> | +--<A HREF="../structure/AbstractLinear.html">structure.AbstractLinear</A> | +--<A HREF="../structure/AbstractQueue.html">structure.AbstractQueue</A> | +--<B>structure.QueueArray</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../structure/Linear.html">Linear</A>, <A HREF="../structure/Queue.html">Queue</A>, <A HREF="../structure/Structure.html">Structure</A></DD></DL><HR><DL><DT>public class <B>QueueArray</B><DT>extends <A HREF="../structure/AbstractQueue.html">AbstractQueue</A><DT>implements <A HREF="../structure/Queue.html">Queue</A></DL><P>An implementation of queues based on arrays. The head of the queue starts out at the head of the array, allowing the queue to grow and shrink in constant time. This queue implementation is ideal for applications that require a queue with a known maximum size that expands in constant time. <P> Example usage: <P> To compute the sum of the unicode value of every character in the standard input we could use the following: <P> <pre> public static void main(String[] arguments) { int charsInInput = QueueExample.countChars(argument); <A HREF="../structure/QueueArray.html"><CODE>QueueArray</CODE></A> q = new <A HREF="../structure/QueueArray.html#QueueArray(int)"><CODE>QueueArray(charsInInput)</CODE></A>; int unicodeSum = 0; if(arguments.length > 0){ for(int i=0; i < arguments.length; i++){ for(int j=0; j < arguments[i].length(); j++){ q.<A HREF="../structure/AbstractQueue.html#enqueue(java.lang.Object)"><CODE>enqueue(new Character(arguments[i].charAt(j)))</CODE></A>; } } } while(!q.<A HREF="../structure/AbstractLinear.html#empty()"><CODE>AbstractLinear.empty()</CODE></A>){ char c = ((Character)q.<A HREF="../structure/AbstractQueue.html#dequeue()"><CODE>AbstractQueue.dequeue()</CODE></A>).charValue(); unicodeSum+=Character.getNumericValue(c); } System.out.println("Total Value: " + unicodeSum); } </pre><P><DL><DT><B>See Also: </B><DD><A HREF="../structure/QueueList.html"><CODE>QueueList</CODE></A>, <A HREF="../structure/QueueVector.html"><CODE>QueueVector</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected int</CODE></FONT></TD><TD><CODE><B><A HREF="../structure/QueueArray.html#count">count</A></B></CODE><BR> current size of queue</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html">Object</A>[]</CODE></FONT></TD><TD><CODE><B><A HREF="../structure/QueueArray.html#data">data</A></B></CODE><BR> The references to values stored within the queue.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected int</CODE></FONT></TD><TD><CODE><B><A HREF="../structure/QueueArray.html#head">head</A></B></CODE><BR> index of the head of queue.</TD></TR></TABLE> <!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../structure/QueueArray.html#QueueArray(int)">QueueArray</A></B>(int size)</CODE><BR> Construct a queue holding at most size elements.</TD></TR></TABLE> <!-- ========== 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/QueueArray.html#add(java.lang.Object)">add</A></B>(<A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html">Object</A> value)</CODE><BR> Add a value to the tail of the queue.</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/QueueArray.html#clear()">clear</A></B>()</CODE><BR> Remove all the values from the queue.</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/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../structure/QueueArray.html#get()">get</A></B>()</CODE><BR> Fetch the value at the head of the queue.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../structure/QueueArray.html#isEmpty()">isEmpty</A></B>()</CODE><BR> Determine if the queue is empty.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../structure/QueueArray.html#isFull()">isFull</A></B>()</CODE><BR> Determines if the queue is not able to accept any new values.</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/util/Iterator.html">Iterator</A></CODE></FONT></TD><TD><CODE><B><A HREF="../structure/QueueArray.html#iterator()">iterator</A></B>()</CODE><BR> Returns an iterator for traversing the structure.</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/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../structure/QueueArray.html#remove()">remove</A></B>()</CODE><BR> Remove a value from the head of the queue.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../structure/QueueArray.html#size()">size</A></B>()</CODE><BR> Determine the number of elements within the queue</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/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../structure/QueueArray.html#toString()">toString</A></B>()</CODE><BR> Construct a string representation of the queue.</TD></TR></TABLE> <A NAME="methods_inherited_from_class_structure.AbstractQueue"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class structure.<A HREF="../structure/AbstractQueue.html">AbstractQueue</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../structure/AbstractQueue.html#dequeue()">dequeue</A>, <A HREF="../structure/AbstractQueue.html#enqueue(java.lang.Object)">enqueue</A>, <A HREF="../structure/AbstractQueue.html#getFirst()">getFirst</A>, <A HREF="../structure/AbstractQueue.html#peek()">peek</A></CODE></TD></TR></TABLE> <A NAME="methods_inherited_from_class_structure.AbstractLinear"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class structure.<A HREF="../structure/AbstractLinear.html">AbstractLinear</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../structure/AbstractLinear.html#empty()">empty</A>, <A HREF="../structure/AbstractLinear.html#remove(java.lang.Object)">remove</A></CODE></TD></TR></TABLE> <A NAME="methods_inherited_from_class_structure.AbstractStructure"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class structure.<A HREF="../structure/AbstractStructure.html">AbstractStructure</A></B></TD>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -