reinventing the wheel of c++ container