Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: stack.h
- Revision:
- 0:71d791204057
diff -r 000000000000 -r 71d791204057 stack.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/stack.h Tue Jun 07 13:32:20 2011 +0000
@@ -0,0 +1,49 @@
+#ifndef STACK_H
+#define STACK_H
+
+template<class T>
+class Stack
+{
+public:
+ T Data[50];
+ short Position;
+
+ Stack() : Position(0) {}
+
+ inline void Push( T v ) { if( Position < 50 ) Data[Position++] = v; }
+ inline T Pull() { if( Position ) return Data[--Position]; else return (T)NAKN; }
+
+ void Pull( T &a )
+ {
+ if( Position ) a = Data[--Position];
+ else a = (T)NAKN;
+ }
+ void Pull( T &b, T &a )
+ {
+ if( Position ) b = Data[--Position];
+ else b = (T)NAKN;
+ if( Position ) a = Data[--Position];
+ else a = (T)NAKN;
+ }
+ void Pull( T &c, T &b, T &a )
+ {
+ if( Position ) c = Data[--Position];
+ else c = (T)NAKN;
+ if( Position ) b = Data[--Position];
+ else b = (T)NAKN;
+ if( Position ) a = Data[--Position];
+ else a = (T)NAKN;
+ }
+ void Pull( T &d, T &c, T &b, T &a )
+ {
+ if( Position ) d = Data[--Position];
+ else d = (T)NAKN;
+ if( Position ) c = Data[--Position];
+ else c = (T)NAKN;
+ if( Position ) b = Data[--Position];
+ else b = (T)NAKN;
+ if( Position ) a = Data[--Position];
+ else a = (T)NAKN;
+ }
+};
+#endif
\ No newline at end of file