home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume36
/
formes
/
part01
/
collect.h
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-01
|
2KB
|
73 lines
/*
* Copyright (C) 1992-1993 Jeffrey Chilton
*
* Permission is granted to anyone to make or distribute copies of
* this program, in any medium, provided that the copyright notice
* and permission notice are preserved, and that the distributor
* grants the recipient permission for further redistribution as
* permitted by this notice.
*
* Author's E-mail address: 172-9221@mcimail.com
*
*/
/* static char *whatstring = "@(#)collect.h 2.3 JWC"; */
#ifndef COLLECT_H
#define COLLECT_H
#include <malloc.h>
/*
* Collection - a multi-purpose collection-of-pointers class
*/
typedef struct Collection Collection;
struct Collection
{
int nOfItems;
int currentLimit;
int (*match)();
void (*destroy)();
char **items;
};
#define NULLMATCH ((int (*)())0)
#define NULLDESTROY ((void (*)())0)
#ifdef __STDC__
extern Collection *Collection_new(int (*match)(), void (*destroy)());
extern char *Collection_atKeyGet(Collection *self, char *key);
extern int Collection_atKeyGetIndex(Collection *self, char *key);
extern int Collection_atKeyPut(Collection *self, char *key, char *value);
extern int Collection_atPut(Collection *self, int index, char *value);
extern int Collection_do(Collection *self, int (*block)(), char *arg);
extern void Collection_destroy(Collection *self);
#else
extern Collection *Collection_new();
extern char *Collection_atKeyGet();
extern int Collection_atKeyGetIndex();
extern int Collection_atKeyPut();
extern int Collection_atPut();
extern int Collection_do();
extern void Collection_destroy();
#endif
#define Collection_add(s, v) Collection_atPut(s, (s)->nOfItems, (char *)v)
#define Collection_atDelete(s, i) Collection_atPut(s, i, (char *)0)
#define Collection_atGet(s, i) ((s)->items[i])
#define Collection_atKeyDelete(s, k) Collection_atKeyPut(s, k, (char *)0)
#define Collection_isIn(s, k) Collection_atKeyGet(s, k)
#define Collection_size(s) ((s)->nOfItems)
#define Collection_getAll(s) ((s)->items)
#endif