2
Copyright (C) 2003-2006 Tommi Junttila
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License version 2
6
as published by the Free Software Foundation.
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License
14
along with this program; if not, write to the Free Software
15
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18
/* FSF address fixed in the above notice on 1 Oct 2009 by Tamas Nepusz */
20
#ifndef BLISS_KSTACK_H
21
#define BLISS_KSTACK_H
23
#include "bliss_defs.hh"
24
#include <cstdlib> // malloc
29
* A stack with fixed capacity
39
bool is_empty() const {return(cursor == entries); }
40
Type top() const {DEBUG_ASSERT(cursor > entries); return *cursor; }
42
DEBUG_ASSERT(cursor > entries);
48
DEBUG_ASSERT(cursor < entries + kapacity);
52
void clean() {cursor = entries; }
53
unsigned int size() const {return(cursor - entries);
55
Type element_at(unsigned int i) {
59
int capacity() {return kapacity; }
67
KStack<Type>::KStack() {
74
KStack<Type>::KStack(int k) {
77
entries = (Type*)malloc((k+1) * sizeof(Type));
82
void KStack<Type>::init(int k) {
87
entries = (Type*)malloc((k+1) * sizeof(Type));
92
KStack<Type>::~KStack() {