/*
- * $Id: Stack.h,v 1.6 1998/03/20 18:07:35 rousskov Exp $
+ * $Id: Stack.h,v 1.14 2003/01/23 00:36:47 robertc Exp $
*
* AUTHOR: Alex Rousskov
*
- * SQUID Internet Object Cache http://squid.nlanr.net/Squid/
- * --------------------------------------------------------
+ * SQUID Web Proxy Cache http://www.squid-cache.org/
+ * ----------------------------------------------------------
*
- * Squid is the result of efforts by numerous individuals from the
- * Internet community. Development is led by Duane Wessels of the
- * National Laboratory for Applied Network Research and funded by
- * the National Science Foundation.
+ * Squid is the result of efforts by numerous individuals from
+ * the Internet community; see the CONTRIBUTORS file for full
+ * details. Many organizations have provided support for Squid's
+ * development; see the SPONSORS file for full details. Squid is
+ * Copyrighted (C) 2001 by the Regents of the University of
+ * California; see the COPYRIGHT file for full details. Squid
+ * incorporates software developed and/or copyrighted by other
+ * sources; see the CREDITS file for full details.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
*
*/
-#ifndef _STACK_H_
-#define _STACK_H_
+#ifndef SQUID_STACK_H
+#define SQUID_STACK_H
#include "Array.h"
#define stackInit arrayInit
#define stackClean arrayClean
#define stackDestroy arrayDestroy
-extern void *stackPop(Stack *s);
#define stackPush arrayAppend
#define stackPrePush arrayPreAppend
-#endif /* ndef _STACK_H_ */
+template <class S>
+typename S::value_type
+stackPop(S * s)
+{
+ assert(s);
+ if (!s->count)
+ return typename S::value_type();
+ typename S::value_type result = s->items[--s->count];
+ s->items[s->count] = typename S::value_type();
+ return result;
+}
+
+/* todo, fatal on empty Top call */
+template <class S>
+typename S::value_type
+stackTop(S * s)
+{
+ assert(s);
+ return s->count ? s->items[s->count - 1] : typename S::value_type();
+}
+#endif /* SQUID_STACK_H */