SPModel: libDelaunay/src/stackpair.c Source File
VPAC - Computational Software Development
Main | SPModel | StGermain FrameWork |
Main Page | Alphabetical List | Class List | Directories | File List | Class Members | File Members

stackpair.c

Go to the documentation of this file.
00001 #include <stdlib.h>
00002 
00003 struct node
00004 { int key; struct node *next; };
00005 
00006 static struct node *heada, *za, *ta;
00007 
00008 static struct node *headb, *zb, *tb;
00009 
00010 void stackpairinit_() 
00011 {
00012     heada = (struct node *) malloc(sizeof *heada);
00013     za = (struct node *) malloc(sizeof *za);
00014     heada->next = za; heada->key=0;
00015     za->next = za;
00016     za->key = 0;
00017     
00018     headb = (struct node *) malloc(sizeof *headb);
00019     zb = (struct node *) malloc(sizeof *zb);
00020     headb->next = zb; headb->key=0;
00021     zb->next = zb;
00022     zb->key = 0;
00023 }
00024 
00025 void stackpairflush_() 
00026 {
00027     free(heada);
00028     free(headb);
00029     free(za);
00030     free(zb);
00031 }
00032 
00033 void pushpair_(pa, pb)
00034 int *pa;
00035 int *pb;
00036 {
00037     int va;
00038     int vb;
00039     va = *pa;
00040     ta = (struct node *) malloc(sizeof *ta);    
00041     ta->key = va; ta->next = heada->next;   
00042     heada->next =ta;    
00043     
00044     vb = *pb;
00045     tb = (struct node *) malloc(sizeof *tb);    
00046     tb->key = vb; tb->next = headb->next;   
00047     headb->next =tb;    
00048 }
00049 
00050 void poppair_(xa,xb)
00051 int *xa;
00052 int *xb;
00053 {
00054     ta = heada->next; heada->next = ta->next;
00055     *xa = ta->key;
00056     free(ta);
00057     tb = headb->next; headb->next = tb->next;
00058     *xb = tb->key;
00059     free(tb);
00060 }
00061 
00062 void stackpairempty_(i)
00063 int *i;
00064 { 
00065     *i = 0;
00066     if(heada->next == za) *i = 1;
00067 }
00068