Clustal Omega
1.1.0
|
00001 /********************************************************************* 00002 * Clustal Omega - Multiple sequence alignment 00003 * 00004 * Copyright (C) 2010 University College Dublin 00005 * 00006 * Clustal-Omega is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License as 00008 * published by the Free Software Foundation; either version 2 of the 00009 * License, or (at your option) any later version. 00010 * 00011 * This file is part of Clustal-Omega. 00012 * 00013 ********************************************************************/ 00014 00015 /* 00016 * RCS $Id: list.h 193 2011-02-07 15:45:21Z andreas $ 00017 * 00018 * Generic single linked list storing pointers to data 00019 * 00020 */ 00021 00022 #ifndef CLUSTALO_LIST_H 00023 #define CLUSTALO_LIST_H 00024 00025 #include <stdlib.h> 00026 00027 typedef struct list_elem_s { 00028 void *data; 00029 struct list_elem_s *next; 00030 } list_elem_t; 00031 00032 typedef struct { 00033 /* size of list */ 00034 int size; 00035 /* user defined function for freeing data */ 00036 void (*destroy)(void *data); 00037 list_elem_t *head; 00038 list_elem_t *tail; 00039 } list_t; 00040 00041 void ListInit(list_t *prList, void (*destroy)(void *data)); 00042 00043 void ListDestroy(list_t *prList); 00044 00045 int ListInsertNext(list_t *prList, list_elem_t *prElement, const void *data); 00046 00047 #define LIST_APPEND(prList, data) ListInsertNext((prList), LIST_TAIL(prList), (data)) 00048 00049 #define LIST_PREPEND(prList, data) ListInsertNext((prList), CLUSTALO_LIST_HEAD(prList), (data)) 00050 00051 int ListRemoveNext(list_t *prList, list_elem_t *prElement, void **data); 00052 00053 #define LIST_SIZE(prList) ((prList)->size) 00054 00055 #define CLUSTALO_LIST_HEAD(prList) ((prList)->head) 00056 00057 #define LIST_TAIL(prList) ((prList)->tail) 00058 00059 #define LIST_IS_HEAD(prList, prElement) ((prElement) == (prList)->head ? 1 : 0) 00060 00061 #define LIST_IS_TAIL(prElement) ((prElement)->next == NULL ? 1 : 0) 00062 00063 #define LIST_DATA(prElement) ((prElement)->data) 00064 00065 #define LIST_NEXT(prElement) ((prElement)->next) 00066 00067 00068 00069 00070 00071 /* special int list: stores ints by copying them (instead of storing 00072 * pointers as generic list) 00073 * 00074 */ 00075 00076 typedef list_t int_list_t; 00077 00078 #define INT_LIST_INIT(prList) ListInit((prList), free) 00079 00080 #define INT_LIST_DESTROY(prList) ListDestroy((prList)); 00081 00082 int IntListInsertNext(list_t *prList, list_elem_t *prElement, const int data); 00083 00084 #define INT_LIST_APPEND(prList, data) IntListInsertNext((prList), LIST_TAIL(prList), (data)) 00085 00086 #define INT_LIST_PREPEND(prList, data) IntListInsertNext((prList), CLUSTALO_LIST_HEAD(prList), (data)) 00087 00088 int IntListRemoveNext(list_t *prList, list_elem_t *prElement, int *data); 00089 00090 #define INT_LIST_SIZE(prList) LIST_SIZE(prList) 00091 00092 #define INT_CLUSTALO_LIST_HEAD(prList) CLUSTALO_LIST_HEAD_INT((prList)) 00093 00094 #define INT_LIST_TAIL(prList) LIST_TAIL_INT((prList) ) 00095 00096 #define INT_LIST_IS_HEAD(prList, prElement) LIST_IS_HEAD(prList, prElement) 00097 00098 #define INT_LIST_IS_TAIL(prElement) LIST_IS_TAIL((prElement)) 00099 00100 #define INT_LIST_DATA(prElement) LIST_DATA((prElement)) 00101 00102 #define INT_LIST_NEXT(prElement) LIST_NEXT((prElement)) 00103 00104 00105 #endif