Codeforces и Polygon могут быть недоступны в период с 6 декабря, 22:00 (МСК) по 7 декабря, 00:00 (МСК) в связи с проведением технических работ. ×

Блог пользователя Tensor

Автор Tensor, 10 лет назад, По-английски

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 :)

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
10 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    10 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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 ?