home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / c / 11459 < prev    next >
Encoding:
Internet Message Format  |  1992-07-22  |  1.0 KB

  1. Path: sparky!uunet!mcsun!fuug!demos!kiae!glas!demos!tamsun.ta!cs.tamu.edu!tpradeep
  2. From: tpradeep@cs.tamu.edu
  3. Newsgroups: comp.lang.c
  4. Date: 17 Jul 92 18:37 MDT
  5. Subject: How to implement a bit array?
  6. Sender: Notesfile to Usenet Gateway <notes@glas.apc.org>
  7. Message-ID: <1992Jul17.143744.12549@tamsun.ta>
  8. Nf-ID: #N:1992Jul17.143744.12549@tamsun.ta:-1367172306:001:633
  9. Nf-From: cs.tamu.edu!tpradeep    Jul 17 18:37:00 1992
  10. Lines: 27
  11.  
  12.  
  13. Howdy netters,
  14.  
  15. In my project I need an array of 30000 elements which have {0,1} values only.
  16. I guesss a good way to implement this is such that each element takes just
  17. one bit. Can someone suggest me a good struct/union implementation for
  18. a bit array.
  19.  
  20. Ideally I should be able to do the following operations:
  21.  
  22.      whatever.whatever...[13467] = 1; // or 0
  23.  
  24.      if( whatever.whatever...[i] ) {  code }
  25.  
  26. However the following is acceptable ( worst case)
  27.  
  28.    BitSet(Array, 13467, 1);
  29.  
  30.    if( IsBitSet(Array, i) ) { code }
  31.  
  32.  
  33. Thank you for your help. If need be, I'll summerize the responses on the net.
  34.  
  35. Pradeep
  36. tpradeep@cs.tamu.edu
  37.  
  38.  
  39.