Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

/magnus/back_end/Equations/include/Queue.h

Go to the documentation of this file.
00001 /*
00002  *   $Id: Queue.h,v 1.2 2000/02/09 22:10:20 bormotov Exp $
00003  */
00004 
00005 // Copyright (C) 1994 The New York Group Theory Cooperative
00006 // See magnus/doc/COPYRIGHT for the full notice.
00007 
00008 // Contents: Definition and implementation of QueueOf<T> class.
00009 //
00010 // Principal Author: Sergey Lyutikov, Dmitry Pechkin
00011 //
00012 // Status: Useable.
00013 //
00014 // Revision History:
00015 //
00016 // Special Notes:
00017 //
00018 // * To instantiate QueueOf<T>, class T must have an assignment
00019 //   operator, a copy constructor, an == operator, and destructor.
00020 //
00021 // * QueueOf class provides interface of queues for lists.
00022 //
00023 // * @dp Based on implementation of @sl's StackOf<T> class.
00024 
00025 #ifndef _QUEUE_H_
00026 #define _QUEUE_H_
00027 
00028 #include "ObjectOf.h"
00029 #include "List.h"
00030 
00031 template < class T > class QueueOf : public ListOf<T> {
00032 
00033 public:
00034 
00035   // Constructors:
00036 
00037   QueueOf( ) : ListOf<T>() { }
00038   // Default constructor makes empty Queue.
00039 
00040   QueueOf( const T& t ) : ListOf<T>(t) { }
00041   // Cast constructor T -> QueueOf<T>
00042 
00043   // copy constructor, operator=, and destructor supplied by compiler.
00044 
00045   void push( const T& t );// { append(t); }
00046 
00047   T pop( ) {
00048     T res = element( 0 );
00049     removeElementOfIndex( 0 );
00050     return res;
00051   }
00052 
00053   void popAll( ) {
00054     while ( length() ) removeElementOfIndex( 0 );
00055   }
00056 
00057   Bool isEmpty( ) const { return !length(); }
00058 
00059   Bool isntEmpty( ) const { return length(); }
00060 
00061 };
00062 
00063 #endif  // _QUEUE_H_

Generated at Tue Jun 19 09:49:35 2001 for Magnus Classes by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001