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