summaryrefslogtreecommitdiff
path: root/STL/stack.h
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1996-10-29 07:34:51 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1996-10-29 07:34:51 +0000
commit60aa7663705dd9338f66fb28384e8b31900434bb (patch)
tree8abdb06b46392187d869ab1716927aa9ed8f045f /STL/stack.h
parent1d10be0da172c415a8cb0c641d79b6b4bf0a0eb6 (diff)
downloadATCD-60aa7663705dd9338f66fb28384e8b31900434bb.tar.gz
STL files from (modified for VC++4.0) HP's implementation of STL.
Diffstat (limited to 'STL/stack.h')
-rw-r--r--STL/stack.h137
1 files changed, 137 insertions, 0 deletions
diff --git a/STL/stack.h b/STL/stack.h
new file mode 100644
index 00000000000..fbbfcff7541
--- /dev/null
+++ b/STL/stack.h
@@ -0,0 +1,137 @@
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company and Microsoft
+ * Corporation make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ */
+
+#ifndef STACK_H
+#define STACK_H
+
+#include <bool.h>
+#include <heap.h>
+
+
+/*
+ *Added by d:\\convert.pl --begin--
+ */
+namespace std {
+/*
+ *Added by d:\\convert.pl --end--
+ */
+
+template <class Container>
+class stack {
+friend bool operator==(const stack<Container>& x, const stack<Container>& y);
+friend bool operator<(const stack<Container>& x, const stack<Container>& y);
+public:
+ typedef Container::value_type value_type;
+ typedef Container::size_type size_type;
+protected:
+ Container c;
+public:
+ bool empty() const { return c.empty(); }
+ size_type size() const { return c.size(); }
+ value_type& top() { return c.back(); }
+ const value_type& top() const { return c.back(); }
+ void push(const value_type& x) { c.push_back(x); }
+ void pop() { c.pop_back(); }
+};
+
+template <class Container>
+bool operator==(const stack<Container>& x, const stack<Container>& y) {
+ return x.c == y.c;
+}
+
+template <class Container>
+bool operator<(const stack<Container>& x, const stack<Container>& y) {
+ return x.c < y.c;
+}
+
+template <class Container>
+class queue {
+friend bool operator==(const queue<Container>& x, const queue<Container>& y);
+friend bool operator<(const queue<Container>& x, const queue<Container>& y);
+public:
+ typedef Container::value_type value_type;
+ typedef Container::size_type size_type;
+protected:
+ Container c;
+public:
+ bool empty() const { return c.empty(); }
+ size_type size() const { return c.size(); }
+ value_type& front() { return c.front(); }
+ const value_type& front() const { return c.front(); }
+ value_type& back() { return c.back(); }
+ const value_type& back() const { return c.back(); }
+ void push(const value_type& x) { c.push_back(x); }
+ void pop() { c.pop_front(); }
+};
+
+template <class Container>
+bool operator==(const queue<Container>& x, const queue<Container>& y) {
+ return x.c == y.c;
+}
+
+template <class Container>
+bool operator<(const queue<Container>& x, const queue<Container>& y) {
+ return x.c < y.c;
+}
+
+template <class Container, class Compare>
+// Compare = less<Container::value_type> >
+class priority_queue {
+public:
+ typedef Container::value_type value_type;
+ typedef Container::size_type size_type;
+protected:
+ Container c;
+ Compare comp;
+public:
+ priority_queue(const Compare& x = Compare()) : c(), comp(x) {}
+ priority_queue(const value_type* first, const value_type* last,
+ const Compare& x = Compare()) : c(first, last), comp(x) {
+ make_heap(c.begin(), c.end(), comp);
+ }
+/*
+ template <class InputIterator>
+ priority_queue(InputIterator first, InputIterator last,
+ const Compare& x = Compare()) : c(first, last), comp(x) {
+ make_heap(c.begin(), c.end(), comp);
+ }
+*/
+ bool empty() const { return c.empty(); }
+ size_type size() const { return c.size(); }
+ value_type& top() { return c.front(); }
+ const value_type& top() const { return c.front(); }
+ void push(const value_type& x) {
+ c.push_back(x);
+ push_heap(c.begin(), c.end(), comp);
+ }
+ void pop() {
+ pop_heap(c.begin(), c.end(), comp);
+ c.pop_back();
+ }
+};
+
+// no equality is provided
+
+
+/*
+ *Added by d:\\convert.pl --begin--
+ */
+}
+/*
+ *Added by d:\\convert.pl --end--
+ */
+
+#endif