inc/bits.h

Go to the documentation of this file.
00001 /* bits - handle operations on arrays of bits. 
00002  *
00003  * This file is copyright 2002 Jim Kent, but license is hereby
00004  * granted for all use - public, private or commercial. */
00005 
00006 #ifndef BITS_H
00007 #define BITS_H
00008 
00009 typedef unsigned char Bits;
00010 
00011 Bits *bitAlloc(int bitCount);
00012 /* Allocate bits. */
00013 
00014 Bits *bitRealloc(Bits *b, int bitCount, int newBitCount);
00015 /* Resize a bit array.  If b is null, allocate a new array */
00016 
00017 Bits *bitClone(Bits* orig, int bitCount);
00018 /* Clone bits. */
00019 
00020 void bitFree(Bits **pB);
00021 /* Free bits. */
00022 
00023 void bitSetOne(Bits *b, int bitIx);
00024 /* Set a single bit. */
00025 
00026 void bitClearOne(Bits *b, int bitIx);
00027 /* Clear a single bit. */
00028 
00029 void bitSetRange(Bits *b, int startIx, int bitCount);
00030 /* Set a range of bits. */
00031 
00032 boolean bitReadOne(Bits *b, int bitIx);
00033 /* Read a single bit. */
00034 
00035 int bitCountRange(Bits *b, int startIx, int bitCount);
00036 /* Count number of bits set in range. */
00037 
00038 int bitFindSet(Bits *b, int startIx, int bitCount);
00039 /* Find the index of the the next set bit. */
00040 
00041 int bitFindClear(Bits *b, int startIx, int bitCount);
00042 /* Find the index of the the next clear bit. */
00043 
00044 void bitClear(Bits *b, int bitCount);
00045 /* Clear many bits (possibly up to 7 beyond bitCount). */
00046 
00047 void bitClearRange(Bits *b, int startIx, int bitCount);
00048 /* Clear a range of bits. */
00049 
00050 void bitAnd(Bits *a, Bits *b, int bitCount);
00051 /* And two bitmaps.  Put result in a. */
00052 
00053 void bitOr(Bits *a, Bits *b, int bitCount);
00054 /* Or two bitmaps.  Put result in a. */
00055 
00056 void bitXor(Bits *a, Bits *b, int bitCount);
00057 /* Xor two bitmaps.  Put result in a. */
00058 
00059 void bitNot(Bits *a, int bitCount);
00060 /* Flip all bits in a. */
00061 
00062 void bitPrint(Bits *a, int startIx, int bitCount, FILE* out);
00063 /* Print part or all of bit map as a string of 0s and 1s.  Mostly useful for
00064  * debugging */
00065 
00066 extern int bitsInByte[256];
00067 /* Lookup table for how many bits are set in a byte. */
00068 
00069 void bitsInByteInit();
00070 /* Initialize bitsInByte array. */
00071 
00072 #endif /* BITS_H */
00073 

Generated on Tue Dec 25 18:39:29 2007 for blat by  doxygen 1.5.2