Almetare 1.20
Alle meine Taschenrechner - Eine C++-Bibliothek zur Entwicklung von Taschenrechnern
stack.h
gehe zur Dokumentation dieser Datei
1//******************************************************************************
2// Copyright (c) 2002-2004 by Friedemann Seebass, Germany.
3// Dieses Programm ist freie Software. Siehe GNU GPL Notiz in Datei main.cpp.
4// This program is free software. See the GNU GPL notice in file main.cpp.
5// Projekt: Almetare - Alle meine Taschenrechner
6//******************************************************************************
10//******************************************************************************
11// Wann Wer Was
12// ---------- -------- ---------------------------------------------------------
13// 06.10.2001 fse erzeugt
14//******************************************************************************
15
16#ifndef STACK_H
17#define STACK_H
18
19#ifndef __cplusplus
20#error stack.h is only for C++!
21#endif
22
23//******************************************************************************
24
25#include <vector>
26#include <list>
27#include <string>
28#include <fstream>
29#include "logging.h"
30
31using namespace std;
32
33//******************************************************************************
34// Template fuer einen Stack:
35//******************************************************************************
36
79// fse, 26.09.01
80// fse, 27.10.01: Zeiger auf File-Stream zwecks Loggíng.
81
82template<class T> class Stack : public vector<T>
83{
84 list< Stack<T> >* mListP;
86public:
87 explicit Stack(list< Stack<T> >* listP = NULL) : mListP(listP) {}
88 void push(const T& x);
89 T pop();
90 T top();
91 T getTopButOne() const { return mTopButOne; }
92 bool isEmpty() const { return vector<T>::empty(); }
93 void setTopButOne(const T& x) { mTopButOne = x; }
94 void setListP(list< Stack<T> >* lP) { mListP = lP; }
95 void out(string op);
96};
97
98//******************************************************************************
99
100template<class T> ostream& operator<<(ostream& os, const Stack<T>&);
101template<class T> ostream& operator<<(ostream& os, const list<T>& );
102
103//******************************************************************************
104//************************************** ***************************************
105//************************* ************************* **************************
106
107#endif // !STACK_H
108
Template-Klasse fuer einen Stack mit Logging bei Stack-Operationen.
Definition: stack.h:83
void push(const T &x)
Push-Funktion mit Ausgabe einer Liste von Stacks.
Definition: stack.cpp:35
list< Stack< T > > * mListP
Liste von Stacks.
Definition: stack.h:84
T mTopButOne
das Element, das vor dem letzten gepusht wurde (noetig fuer "y-Register" der Casio Rechner)
Definition: stack.h:85
T pop()
Pop-Funktion mit Rueckgabe des letzten Wertes und Ausgabe einer Liste von Stacks.
Definition: stack.cpp:76
T top()
Top-Funktion mit Ausgabe der Liste, die in Klasse ComputerBase definiert ist.
Definition: stack.cpp:99
void out(string op)
Gibt Stack in Debug-Log-Datei aus.
Definition: stack.cpp:50
Klasse zum Loggen von Daten in drei verschiedene Dateien (Modul lib)
ostream & operator<<(ostream &os, const Stack< T > &)
Ausgabe eines einzelnen Stacks als durch Komma getrennte Aufzaehlung.
Definition: stack.cpp:122