Implementation of common algorithms in c++