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.
Fork of F401RE-USBHost by
myvector.h
00001 #pragma once 00002 00003 template<class T> 00004 class myvector { 00005 public: 00006 myvector() { 00007 m_size = 0; 00008 m_buf = NULL; 00009 } 00010 ~myvector() { 00011 if (m_buf) { 00012 delete[] m_buf; 00013 } 00014 } 00015 void push_back(T v) { 00016 T* new_buf = new T[m_size+1]; 00017 if (m_size > 0) { 00018 for(int i = 0; i < m_size; i++) { 00019 new_buf[i] = m_buf[i]; 00020 } 00021 delete[] m_buf; 00022 } 00023 m_buf = new_buf; 00024 m_buf[m_size++] = v; 00025 } 00026 T& operator[](const int index) { 00027 return m_buf[index]; 00028 } 00029 int size() { return m_size; } 00030 00031 private: 00032 int m_size; 00033 T *m_buf; 00034 };
Generated on Tue Jul 12 2022 21:43:28 by
1.7.2
