stack.h

Go to the documentation of this file.
00001 #ifndef STACK_CLASS
00002 #define STACK_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : stack                                                             *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1990-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include <basis/array.h>
00019 
00021 
00026 template <class contents>
00027 class stack
00028 {
00029 public:
00030   enum stack_kinds { BOUNDED, UNBOUNDED };
00031 
00032   stack(int elements = 0);
00034 
00043   stack(const stack &to_copy);
00045 
00046   ~stack();
00048 
00049   void reset();
00051 
00052   stack_kinds kind() const { return _kind; }
00054 
00055   outcome push(const contents &element);
00057 
00061   outcome pop();
00063 
00066   contents &top();
00068 
00071   outcome acquire_pop(contents &to_stuff);
00073 
00076   int size() const;
00078 
00080   stack &operator =(const stack &to_copy);
00082 
00083   contents &operator [](int index);
00085 
00090   void invert();
00092 
00093   int elements() const;
00095 
00100 private:
00101   array<contents> _store;  
00102   stack_kinds _kind;  
00103   int _valid_fields;  
00104 };
00105 
00106 #endif
00107 

Generated on Fri Nov 21 04:29:41 2008 for HOOPLE Libraries by  doxygen 1.5.1