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.
Dependents: F401RE-USBHostMIDI_RecieveExample
Fork of F401RE-USBHost by
Diff: USBHost/myqueue.h
- Revision:
- 10:40c7f6788902
- Parent:
- 9:7f9f64cf5ded
- Child:
- 11:61843badd06e
diff -r 7f9f64cf5ded -r 40c7f6788902 USBHost/myqueue.h
--- a/USBHost/myqueue.h Mon Feb 03 13:00:16 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-#pragma once
-
-template<class T>
-class myqueue {
-public:
- myqueue() {
- m_w = m_r = 0;
- m_size = 0;
- m_limit = 4;
- m_buf = new T[m_limit];
- }
- void push(T v) {
- if (m_size >= m_limit) {
- int new_limit = m_limit + 4;
- T* new_buf = new T[new_limit];
- for(int i = 0; i < m_size; i++) {
- new_buf[i] = m_buf[i];
- }
- delete[] m_buf;
- m_buf = new_buf;
- m_limit = new_limit;
- }
- m_buf[m_w++] = v;
- if (m_w >= m_limit) {
- m_w = 0;
- }
- m_size++;
- }
- T pop() {
- T v = m_buf[m_r++];
- if (m_r >= m_limit) {
- m_r = 0;
- }
- m_size--;
- return v;
- }
- bool empty() { return (m_w == m_r) ? true : false; }
- int size() { return m_size; }
- void clear() { m_size = 0; }
- T at(int i) { return m_buf[i]; }
-
-private:
- int m_limit;
- int m_size;
- int m_w;
- int m_r;
- T *m_buf;
-};
