quakeforge/tools/qfcc/include/set.h

80 lines
2.2 KiB
C
Raw Normal View History

2012-08-04 12:49:38 +00:00
/*
set.h
Set manipulation.
Copyright (C) 2012 Bill Currie <bill@taniwha.org>
Author: Bill Currie <bill@taniwha.org>
Date: 2012/8/4
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifndef set_h
#define set_h
/** \defgroup qfcc_set Set handling
\ingroup qfcc
*/
//@{
typedef struct set_s {
struct set_s *next; //< private. for ALLOC
2012-08-04 12:49:38 +00:00
unsigned *map;
unsigned size;
2012-08-04 12:49:38 +00:00
unsigned defmap[8];
} set_t;
typedef struct set_iter_s {
struct set_iter_s *next; //< private. for ALLOC
const set_t *set;
/** The result of set_first() or set_next(). set_next() will start at the
following member.
*/
unsigned member;
} set_iter_t;
void set_del_iter (set_iter_t *set_iter);
2012-08-04 12:49:38 +00:00
set_t *set_new (void);
void set_delete (set_t *set);
void set_add (set_t *set, unsigned x);
void set_remove (set_t *set, unsigned x);
set_t *set_union (set_t *dst, const set_t *src);
set_t *set_intersection (set_t *dst, const set_t *src);
set_t *set_difference (set_t *dst, const set_t *src);
set_t *set_assign (set_t *dst, const set_t *src);
set_t *set_empty (set_t *set);
int set_is_empty (const set_t *set);
int set_is_disjoint (const set_t *s1, const set_t *s2);
int set_is_intersecting (const set_t *s1, const set_t *s2);
int set_is_equivalent (const set_t *s1, const set_t *s2);
int set_is_subset (const set_t *set, const set_t *sub);
int set_is_member (const set_t *set, unsigned x);
unsigned set_size (const set_t *set);
set_iter_t *set_first (const set_t *set);
set_iter_t *set_next (set_iter_t *set_iter);
2012-10-30 11:10:25 +00:00
const char *set_as_string (const set_t *set);
2012-08-04 12:49:38 +00:00
//@}
#endif//set_h