inc/bits.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef unsigned char Bits

Functions

BitsbitAlloc (int bitCount)
BitsbitRealloc (Bits *b, int bitCount, int newBitCount)
BitsbitClone (Bits *orig, int bitCount)
void bitFree (Bits **pB)
void bitSetOne (Bits *b, int bitIx)
void bitClearOne (Bits *b, int bitIx)
void bitSetRange (Bits *b, int startIx, int bitCount)
boolean bitReadOne (Bits *b, int bitIx)
int bitCountRange (Bits *b, int startIx, int bitCount)
int bitFindSet (Bits *b, int startIx, int bitCount)
int bitFindClear (Bits *b, int startIx, int bitCount)
void bitClear (Bits *b, int bitCount)
void bitClearRange (Bits *b, int startIx, int bitCount)
void bitAnd (Bits *a, Bits *b, int bitCount)
void bitOr (Bits *a, Bits *b, int bitCount)
void bitXor (Bits *a, Bits *b, int bitCount)
void bitNot (Bits *a, int bitCount)
void bitPrint (Bits *a, int startIx, int bitCount, FILE *out)
void bitsInByteInit ()

Variables

int bitsInByte [256]


Typedef Documentation

typedef unsigned char Bits

Definition at line 9 of file bits.h.


Function Documentation

Bits* bitAlloc ( int  bitCount  ) 

Definition at line 51 of file bits.c.

References needLargeZeroedMem().

Referenced by maskFromUpperCaseSeq(), and nibInput().

00053 {
00054 int byteCount = ((bitCount+7)>>3);
00055 return needLargeZeroedMem(byteCount);
00056 }

Here is the call graph for this function:

Here is the caller graph for this function:

void bitAnd ( Bits a,
Bits b,
int  bitCount 
)

Definition at line 218 of file bits.c.

00220 {
00221 int byteCount = ((bitCount+7)>>3);
00222 while (--byteCount >= 0)
00223     {
00224     *a = (*a & *b++);
00225     a++;
00226     }
00227 }

void bitClear ( Bits b,
int  bitCount 
)

Definition at line 190 of file bits.c.

References zeroBytes().

00192 {
00193 int byteCount = ((bitCount+7)>>3);
00194 zeroBytes(b, byteCount);
00195 }

Here is the call graph for this function:

void bitClearOne ( Bits b,
int  bitIx 
)

Definition at line 87 of file bits.c.

References oneBit.

00089 {
00090 b[bitIx>>3] &= ~oneBit[bitIx&7];
00091 }

void bitClearRange ( Bits b,
int  startIx,
int  bitCount 
)

Definition at line 197 of file bits.c.

References leftMask, and rightMask.

00199 {
00200 int endIx = (startIx + bitCount - 1);
00201 int startByte = (startIx>>3);
00202 int endByte = (endIx>>3);
00203 int startBits = (startIx&7);
00204 int endBits = (endIx&7);
00205 int i;
00206 
00207 if (startByte == endByte)
00208     {
00209     b[startByte] &= ~(leftMask[startBits] & rightMask[endBits]);
00210     return;
00211     }
00212 b[startByte] &= ~leftMask[startBits];
00213 for (i = startByte+1; i<endByte; ++i)
00214     b[i] = 0x00;
00215 b[endByte] &= ~rightMask[endBits];
00216 }

Bits* bitClone ( Bits orig,
int  bitCount 
)

Definition at line 66 of file bits.c.

References needLargeZeroedMem().

Referenced by cloneDnaSeq().

00068 {
00069 int byteCount = ((bitCount+7)>>3);
00070 Bits* bits = needLargeZeroedMem(byteCount);
00071 memcpy(bits, orig, byteCount);
00072 return bits;
00073 }

Here is the call graph for this function:

Here is the caller graph for this function:

int bitCountRange ( Bits b,
int  startIx,
int  bitCount 
)

Definition at line 121 of file bits.c.

References bitsInByte, bitsInByteInit(), inittedBitsInByte, leftMask, and rightMask.

Referenced by gfFastFindDnaHits(), gfSegmentedFindHits(), gfSegmentedFindNearHits(), gfStraightFindHits(), and gfStraightFindNearHits().

00123 {
00124 int endIx = (startIx + bitCount - 1);
00125 int startByte = (startIx>>3);
00126 int endByte = (endIx>>3);
00127 int startBits = (startIx&7);
00128 int endBits = (endIx&7);
00129 int i;
00130 int count = 0;
00131 
00132 if (!inittedBitsInByte)
00133     bitsInByteInit();
00134 if (startByte == endByte)
00135     return bitsInByte[b[startByte] & leftMask[startBits] & rightMask[endBits]];
00136 count = bitsInByte[b[startByte] & leftMask[startBits]];
00137 for (i = startByte+1; i<endByte; ++i)
00138     count += bitsInByte[b[i]];
00139 count += bitsInByte[b[endByte] & rightMask[endBits]];
00140 return count;
00141 }

Here is the call graph for this function:

Here is the caller graph for this function:

int bitFindClear ( Bits b,
int  startIx,
int  bitCount 
)

Definition at line 184 of file bits.c.

References bitFind(), and FALSE.

00186 {
00187 return bitFind(b, startIx, FALSE, bitCount);
00188 }

Here is the call graph for this function:

int bitFindSet ( Bits b,
int  startIx,
int  bitCount 
)

Definition at line 178 of file bits.c.

References bitFind(), and TRUE.

Referenced by drawAfterOnOff().

00180 {
00181 return bitFind(b, startIx, TRUE, bitCount);
00182 }

Here is the call graph for this function:

Here is the caller graph for this function:

void bitFree ( Bits **  pB  ) 

Definition at line 75 of file bits.c.

References freez().

Referenced by freeDnaSeq(), genoFindFree(), and searchOneMaskTrim().

00077 {
00078 freez(pB);
00079 }

Here is the call graph for this function:

Here is the caller graph for this function:

void bitNot ( Bits a,
int  bitCount 
)

Definition at line 250 of file bits.c.

00252 {
00253 int byteCount = ((bitCount+7)>>3);
00254 while (--byteCount >= 0)
00255     {
00256     *a = ~*a;
00257     a++;
00258     }
00259 }

void bitOr ( Bits a,
Bits b,
int  bitCount 
)

Definition at line 229 of file bits.c.

00231 {
00232 int byteCount = ((bitCount+7)>>3);
00233 while (--byteCount >= 0)
00234     {
00235     *a = (*a | *b++);
00236     a++;
00237     }
00238 }

void bitPrint ( Bits a,
int  startIx,
int  bitCount,
FILE *  out 
)

Definition at line 261 of file bits.c.

References bitReadOne().

00264 {
00265 int i;
00266 for (i = startIx; i < bitCount; i++)
00267     {
00268     if (bitReadOne(a, i))
00269         fputc('1', out);
00270     else
00271         fputc('0', out);
00272     }
00273 fputc('\n', out);
00274 }

Here is the call graph for this function:

boolean bitReadOne ( Bits b,
int  bitIx 
)

Definition at line 115 of file bits.c.

References oneBit.

Referenced by bitFind(), bitPrint(), chainReadUsedSwapLf(), nibOutput(), and savePslx().

00117 {
00118 return (b[bitIx>>3] & oneBit[bitIx&7]) != 0;
00119 }

Here is the caller graph for this function:

Bits* bitRealloc ( Bits b,
int  bitCount,
int  newBitCount 
)

Definition at line 58 of file bits.c.

References needLargeZeroedMemResize().

00060 {
00061 int byteCount = ((bitCount+7)>>3);
00062 int newByteCount = ((newBitCount+7)>>3);
00063 return needLargeZeroedMemResize(b, byteCount, newByteCount);
00064 }

Here is the call graph for this function:

void bitSetOne ( Bits b,
int  bitIx 
)

Definition at line 81 of file bits.c.

References oneBit.

Referenced by maskFromUpperCaseSeq(), and nibInput().

00083 {
00084 b[bitIx>>3] |= oneBit[bitIx&7];
00085 }

Here is the caller graph for this function:

void bitSetRange ( Bits b,
int  startIx,
int  bitCount 
)

Definition at line 93 of file bits.c.

References leftMask, and rightMask.

00095 {
00096 int endIx = (startIx + bitCount - 1);
00097 int startByte = (startIx>>3);
00098 int endByte = (endIx>>3);
00099 int startBits = (startIx&7);
00100 int endBits = (endIx&7);
00101 int i;
00102 
00103 if (startByte == endByte)
00104     {
00105     b[startByte] |= (leftMask[startBits] & rightMask[endBits]);
00106     return;
00107     }
00108 b[startByte] |= leftMask[startBits];
00109 for (i = startByte+1; i<endByte; ++i)
00110     b[i] = 0xff;
00111 b[endByte] |= rightMask[endBits];
00112 }

void bitsInByteInit (  ) 

Definition at line 19 of file bits.c.

References bitsInByte, inittedBitsInByte, and TRUE.

Referenced by bitCountRange().

00021 {
00022 int i;
00023 
00024 if (!inittedBitsInByte)
00025     {
00026     inittedBitsInByte = TRUE;
00027     for (i=0; i<256; ++i)
00028         {
00029         int count = 0;
00030         if (i&1)
00031             count = 1;
00032         if (i&2)
00033             ++count;
00034         if (i&4)
00035             ++count;
00036         if (i&8)
00037             ++count;
00038         if (i&0x10)
00039             ++count;
00040         if (i&0x20)
00041             ++count;
00042         if (i&0x40)
00043             ++count;
00044         if (i&0x80)
00045             ++count;
00046         bitsInByte[i] = count;
00047         }
00048     }
00049 }

Here is the caller graph for this function:

void bitXor ( Bits a,
Bits b,
int  bitCount 
)

Definition at line 240 of file bits.c.

00241 {
00242 int byteCount = ((bitCount+7)>>3);
00243 while (--byteCount >= 0)
00244     {
00245     *a = (*a ^ *b++);
00246     a++;
00247     }
00248 }


Variable Documentation

int bitsInByte[256]

Definition at line 15 of file bits.c.

Referenced by bitCountRange(), and bitsInByteInit().


Generated on Tue Dec 25 18:42:33 2007 for blat by  doxygen 1.5.2