daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct Snake{
  2.     Ringlet* head;
  3.     Snake(Ringlet* _head){
  4.         head = _head;
  5.     }
  6.  
  7.     void append(Ringlet* ringlet){
  8.         Ringlet* cur = head;
  9.         while(cur->next != NULL){
  10.             cur = cur->next;
  11.         }
  12.         cur->next = ringlet;
  13.         ringlet->previous = head;
  14.     }
  15.  
  16.     void prepend(Ringlet* ringlet){
  17.         head->previous = ringlet;
  18.         ringlet->next = head;
  19.         head = ringlet;
  20.     }
  21.  
  22.     void insert(Ringlet* before, Ringlet* ringlet){
  23.         Ringlet* after = before->next;
  24.         before->next = ringlet;
  25.         ringlet->previous = before;
  26.         ringlet->next = after;
  27.         after->previous = ringlet;
  28.     }
  29.  
  30.     void remove(Ringlet* ringlet){
  31.         Ringlet* previous = ringlet->previous;
  32.         Ringlet* next = ringlet->next;
  33.         previous->next = next;
  34.         next->previous = previous;
  35.     }
  36. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top