quick vector implementation similar to that in C++