Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <class T>
- void LinkedList<T>::insertInOrder(T value, bool (*charcmp)(char, char))
- {
- if(!empty())
- {
- Elt_t<T> * Temp;
- Temp = new Elt_t<T>;
- Temp -> data = value;
- begin();
- while(Curs != NULL && charcmp(Curs ->data, Temp ->data))
- {
- Curs = Curs -> Link;
- }
- if(Curs == NULL) //tests if largest
- pushback(value);
- else if(Curs -> Pred != NULL)
- {
- Temp -> Link = Curs;
- Temp -> Pred = Curs -> Pred;
- Curs -> Pred = Temp;
- Curs = Temp ->Pred;
- Curs -> Link = Temp;
- total++;
- }//inserts if not at end of list
- else if(Curs ->Pred == NULL)//inserts if at start of list
- pushfront(value);
- }
- else//creates first item in list
- pushfront(value);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement