home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML in Action / Dynamicke-HTML-v-akci-covermount.bin / XML / PARSER / XMLINST.EXE / classes / com / ms / xml / util / Queue.java < prev    next >
Encoding:
Java Source  |  1997-08-27  |  1.2 KB  |  65 lines

  1. /*
  2.  * @(#)Queue.java 1.0 7/29/97
  3.  * 
  4.  * Copyright (c) 1997 Microsoft, Corp. All Rights Reserved.
  5.  * 
  6.  */
  7.  
  8. package com.ms.xml.util;
  9.  
  10. import java.util.Vector;
  11.  
  12. public class Queue extends Vector 
  13. {
  14.      
  15.     /**
  16.      * Creates a new queue with no elements. 
  17.      */
  18.     public Queue()
  19.     {
  20.         super();
  21.     }
  22.  
  23.     public boolean empty()
  24.     {
  25.         return isEmpty();   
  26.     }
  27.     
  28.     /**
  29.      * Looks at the object at the front of this queue without removing it
  30.      */
  31.     public Object peek()
  32.     {
  33.         return firstElement();
  34.     }
  35.  
  36.     /**
  37.      * Removes the object at the front of queue and returns that object
  38.      */
  39.     public Object pull()
  40.     {
  41.         if( isEmpty() )
  42.             return null;
  43.  
  44.         Object first = firstElement();
  45.         removeElementAt(0);
  46.         return first;
  47.     }
  48.  
  49.     /**
  50.      * Pushes an item onto the end of this queue
  51.      */
  52.     public Object push(Object  item)
  53.     {
  54.         addElement( item );
  55.         return item;
  56.     }
  57.  
  58.     /**
  59.      * Determines if an object is in this queue. 
  60.      */
  61.     public int search(Object  o)
  62.     {
  63.         return lastIndexOf(o);
  64.     }
  65. }