Adding in a sorted bag C++
问题 I want to implement the sorted bag(collection) data structure(with a singly-linked list) in C++ and I have a problem when I want to test the add function. This is the test: SortedBag sb(relation1); (relation1 is e1<=e2) sb.add(5); std::cout << sb.size()<<" "; sb.add(6); std::cout << sb.size() << " "; sb.add(0); std::cout << sb.size() << " "; sb.add(5); std::cout << sb.size() << " "; sb.add(10); std::cout << sb.size() << " "; sb.add(8); std::cout << sb.size() << " "; And it will print 1 2 3 3