I have a doubly-linked-list template class, OK, great.
My class has member functions (among others):
1) int sorted() -checks to see if the list is in fact sorted. Returns "1" if sorted in ascending order, "-1" if sorted in descending order, or "0" if not sorted at all.
2) void sort() -sorts the list in ascending order.
3) void revsort() -sorts the list descending order.
4) void insert(const T& X) -inserts (X) into a list. Only inserts if list is sorted in ascending order. If the list is not sorted in ascending order, sort() is called, the list is sorted in ascending order, and the insertion is performed.
5) void revins(const T& X) -same as insert(). Its the same as insert, but traverses the list from the tail. It's important to note that this function, like insert(), takes respect to a list sorted in "ascending" order as well. I'll explain the purpose of this in the next function...
6) void ins(const T& X) -this function "chooses" insert() or revins() depending on whether (X) is closer to the head or tail of the list. I included this for cases where the list might be thousands or hundreds of thousands entries long.
Whoopty friggin' doo! (I'm sure you're thinking it!)
I don't really have a question, rather, I just want to get your ideas on how to handle some of these ambiguities:
-what if my list is in descending oreder?
-do i sort ascending, insert, then sort descending?
-how do i know if the user of the class wants one kind of functionality or another?
-do write into my template 3 more insertion functions to handle "descending lists"? If so, how is the end-user effected by this?
-what if i don't want the list sorted at all? is it possible to keep insert from being called unintentionally?
I know these are pretty open-ended questions, with a lot of different answers/solutions. Just like to hear others' thoughts and maybe what the "standards" are (if any) on writing lists.