home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftptest.leeds.ac.uk
/
2015.02.ftptest.leeds.ac.uk.tar
/
ftptest.leeds.ac.uk
/
bionet
/
CAE-GROUP
/
SCL-WIN3x
/
FED_PLUS.EXE
/
LINKLIST.H
< prev
next >
Wrap
C/C++ Source or Header
|
1994-07-25
|
5KB
|
179 lines
#ifndef LINKLIST_H
#define LINKLIST_H
/* $Id: linklist.h,v 1.2 1993/10/15 18:49:23 libes Exp $ */
/*
* This work was supported by the United States Government, and is
* not subject to copyright.
*
* $Log: linklist.h,v $
* Revision 1.2 1993/10/15 18:49:23 libes
* CADDETC certified
*
* Revision 1.5 1993/03/19 20:44:12 libes
* added included
*
* Revision 1.4 1993/01/19 22:17:27 libes
* *** empty log message ***
*
* Revision 1.3 1992/08/18 17:15:40 libes
* rm'd extraneous error messages
*
* Revision 1.2 1992/06/08 18:07:35 libes
* prettied up interface to print_objects_when_running
*/
/*************/
/* constants */
/*************/
#define LINK_NULL (Link)NULL
#define LIST_NULL (Linked_List)NULL
/*****************/
/* packages used */
/*****************/
#include "basic.h"
#include "memory.h"
/************/
/* typedefs */
/************/
typedef struct Linked_List *Linked_List;
#ifdef __STDC__
#else /* old C */
#endif /*__STDC__*/
/****************/
/* modules used */
/****************/
#include "error.h"
/***************************/
/* hidden type definitions */
/***************************/
typedef struct Link {
struct Link* next;
struct Link* prev;
Generic data;
} *Link;
struct Linked_List {
Link mark;
};
/********************/
/* global variables */
/********************/
#ifdef LINKLIST_C
#include "defstart.h"
#else
#include "decstart.h"
#endif /*LINKED_LIST_C*/
GLOBAL Error ERROR_empty_list INITIALLY(ERROR_none);
GLOBAL struct freelist_head LINK_fl;
GLOBAL struct freelist_head LIST_fl;
GLOBAL Linked_List LINK__l; /* for LISTcreate_with macro - ugh */
#include "de_end.h"
/******************************/
/* macro function definitions */
/******************************/
#define LINK_new() (struct Link *)MEM_new(&LINK_fl)
#define LINK_destroy(x) MEM_destroy(&LINK_fl,(Freelist *)(Generic)x)
#define LIST_new() (struct Linked_List *)MEM_new(&LIST_fl)
#define LIST_destroy(x) MEM_destroy(&LIST_fl,(Freelist *)(Generic)x)
/* following could be optimized */
#define LISTcreate_with(x) (LINK__l = LISTcreate()),\
LISTadd(LINK__l,x),\
LINK_l)
/* accessing links */
#define LINKdata(link) (link)->data
#define LINKnext(link) (link)->next
#define LINKprev(link) (link)->prev
/* iteration */
#define LISTdo(list, elt, type) \
{struct Linked_List* __l = (list); \
type elt; \
Link __p; \
if (__l) { \
for (__p = __l->mark; (__p = __p->next) != __l->mark; ) { \
(elt) = (type)((__p)->data);
#define LISTdo_links(list, link) \
{Linked_List __in = (list); \
Link link; \
if (__in != LIST_NULL) { \
for ((link) = __in->mark; ((link) = (link)->next) != __in->mark; ) {
#define LISTod }}}
/* accessing */
#define LISTpeek_first(list) \
(((struct Linked_List*)list)->mark->next->data)
/* function aliases */
#define LISTadd(list, item) LISTadd_last(list, item)
#define LISTadd_all(list, items) \
LISTdo(items, e, Generic) \
LISTadd(list, e); \
LISTod;
/***********************/
/* function prototypes */
/***********************/
extern void LISTinitialize PROTO((void));
extern Linked_List LISTcreate PROTO((void));
/*extern Linked_List LISTcreate_with PROTO((Generic));*/
extern Linked_List LISTcopy PROTO((Linked_List ));
extern Generic LISTadd_first PROTO((Linked_List, Generic));
extern Generic LISTadd_last PROTO((Linked_List, Generic));
extern Generic LISTadd_after PROTO((Linked_List, Link, Generic));
extern Generic LISTadd_before PROTO((Linked_List, Link, Generic));
extern Generic LISTremove_first PROTO((Linked_List));
extern Generic LISTremove PROTO((Linked_List, Link));
extern Generic LISTget_first PROTO((Linked_List));
extern Generic LISTget_second PROTO((Linked_List));
extern Generic LISTget_nth PROTO((Linked_List,int));
extern void LISTfree PROTO((Linked_List));
extern int LISTget_length PROTO((Linked_List));
extern int LISTempty(struct Linked_List *list);
extern void LISTinitialize(void );
extern struct Linked_List *LISTcreate(void);
extern struct Linked_List *LISTcopy(struct Linked_List *src);
extern void LISTfree(struct Linked_List *list);
extern char *LISTadd_first(struct Linked_List *list,char *item);
extern char *LISTadd_last(struct Linked_List *list,char *item);
extern char *LISTadd_after(struct Linked_List *list,struct Link *link,char *item);
extern char *LISTadd_before(struct Linked_List *list,struct Link *link,char *item);
extern char *LISTremove_first(struct Linked_List *list);
extern char *LISTremove(struct Linked_List *list,struct Link *link);
extern char *LISTget_first(struct Linked_List *list);
extern char *LISTget_second(struct Linked_List *list);
extern char *LISTget_nth(struct Linked_List *list,int n);
extern int LISTget_length(struct Linked_List *list);
/*******************************/
/* inline function definitions */
/*******************************/
Boolean
LISTempty(Linked_List list);
#endif /*LINKED_LIST_H*/