How to do sets?

Mike McNelly mike at hpfcdc.HP.COM
Sat Mar 18 02:43:07 AEST 1989


> This may be a dumb question, but I haven't been able to find anyone yet who
> could answer it...

> Is there a way to do sets in C (like in Pascal)?  That is, check for set
> inclusion (char in ["0".."9"]), and perform unions and intersections.  And the
> answer is not "use bitwise operators," I already know how to do that and would
> rather not if there's an easier way, especially with large sets requiring 32
> bytes or more.

> Thanks.

No set operations are inherent in the C language. It's easy enough, however,
to write a library with routines to 
	1) create a set of a specified size
	2) manipulate the set (e.g. intersection)
	3) free a set
That's precisely how set operations are implemented in languages such as 
Pascal.

Sorry, I can't provide such a library since it's part of our proprietary
software.

Mike McNelly	mike%hpfcla at hplabs.hp.com



More information about the Comp.lang.c mailing list