3 ms·
Yes, I noted that list container. If I need a sorted list, do I need to do that myself (which is OK though not ideal)? Or again there is some other container
by alok-g 13y ago
Yes, I noted that list container. If I need a sorted list, do I need to do that myself (which is OK though not ideal)? Or again there is some other container that can work possibly with a wrapper around it to emulate a sorted linked list?
- cmccabe 13y agoI think the thing to do is just to write a function to keep stepping through the list until you find the right place to insert, and then just use container/list. Sorry to be "that guy" who questions the question, but sorted lists aren't really a great data structure. As you probably already know, insertion is O(N), where N is the total number of elements in the list. It might be better just to use the GoLRB library, which provides some always-sorted tree structures.
- alok-g 13y agoYou are right. I had a very specific case where I needed a sorted list. I do not recall why anymore.