home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdarg.h>
- #include "sets.h"
- /***************************************************************************/
- int add_member(set *aset, int member)
- /***************************************************************************/
- /* sets a bit in the member'th bit place of the set's member record. */
- {
- int wrd,bit,i;
-
- /* check to see if the set has that many words & members */
- if(member > aset->set_size)
- return FAILURE;
-
- /* get the bit */
- bit = member % MEMBERS_PER_WORD;
-
- /* get the right word */
- i = member / MEMBERS_PER_WORD;
-
- /* test the bit to see if it's already there */
- wrd = 1 << bit;
- if(wrd & aset->word[i])
- return NOCHANGE; /* it's already there */
- else {
- /* set the bit */
- aset->word[i] |= wrd;
-
- /* update the member count */
- aset->nmembers += 1;
- }
-
- /* done */
- return SUCCESS;
-
- } /* end add_member */
-
-