fork download
  1. #include <stdio.h>
  2.  
  3. // Definitions
  4. typedef M;typedef struct M{int d;M*n;M*p;}Q;typedef struct{Q*f;Q*e;}L;Q*t;x;
  5.  
  6. // Obtain iterator on first item
  7. Q*F(L**l){return*l?(*l)->f:0;}
  8.  
  9. // Obtain iterator on last item
  10. Q*E(L**l){return*l?(*l)->e:0;}
  11.  
  12. // Move iterator to next item
  13. N(Q**t){*t=*t?(*t)->n:0;}
  14.  
  15. // Move iterator to previous item
  16. P(Q**t){*t=*t?(*t)->p:0;}
  17.  
  18. // Push Front
  19. A(L**l,int d){Q*t=(Q*)malloc(sizeof(Q));t->d=d;if(*l)(*l)->f->p=t,t->n=(*l)->f,(*l)->f=t;else(*l)=(L*)malloc(sizeof(L)),(*l)->f=t,(*l)->e=t;}
  20.  
  21. // Pop Front
  22. B(L**l){if(*l)t=(*l)->f,(*l)->f=t->n,(*l)->f->p=0,x=t->d,free(t);if(!(*l)->f)free(*l);return x;}
  23.  
  24. // Push Back
  25. C(L**l,int d){t=(Q*)malloc(sizeof(Q));t->d=d;if(*l)(*l)->e->n=t,t->p=(*l)->e,(*l)->e=t;else (*l)=(L*)malloc(sizeof(L)),(*l)->f=t,(*l)->e=t;}
  26.  
  27. // Pop Back
  28. D(L**l){if(*l)t=(*l)->e,(*l)->e=t->p,(*l)->e->n=0,x=t->d,free(t);if(!(*l)->e)free(*l);return x;}
  29.  
  30. main(void){}
  31.  
Success #stdin #stdout 0s 9280KB
stdin
Standard input is empty
stdout
Standard output is empty