Implemented the bag class with counted reference pointers

CVUT name: tolmeval