TPIE

2362a60
internal_stack.h
Go to the documentation of this file.
1 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
2 // vi:set ts=4 sts=4 sw=4 noet :
3 // Copyright 2010, 2012, The TPIE development team
4 //
5 // This file is part of TPIE.
6 //
7 // TPIE is free software: you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the
9 // Free Software Foundation, either version 3 of the License, or (at your
10 // option) any later version.
11 //
12 // TPIE is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with TPIE. If not, see <http://www.gnu.org/licenses/>
19 #ifndef __TPIE_INTERNAL_STACK_H__
20 #define __TPIE_INTERNAL_STACK_H__
21 
26 #include <tpie/array.h>
27 #include <tpie/util.h>
29 namespace tpie {
30 
36 template <typename T>
37 class internal_stack: public internal_stack_vector_base<T,internal_stack<T> > {
38 public:
40 
46 
48  using parent_t::m_size;
49 
53  inline T & top() {return m_elements[m_size-1];}
54 
62  inline void push(const T & val){m_elements[m_size++] = val;}
63 
67  inline void pop(){--m_size;}
68 
69 };
70 
71 }
72 #endif //__TPIE_INTERNAL_STACK_H__
T & top()
Return the topmost element on the stack.
size_t m_size
Number of elements pushed to the structure.
A generic internal stack.
Generic base for internal stack and vector with known memory requirements.
size_t size() const
Return the number of elements in the data structure.
A base class for a generic internal fixed size stack and vector.
Generic internal array with known memory requirements.
void pop()
Remove the topmost element from the stack.
Miscellaneous utility functions.
internal_stack(size_t size=0)
Construct structure with given capacity.
void push(const T &val)
Add an element to the top of the stack.