/* This file implements a bit-vector integer set. Copyright (C) 2004 The University of Texas at Austin Based upon Daniel Huson's implementation. 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 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Email: usman@cs.njit.edu Mail: Usman Roshan, Department of Computer Sciences, NJIT-CCS, Computer Science Department, GITC 4400, University Heights, Newark, NJ 07102 */ /*! \file int_set.h \brief Contains definitions for an integer set structure. */ #ifndef INT_SET #define INT_SET #define IS_WORD long #define IS_WORDBYTES ((int)sizeof(long)) #define IS_WORDBITS (8*IS_WORDBYTES) #define IS_MAXBITS 100000 /*! \brief An int_set is a pointer to an int_set_struct*/ typedef struct int_set_struct* int_set; /* \brief Representation of an integer set */ struct int_set_struct { int bits; int words; int nelements; IS_WORD* data; int max; int min; }; /****** PUBLIC ******/ /*create new set*/ int_set new_int_set(const int size); /*delete set*/ void del_int_set(int_set s); /*insert integer k into set s*/ void insert_int_set(int_set s, const int k); /*remove k from s*/ void remove_int_set(int_set s, const int k); /*return the intersection of A and B. don't forget to delete the intersection after done with it*/ int_set intersect_int_set(int_set A, int_set B); /*return the union of A and B. don't forget to delete the union after done with it*/ int_set union_int_set(int_set A, int_set B); /*returns 1 if k is a member of s, 0 otherwise*/ short member_int_set(int_set s, const int k); /*print out elements of s*/ void print_int_set(int_set s); /*return size of s*/ int size_int_set(int_set s); /*return all the elements of s in array entries. entries MUST be of size at least s*/ void get_entries_int_set(int_set s, int* entries); /*return 1 if A is a subset or equal to B, 0 otherwise*/ short subseteq_int_set(int_set A, int_set B); /*return 1 if A==B, 0 otherwise*/ short equal_int_set(int_set A, int_set B); /*return smallest element of s*/ int choose_int_set(int_set s); /* returns A-B. don't forget to delete it after you're done. */ int_set diff_int_set(int_set A, int_set B); /*copy B into A, with B untouched. A must be created and not an empty pointer.*/ int_set assign_int_set(int_set A, int_set B); #endif