]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - include/Stack.h
Import of fix-ranges branch
[thirdparty/squid.git] / include / Stack.h
index 30abb4bc9ee4594181b255d61dd19700d14989bc..c03a0f265553339f1fd3681ed65ed79ec1acb438 100644 (file)
@@ -1,15 +1,19 @@
 /*
- * $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"
 
@@ -38,8 +42,27 @@ typedef Array Stack;
 #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 */