#include "common.h"#include "bits.h"Include dependency graph for bits.c:

Go to the source code of this file.
Functions | |
| void | bitsInByteInit () |
| Bits * | bitAlloc (int bitCount) |
| Bits * | bitRealloc (Bits *b, int bitCount, int newBitCount) |
| Bits * | bitClone (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 | bitFind (Bits *b, int startIx, boolean val, 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) |
Variables | |
| static char const | rcsid [] = "$Id: bits.c,v 1.19 2006/02/28 05:40:46 markd Exp $" |
| static Bits | oneBit [8] = { 0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1} |
| static Bits | leftMask [8] = {0xFF, 0x7F, 0x3F, 0x1F, 0xF, 0x7, 0x3, 0x1,} |
| static Bits | rightMask [8] = {0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF,} |
| int | bitsInByte [256] |
| static boolean | inittedBitsInByte = FALSE |
| 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 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 | |||
| ) |
| 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 }
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 bitFind | ( | Bits * | b, | |
| int | startIx, | |||
| boolean | val, | |||
| int | bitCount | |||
| ) |
Definition at line 143 of file bits.c.
References bitReadOne().
Referenced by bitFindClear(), and bitFindSet().
00145 { 00146 unsigned char notByteVal = val ? 0 : 0xff; 00147 int iBit = startIx; 00148 int endByte = ((bitCount-1)>>3); 00149 int iByte; 00150 00151 /* scan initial byte */ 00152 while (((iBit & 7) != 0) && (iBit < bitCount)) 00153 { 00154 if (bitReadOne(b, iBit) == val) 00155 return iBit; 00156 iBit++; 00157 } 00158 00159 /* scan byte at a time, if not already in last byte */ 00160 iByte = (iBit >> 3); 00161 if (iByte < endByte) 00162 { 00163 while ((iByte < endByte) && (b[iByte] == notByteVal)) 00164 iByte++; 00165 iBit = iByte << 3; 00166 } 00167 00168 /* scan last byte */ 00169 while (iBit < bitCount) 00170 { 00171 if (bitReadOne(b, iBit) == val) 00172 return iBit; 00173 iBit++; 00174 } 00175 return bitCount; /* not found */ 00176 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int bitFindClear | ( | Bits * | b, | |
| int | startIx, | |||
| int | bitCount | |||
| ) |
| int bitFindSet | ( | Bits * | b, | |
| int | startIx, | |||
| int | bitCount | |||
| ) |
| 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 | |||
| ) |
| 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:

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:

| int bitsInByte[256] |
boolean inittedBitsInByte = FALSE [static] |
Definition at line 13 of file bits.c.
Referenced by bitClearRange(), bitCountRange(), and bitSetRange().
char const rcsid[] = "$Id: bits.c,v 1.19 2006/02/28 05:40:46 markd Exp $" [static] |
Definition at line 14 of file bits.c.
Referenced by bitClearRange(), bitCountRange(), and bitSetRange().
1.5.2