-
Notifications
You must be signed in to change notification settings - Fork 2
/
lists.c
61 lines (61 loc) · 1.13 KB
/
lists.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdlib.h>
#include <stdio.h>
#include <utils.h>
#include "params.h"
#include "zargs.h"
#include "lists.h"
void list_swap(particle *p){
LIST_SWAP(p->new_list,p->old_list);
SWAP(p->en_old,p->en_new);
}
void adjust_lists(particle *p){
unsigned int i,j,in;
particle *q;
for(i=0;i<p->en_new;i++){
for(j=0,in=0;!in&&j<p->en_old;j++){
if(p->new_list[i]==p->old_list[j]){
p->old_list[j]=p->old_list[--p->en_old];
in=1;
}
}
if(!in){
q=p->new_list[i];
q->new_list[q->en_new++]=p;
}
}
for(i=0;i<p->en_old;i++){
q=p->old_list[i];
for(j=0;j<q->en_new;j++)
if(q->new_list[j]==p){
q->new_list[j]=q->new_list[--q->en_new];
break;
}
}
return;
}
void delete_lists(particle *p){
unsigned int i,j;
particle *q;
for(i=0;i<p->en_new;i++){
q=p->new_list[i];
for(j=0;j<q->en_new;j++)
if(q->new_list[j]==p){
q->new_list[j]=q->new_list[--q->en_new];
break;
}
}
return;
}
void swap_lists(particle *p,particle *w){
unsigned int i,j;
particle *q;
for(i=0;i<p->en_new;i++){
q=p->new_list[i];
for(j=0;j<q->en_new;j++)
if(q->new_list[j]==p){
q->new_list[j]=w;
break;
}
}
return;
}