This is somehow far from competitive programming but recently I'm trying to get enrolled in a summer of code project with boost library ( an open source C++ library ), to get enrolled in the boost summer of code projects requires a competency test, mine was writing a simple C++11 vector-like class.
I've written an std::vector like class but not with all methods like that of the STL (it's not required to fully complete the class), so it would be appreciated to give any feedback about my code and tell me if any issues are found.
Thanks in advance :)
Hi, Tensor. I looked at your code and the it seems quite clear to me. However, you have not implemented some useful functions such as erase and insert. I also don't quite understand typedef unsigned int size_type; Don't you like size_t? And finally your implementation of clear has linear complexity but it can be done in O(1) for primitive types. For more info read a post on stackoverflow
thank you for your feedback :). Now I have changed the clear function to run in O(1), and for size_type it's just for more clarfication. For erase and insert, I just thought that emplace_back, push_back are more important than insert and erase to write in the competency test as they said a "simple" vector-like, don't you think so ?
You can't just write
this->_size = 0
. You have to deallocate the memory. No, I don't.thank you again for feedback :-)