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.
linearArray.h@9:68d882e457c5, 2017-03-14 (annotated)
- Committer:
- UHSLMarcus
- Date:
- Tue Mar 14 10:05:47 2017 +0000
- Revision:
- 9:68d882e457c5
- Parent:
- 2:92576523c23e
- Child:
- 10:864b79e79ca8
better item defaults. Allow peeks at any item in array
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| UHSLMarcus | 0:23c500341c13 | 1 | #ifndef LINEAR_ARRAY_H |
| UHSLMarcus | 0:23c500341c13 | 2 | #define LINEAR_ARRAY_H |
| UHSLMarcus | 0:23c500341c13 | 3 | |
| UHSLMarcus | 0:23c500341c13 | 4 | #include "mbed.h" |
| UHSLMarcus | 0:23c500341c13 | 5 | |
| UHSLMarcus | 9:68d882e457c5 | 6 | template<class type> |
| UHSLMarcus | 0:23c500341c13 | 7 | class LinearArray { |
| UHSLMarcus | 9:68d882e457c5 | 8 | public: |
| UHSLMarcus | 9:68d882e457c5 | 9 | LinearArray(int size, bool forced = false); |
| UHSLMarcus | 9:68d882e457c5 | 10 | ~LinearArray(); |
| UHSLMarcus | 9:68d882e457c5 | 11 | int push(type item); |
| UHSLMarcus | 9:68d882e457c5 | 12 | type& pop(); |
| UHSLMarcus | 9:68d882e457c5 | 13 | bool try_pop(type& item); |
| UHSLMarcus | 9:68d882e457c5 | 14 | type& peek(); |
| UHSLMarcus | 9:68d882e457c5 | 15 | type& peek(int idx); |
| UHSLMarcus | 9:68d882e457c5 | 16 | int size(); |
| UHSLMarcus | 9:68d882e457c5 | 17 | bool empty(); |
| UHSLMarcus | 9:68d882e457c5 | 18 | bool full(); |
| UHSLMarcus | 9:68d882e457c5 | 19 | int count(); |
| UHSLMarcus | 9:68d882e457c5 | 20 | private: |
| UHSLMarcus | 9:68d882e457c5 | 21 | type* _array; |
| UHSLMarcus | 9:68d882e457c5 | 22 | int _elem_count; |
| UHSLMarcus | 9:68d882e457c5 | 23 | int _array_size; |
| UHSLMarcus | 9:68d882e457c5 | 24 | int _front; |
| UHSLMarcus | 9:68d882e457c5 | 25 | int _rear; |
| UHSLMarcus | 9:68d882e457c5 | 26 | bool _forced; |
| UHSLMarcus | 0:23c500341c13 | 27 | |
| UHSLMarcus | 9:68d882e457c5 | 28 | }; |
| UHSLMarcus | 1:49758f1e1317 | 29 | |
| UHSLMarcus | 9:68d882e457c5 | 30 | #include "LinearArray.hpp" |
| UHSLMarcus | 9:68d882e457c5 | 31 | |
| UHSLMarcus | 9:68d882e457c5 | 32 | #endif /* LINEAR_ARRAY_H */ |