kao yi
/
Boboobooov4
wu
Fork of Bov3 by
Stack.h@19:4869b10a962e, 2014-07-02 (annotated)
- Committer:
- backman
- Date:
- Wed Jul 02 03:23:07 2014 +0000
- Revision:
- 19:4869b10a962e
- Parent:
- 18:eb675df59c7f
wang
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
backman | 18:eb675df59c7f | 1 | /* |
backman | 18:eb675df59c7f | 2 | * mbed library for Stack |
backman | 18:eb675df59c7f | 3 | * Copyright (c) 2011 Hiroshi Suga |
backman | 18:eb675df59c7f | 4 | * Released under the MIT License: http://mbed.org/license/mit |
backman | 18:eb675df59c7f | 5 | */ |
backman | 18:eb675df59c7f | 6 | |
backman | 18:eb675df59c7f | 7 | /** @file Stack.h |
backman | 18:eb675df59c7f | 8 | * @brief Stack |
backman | 18:eb675df59c7f | 9 | */ |
backman | 18:eb675df59c7f | 10 | |
backman | 18:eb675df59c7f | 11 | #ifndef Stack_H |
backman | 18:eb675df59c7f | 12 | #define Stack_H |
backman | 18:eb675df59c7f | 13 | |
backman | 18:eb675df59c7f | 14 | #include "mbed.h" |
backman | 18:eb675df59c7f | 15 | |
backman | 18:eb675df59c7f | 16 | /** Stack class |
backman | 18:eb675df59c7f | 17 | */ |
backman | 18:eb675df59c7f | 18 | template <class T> |
backman | 18:eb675df59c7f | 19 | class Stack { |
backman | 18:eb675df59c7f | 20 | public: |
backman | 18:eb675df59c7f | 21 | /** init Stack class |
backman | 18:eb675df59c7f | 22 | * @param p_size size of stack |
backman | 18:eb675df59c7f | 23 | */ |
backman | 18:eb675df59c7f | 24 | Stack (int p_size); |
backman | 18:eb675df59c7f | 25 | ~Stack (); |
backman | 18:eb675df59c7f | 26 | |
backman | 18:eb675df59c7f | 27 | /** push to stack |
backman | 18:eb675df59c7f | 28 | * @param dat data |
backman | 18:eb675df59c7f | 29 | * @return data or -1:error |
backman | 18:eb675df59c7f | 30 | */ |
backman | 18:eb675df59c7f | 31 | int push (T dat); |
backman | 18:eb675df59c7f | 32 | |
backman | 18:eb675df59c7f | 33 | /** pop from stack |
backman | 18:eb675df59c7f | 34 | * @param dat data |
backman | 18:eb675df59c7f | 35 | * @return 0:ok / -1:error |
backman | 18:eb675df59c7f | 36 | */ |
backman | 18:eb675df59c7f | 37 | int pop (T *dat); |
backman | 18:eb675df59c7f | 38 | |
backman | 18:eb675df59c7f | 39 | int read (T *dat); |
backman | 18:eb675df59c7f | 40 | |
backman | 18:eb675df59c7f | 41 | void clear (); |
backman | 18:eb675df59c7f | 42 | int available (); |
backman | 18:eb675df59c7f | 43 | int use (); |
backman | 18:eb675df59c7f | 44 | |
backman | 18:eb675df59c7f | 45 | private: |
backman | 18:eb675df59c7f | 46 | T *buf; |
backman | 18:eb675df59c7f | 47 | int size; |
backman | 18:eb675df59c7f | 48 | int addr; |
backman | 18:eb675df59c7f | 49 | }; |
backman | 18:eb675df59c7f | 50 | |
backman | 18:eb675df59c7f | 51 | #endif |