Loading [MathJax]/extensions/TeX/AMSmath.js
LALInspiral 5.0.3.1-6c6b863
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALInspiralBankList.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Bernd Machenschalk, Thomas Cokelaer
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20/*
21 Author Cokelaer Thomas
22 Functions to manipulate linked list.
23*/
24
25
26#include <stdio.h>
27#include <lal/LALInspiralBank.h>
28#include <lal/AVFactories.h>
29#include <lal/SeqFactories.h>
30#include <lal/LALStdio.h>
31#include <lal/FindRoot.h>
32
33/* for debugging only
34void
35print_list(CellList *head)
36{
37 if (head == NULL){
38 printf("\n");
39 }
40 else {
41 printf(" %d", head->id);
42 print_list(head->next);
43 }
44}
45*/
46
48{
49 UINT4 count = 0;
50 while (list != NULL){
51 count++;
52 list = list->next;
53 }
54 return count;
55}
56
57
58
60 CellList **headRef,
61 INT4 id)
62{
63 CellList *current;
64
65 if ((current = malloc(sizeof(*current))) == NULL) {
66 {
67 printf("Error with malloc\n");
68 exit(0);
69 }
70 }
71 current->id = id;
72 current->next = *headRef;
73 *headRef = current;
74}
75
76
77
78/*Is it used somewhere ? delete everything in principle*/
79/*
80void DeleteList(CellList **headRef)
81{
82 CellList *tmp;
83
84 while (headRef !=NULL){
85 tmp = (*headRef)->next;
86 free(headRef);
87 (*headRef) = tmp;
88 }
89
90}
91*/
92
93
94void LALListDelete(CellList **headRef, INT4 id)
95{
96 CellList *ptr = NULL;
97 CellList *prev = NULL;
98
99
100 for (ptr = *headRef; ptr != NULL; ptr= ptr->next){
101 if (id == ptr->id)
102 break;
103
104 prev = ptr;
105 }
106
107 if (ptr==NULL)
108 return ;
109
110 if (prev!=NULL){
111 prev->next = ptr->next;
112 }
113 else{
114 *headRef = ptr->next;
115 }
116
117 /* free the data here if needed such as free(ptr->id); */
118 free(ptr);
119
120 return ;
121
122
123
124}
uint32_t UINT4
int32_t INT4
UINT4 LALListLength(CellList *list)
void LALListAppend(CellList **headRef, INT4 id)
void LALListDelete(CellList **headRef, INT4 id)
This is a structure needed in the inner workings of the LALInspiralHexagonalBank code.
struct tagCellList * next