home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
oct93
/
graphics
/
graphtal.lha
/
Graphtal
/
ValueStack.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-17
|
1KB
|
65 lines
/*
* ValueStack.h - class definitions for fast value stack.
*
* Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
* University of Berne, Switzerland
* All rights reserved.
*
* This software may be freely copied, modified, and redistributed
* provided that this copyright notice is preserved on all copies.
*
* You may not distribute this software, in whole or in part, as part of
* any commercial product without the express consent of the authors.
*
* There is no warranty or other guarantee of fitness of this software
* for any purpose. It is provided solely "as is".
*
*/
#ifndef ValueStack_H
# define ValueStack_H
#include "Value.h"
#include "Error.h"
//___________________________________________________________ ValueStack
static const int STACK_SIZE = 10;
class ValueStack
{
public:
ValueStack();
~ValueStack();
void clear();
Value& pop();
void push(const Value& v);
private:
Value items[STACK_SIZE];
int sp;
};
inline void ValueStack::clear()
{
sp = -1;
}
inline void ValueStack::push(const Value& v)
{
if (sp >= STACK_SIZE)
Error(ERR_ABORT, "ValueStack::push stack is full");
items[++sp] = v;
}
inline Value& ValueStack::pop()
{
if (sp < 0)
Error(ERR_ABORT, "ValueStack::pop stack is empty");
return items[sp--];
}
#endif // ValueStack_H