Advertisement
Guest User

Untitled

a guest
Sep 28th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. [code]class List{
  2.    node head; //it does not hold meaningful data
  3. };
  4.  
  5. void List::List(): head(&head) //circular
  6. {}
  7.  
  8. void List::Add(double data){
  9.    node *lower_bound = &head;
  10.    while( lower_bound->next != &head and lower_bound->next->data < data )
  11.       lower_bound = lower_bound->next;
  12.    //here it holds that `lower_bound->next->data > data'
  13.    //or that we are at the end of the list
  14.    lower_bound->next = new node(data, lower_bound->next);
  15. }[/code]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement