comparison clustalomega/clustal-omega-0.2.0/src/clustal/list.h @ 0:ff1768533a07

Migrated tool version 0.2 from old tool shed archive to new tool shed repository
author clustalomega
date Tue, 07 Jun 2011 17:04:25 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:ff1768533a07
1 /*********************************************************************
2 * Clustal Omega - Multiple sequence alignment
3 *
4 * Copyright (C) 2010 University College Dublin
5 *
6 * Clustal-Omega is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This file is part of Clustal-Omega.
12 *
13 ********************************************************************/
14
15 /*
16 * RCS $Id: list.h 193 2011-02-07 15:45:21Z andreas $
17 *
18 * Generic single linked list storing pointers to data
19 *
20 */
21
22 #ifndef CLUSTALO_LIST_H
23 #define CLUSTALO_LIST_H
24
25 #include <stdlib.h>
26
27 typedef struct list_elem_s {
28 void *data;
29 struct list_elem_s *next;
30 } list_elem_t;
31
32 typedef struct {
33 /* size of list */
34 int size;
35 /* user defined function for freeing data */
36 void (*destroy)(void *data);
37 list_elem_t *head;
38 list_elem_t *tail;
39 } list_t;
40
41 void ListInit(list_t *prList, void (*destroy)(void *data));
42
43 void ListDestroy(list_t *prList);
44
45 int ListInsertNext(list_t *prList, list_elem_t *prElement, const void *data);
46
47 #define LIST_APPEND(prList, data) ListInsertNext((prList), LIST_TAIL(prList), (data))
48
49 #define LIST_PREPEND(prList, data) ListInsertNext((prList), CLUSTALO_LIST_HEAD(prList), (data))
50
51 int ListRemoveNext(list_t *prList, list_elem_t *prElement, void **data);
52
53 #define LIST_SIZE(prList) ((prList)->size)
54
55 #define CLUSTALO_LIST_HEAD(prList) ((prList)->head)
56
57 #define LIST_TAIL(prList) ((prList)->tail)
58
59 #define LIST_IS_HEAD(prList, prElement) ((prElement) == (prList)->head ? 1 : 0)
60
61 #define LIST_IS_TAIL(prElement) ((prElement)->next == NULL ? 1 : 0)
62
63 #define LIST_DATA(prElement) ((prElement)->data)
64
65 #define LIST_NEXT(prElement) ((prElement)->next)
66
67
68
69
70
71 /* special int list: stores ints by copying them (instead of storing
72 * pointers as generic list)
73 *
74 */
75
76 typedef list_t int_list_t;
77
78 #define INT_LIST_INIT(prList) ListInit((prList), free)
79
80 #define INT_LIST_DESTROY(prList) ListDestroy((prList));
81
82 int IntListInsertNext(list_t *prList, list_elem_t *prElement, const int data);
83
84 #define INT_LIST_APPEND(prList, data) IntListInsertNext((prList), LIST_TAIL(prList), (data))
85
86 #define INT_LIST_PREPEND(prList, data) IntListInsertNext((prList), CLUSTALO_LIST_HEAD(prList), (data))
87
88 int IntListRemoveNext(list_t *prList, list_elem_t *prElement, int *data);
89
90 #define INT_LIST_SIZE(prList) LIST_SIZE(prList)
91
92 #define INT_CLUSTALO_LIST_HEAD(prList) CLUSTALO_LIST_HEAD_INT((prList))
93
94 #define INT_LIST_TAIL(prList) LIST_TAIL_INT((prList) )
95
96 #define INT_LIST_IS_HEAD(prList, prElement) LIST_IS_HEAD(prList, prElement)
97
98 #define INT_LIST_IS_TAIL(prElement) LIST_IS_TAIL((prElement))
99
100 #define INT_LIST_DATA(prElement) LIST_DATA((prElement))
101
102 #define INT_LIST_NEXT(prElement) LIST_NEXT((prElement))
103
104
105 #endif