Copyright © 2008-2018, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Date: 2015sep9 Language: C++ Q. Is there a sorted list in the Standard Template Library? A. No. There are some options. 1. Usually the best way is to use std::set() It promises to keep everything in order. Call myset.insert() to add stuff and iterate starting with myset.begin() 2. You can just do a sort() after each push_back()list.push_back(n); list.sort();This is fine for very small lists. 3. You can use sorted_vector<>
Add a commentSign in to add a comment