本文整理汇总了C++中SetBit函数的典型用法代码示例。如果您正苦于以下问题:C++ SetBit函数的具体用法?C++ SetBit怎么用?C++ SetBit使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetBit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BitMapSortDemo
void BitMapSortDemo()
{
//为了简单起见,我们不考虑负数
int num[] = {3,5,2,10,6,12,8,14,9};
//BufferLen这个值是根据待排序的数据中最大值确定的
//待排序中的最大值是14,因此只需要2个Bytes(16个Bit)
//就可以了。
const int BufferLen = 2;
char *pBuffer = new char[BufferLen];
//要将所有的Bit位置为0,否则结果不可预知。
memset(pBuffer,0,BufferLen);
for(int i=0;i<9;i++)
{
//首先将相应Bit位上置为1
SetBit(pBuffer,num[i]);
}
//输出排序结果
for(int i=0;i<BufferLen;i++)//每次处理一个字节(Byte)
{
for(int j=0;j<BYTESIZE;j++)//处理该字节中的每个Bit位
{
//判断该位上是否是1,进行输出,这里的判断比较笨。
//首先得到该第j位的掩码(0x01<<j),将内存区中的
//位和此掩码作与操作。最后判断掩码是否和处理后的
//结果相同
if((*pBuffer&(0x01<<j)) == (0x01<<j))
{
printf("%d ",i*BYTESIZE + j);
}
}
pBuffer++;
}
}
示例2: next
Bool_t KVHarpeeSi::PositionIsOK(){
// Returns true if all the conditions to access to the particle position
// are verified. In this case the position is given by the method
// GetPosition(...).
// The conditions are:
// -the multiplicity of fired ( "Pany" option of Fired() ) Harpee Si
// detectors must be equal to one;
// -this detectector must be the fired detector.
if( !TestBit( kPosIsOK ) ){
Int_t mult = 0;
TIter next( fHarpeeSiList );
KVHarpeeSi *si = NULL;
while( (si = (KVHarpeeSi *)next()) ){
if( si->Fired( "Pany" ) ){
mult++;
fSiForPosition = si;
}
}
if( mult != 1 ) fSiForPosition = NULL;
SetBit( kPosIsOK );
}
return fSiForPosition == this;
}
示例3: pwm_config
void pwm_config(void){
// Configuramos los puertos como salidas en cero
// enables de los motores
SetBit (DDR_MOTOR_DERECHO_ENABLE, MOTOR_DERECHO_ENABLE_NUMBER);
SetBit (DDR_MOTOR_IZQUIERDO_ENABLE, MOTOR_IZQUIERDO_ENABLE_NUMBER);
SetBit (DDR_MOTOR_DERECHO_1, MOTOR_DERECHO_1_NUMBER);
SetBit (DDR_MOTOR_DERECHO_2, MOTOR_DERECHO_2_NUMBER);
SetBit (DDR_MOTOR_IZQUIERDO_1, MOTOR_IZQUIERDO_1_NUMBER);
SetBit (DDR_MOTOR_IZQUIERDO_2, MOTOR_IZQUIERDO_2_NUMBER);
// PORT_PWM1 &=~ _BV(PIN_NUM_PWM1);
// PORT_PWM2 &=~ _BV(PIN_NUM_PWM2);
// pines de sentido de giro
ClearBit (PORT_MOTOR_DERECHO_ENABLE, MOTOR_DERECHO_ENABLE_NUMBER);
ClearBit (PORT_MOTOR_IZQUIERDO_ENABLE, MOTOR_IZQUIERDO_ENABLE_NUMBER);
ClearBit (PORT_MOTOR_DERECHO_1, MOTOR_DERECHO_1_NUMBER);
ClearBit (PORT_MOTOR_DERECHO_2, MOTOR_DERECHO_2_NUMBER);
ClearBit (PORT_MOTOR_IZQUIERDO_1, MOTOR_IZQUIERDO_1_NUMBER);
ClearBit (PORT_MOTOR_IZQUIERDO_2, MOTOR_IZQUIERDO_2_NUMBER);
// Configuramos el PWM
TCCR1A = PWM_TCCR1A;
TCCR1B = PWM_TCCR1B;
TCCR0A = PWM_TCCR0A;
TCCR0B = PWM_TCCR0B;
OCR1A = 128;
//OCR1B = 0;
OCR0A = 128;
//OCR0B = 0;
// Activamos la IRQ de OVF
//TIMSK1 |= _BV(TOIE1) ;
// Apaga los motores
//mot1_sent(LIBRE);
//mot2_sent(LIBRE);
}
示例4: main
int main (int argc, char** argv) {
int tx=0, rx=0;
int tx_shadow=1, rx_shadow=1;
hw_init();
led_init();
LED_ON(1);
/* TXD0 and TXD1 output */
SetBit(IO0DIR, TXD0_PIN);
SetBit(IO0DIR, TXD1_PIN);
/* RXD0 and RXD1 input */
ClearBit(IO0DIR,RXD0_PIN);
ClearBit(IO0DIR,RXD1_PIN);
/* use shadow bits to reduce jitter */
while(1) {
tx = bit_is_set(IO0PIN, RXD0_PIN);
if (tx != tx_shadow) {
if (tx) {
SetBit(IO0SET, TXD1_PIN);
} else {
SetBit(IO0CLR, TXD1_PIN);
}
tx_shadow = tx;
LED_TOGGLE(2);
}
rx = bit_is_set(IO0PIN, RXD1_PIN);
if (rx != rx_shadow) {
if (rx) {
SetBit(IO0SET, TXD0_PIN);
} else {
SetBit(IO0CLR, TXD0_PIN);
}
rx_shadow = rx;
LED_TOGGLE(3);
}
}
return 0;
}
示例5: OnClick
virtual void OnClick(Point pt, int widget, int click_count)
{
const Vehicle *v = this->vehicle;
switch (widget) {
case WID_VT_ORDER_VIEW: // Order view button
ShowOrdersWindow(v);
break;
case WID_VT_TIMETABLE_PANEL: { // Main panel.
int selected = GetOrderFromTimetableWndPt(pt.y, v);
this->DeleteChildWindows();
this->sel_index = (selected == INVALID_ORDER || selected == this->sel_index) ? -1 : selected;
break;
}
case WID_VT_START_DATE: // Change the date that the timetable starts.
ShowSetDateWindow(this, v->index, _date, _cur_year, _cur_year + 15, ChangeTimetableStartCallback);
break;
case WID_VT_CHANGE_TIME: { // "Wait For" button.
int selected = this->sel_index;
VehicleOrderID real = (selected + 1) / 2;
if (real >= v->GetNumOrders()) real = 0;
const Order *order = v->GetOrder(real);
StringID current = STR_EMPTY;
if (order != NULL) {
uint time = (selected % 2 == 1) ? order->travel_time : order->wait_time;
if (!_settings_client.gui.timetable_in_ticks) time /= DAY_TICKS;
if (time != 0) {
SetDParam(0, time);
current = STR_JUST_INT;
}
}
this->query_is_speed_query = false;
ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, this, CS_NUMERAL, QSF_NONE);
break;
}
case WID_VT_CHANGE_SPEED: { // Change max speed button.
int selected = this->sel_index;
VehicleOrderID real = (selected + 1) / 2;
if (real >= v->GetNumOrders()) real = 0;
StringID current = STR_EMPTY;
const Order *order = v->GetOrder(real);
if (order != NULL) {
if (order->max_speed != UINT16_MAX) {
SetDParam(0, ConvertKmhishSpeedToDisplaySpeed(order->max_speed));
current = STR_JUST_INT;
}
}
this->query_is_speed_query = true;
ShowQueryString(current, STR_TIMETABLE_CHANGE_SPEED, 31, this, CS_NUMERAL, QSF_NONE);
break;
}
case WID_VT_CLEAR_TIME: { // Clear waiting time.
uint32 p1 = PackTimetableArgs(v, this->sel_index, false);
DoCommandP(0, p1, 0, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
break;
}
case WID_VT_CLEAR_SPEED: { // Clear max speed button.
uint32 p1 = PackTimetableArgs(v, this->sel_index, true);
DoCommandP(0, p1, UINT16_MAX, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
break;
}
case WID_VT_RESET_LATENESS: // Reset the vehicle's late counter.
DoCommandP(0, v->index, 0, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
break;
case WID_VT_AUTOFILL: { // Autofill the timetable.
uint32 p2 = 0;
if (!HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(p2, 0);
if (_ctrl_pressed) SetBit(p2, 1);
DoCommandP(0, v->index, p2, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
break;
}
case WID_VT_EXPECTED:
this->show_expected = !this->show_expected;
break;
case WID_VT_SHARED_ORDER_LIST:
ShowVehicleListWindow(v);
break;
}
this->SetDirty();
}
示例6: ReadBinFiles
int
ReadBinFiles(
char FileStem[1000],
char *ext,
int StartNr,
int EndNr,
int *ObsSpotsMat,
int nLayers,
long long int ObsSpotsSize)
{
int i,j,k,nElements=0,nElements_previous,nCheck,ythis,zthis,NrOfFiles,NrOfPixels;
long long int BinNr;
long long int TempCntr;
float32_t dummy;
uint32_t dummy2;
FILE *fp;
char FileName[1024];
struct Theader Header1;
uint16_t *ys=NULL, *zs=NULL, *peakID=NULL;
float32_t *intensity=NULL;
int counter=0;
NrOfFiles = EndNr - StartNr + 1;
NrOfPixels = 2048*2048;
long long int kT;
/*for (kT=0;kT<ObsSpotsSize;kT++){
ObsSpotsMat[k] = 0;
}*/
for (k=0;k<nLayers;k++){
for (i=StartNr;i<=EndNr;i++){
sprintf(FileName,"%s_%06d.%s%d",FileStem,i,ext,k);
//printf("Reading file : %s\n",FileName);
fp = fopen(FileName,"r");
fread(&dummy,sizeof(float32_t),1,fp);
ReadHeader(fp,&Header1);
fread(&dummy2,sizeof(uint32_t),1,fp);
fread(&dummy2,sizeof(uint32_t),1,fp);
fread(&dummy2,sizeof(uint32_t),1,fp);
fread(&dummy2,sizeof(uint32_t),1,fp);
fread(&dummy2,sizeof(uint32_t),1,fp);
ReadHeader(fp,&Header1);
nElements_previous = nElements;
nElements = (Header1.DataSize - Header1.NameSize)/2;
realloc_buffers(nElements,nElements_previous,&ys,&zs,&peakID,&intensity);
fread(ys,sizeof(uint16_t)*nElements,1,fp);
ReadHeader(fp,&Header1);
nCheck = (Header1.DataSize - Header1.NameSize)/2;
if (nCheck!=nElements){
printf("Number of elements mismatch.\n");
return 0;
}
fread(zs,sizeof(uint16_t)*nElements,1,fp);
ReadHeader(fp,&Header1);
nCheck = (Header1.DataSize - Header1.NameSize)/4;
if (nCheck!=nElements){
printf("Number of elements mismatch.\n");
return 0;
}
fread(intensity,sizeof(float32_t)*nElements,1,fp);
ReadHeader(fp,&Header1);
nCheck = (Header1.DataSize - Header1.NameSize)/2;
if (nCheck!=nElements){
printf("Number of elements mismatch.\n");
return 0;
}
fread(peakID,sizeof(uint16_t)*nElements,1,fp);
for (j=0;j<nElements;j++){
ythis=(int)ys[j];
zthis=(int)zs[j];
if (Flag == 1) zthis = 2048 - zthis;
BinNr = k;
BinNr *=NrOfFiles;
BinNr *= NrOfPixels;
TempCntr = (counter*(NrOfPixels));
BinNr += TempCntr;
BinNr += (ythis*(2048));
BinNr += zthis;
SetBit(ObsSpotsMat,BinNr);
}
fclose(fp);
counter+=1;
}
counter = 0;
}
return 1;
free(ys);
free(zs);
free(peakID);
free(intensity);
}
示例7: motor_turn_right
void motor_turn_right(){
motor_left_forward();
//servo_disable(PIN_RIGHT_SERVO);
SetBit(PORTC,PIN_RIGHT_FORWARD);
SetBit(PORTC,PIN_RIGHT_BACKWARD);
}
示例8: FillTable
//.........这里部分代码省略.........
zerosum_value=0;
pCol=&(TPtr->ColPtr[NPtr->zerosum_column]);
rc=SQLBindParameter(hstmt,(short)(NPtr->zerosum_column+1),SQL_PARAM_INPUT,SQL_C_SHORT,
pCol->pTypeInfo->SQLDataType,pCol->DataTypeLen,0,
&zerosum_value,0,NULL);
if(!CHECKRC(SQL_SUCCESS,rc,"SQLBindParameter")){
LogAllErrors(NULL,NULL,hstmt);
if(gDebug) assert(FALSE);
return(FAILURE);
}
/* set last process id column */
last_process_id_column=0;
pCol=&(TPtr->ColPtr[NPtr->last_process_id_column]);
rc=SQLBindParameter(hstmt,(short)(NPtr->last_process_id_column+1),SQL_PARAM_INPUT,SQL_C_SHORT,
pCol->pTypeInfo->SQLDataType,pCol->DataTypeLen,0,
&last_process_id_column,0,NULL);
if(!CHECKRC(SQL_SUCCESS,rc,"SQLBindParameter")){
LogAllErrors(NULL,NULL,hstmt);
if(gDebug) assert(FALSE);
return(FAILURE);
}
/* EXECUTE the previously prepared INSERT statement */
rc=SQLExecute(hstmt);
if(!CHECKRC(SQL_SUCCESS,rc,"SQLExecute")){
LogAllErrors(NULL,NULL,hstmt);
assert(FALSE);
if(rc!=SQL_SUCCESS_WITH_INFO) return(FAILURE);
}
/* once sucessfully inserted (or hit allowable error) then mark bit... */
/* ...in bitmap for this table */
SetBit(BIT_ON,NPtr->BitmapPtr,record_num);
}/* end: for */
} /* end: if random inserts */
/* fill the table with sequential inserts starting at record zero */
else {
if(gTrace){
LogMsg(0," %s\n"
" -- filling table %s sequentially starting with 0 for %ld records\n",
TPtr->TableName,command_line,NPtr->InitialRecordCount);
}
for(record_count=0;i<NPtr->InitialRecordCount;record_count++){
/* fill each field with random data appropriate to its type */
/* randomly fill values into all columns */
RSPtr=BindAndFillAllParams(hstmt,TPtr);
if(RSPtr!=NULL){
LogMsg(ERRMSG+LINEAFTER,
"couldn't generate random data values for all columns\n"
"probable cause: row contains an unsupported data type\n"
"I will continue, inserting the row as is\n");
FreeReturnStatus(RSPtr);
}
/* set key-column(s) */
RSPtr=SetKeyColumnValue2(TablePtr,i);
if(RSPtr!=NULL){
LogMsg(ERRMSG+LINEAFTER,
"couldn't set data value for all key columns\n"
"probable cause: row contains an unsupported data type\n"
示例9: CopyL
/* In the _vast_ majority of cases this simply checks that your chosen random
* number is >= KLastSmallPrimeSquared and return EFalse and lets the normal
* prime generation routines handle the situation. In the case where it is
* smaller, it generates a provable prime and returns ETrue. The algorithm for
* finding a provable prime < KLastPrimeSquared is not the most efficient in the
* world, but two points come to mind
* 1) The two if statements hardly _ever_ evaluate to ETrue in real life.
* 2) Even when it is, the distribution of primes < KLastPrimeSquared is pretty
* dense, so you aren't going to have check many.
* This function is essentially here for two reasons:
* 1) Ensures that it is possible to generate primes < KLastPrimeSquared (the
* test code does this)
* 2) Ensures that if you request a prime of a large bit size that there is an
* even probability distribution across all integers < 2^aBits
*/
TBool TInteger::SmallPrimeRandomizeL(void)
{
TBool foundPrime = EFalse;
//If the random number we've chosen is less than KLastSmallPrime,
//testing for primality is easy.
if(*this <= KLastSmallPrime)
{
//If Zero or One, or two, next prime number is two
if(IsZero() || *this == One() || *this == Two())
{
CopyL(TInteger::Two());
foundPrime = ETrue;
}
else
{
//Make sure any number we bother testing is at least odd
SetBit(0);
//Binary search the small primes.
while(!IsSmallPrime(ConvertToUnsignedLong()))
{
//If not prime, add two and try the next odd number.
//will never carry as the minimum size of an RInteger is 2
//words. Much bigger than KLastSmallPrime on 32bit
//architectures.
IncrementNoCarry(Ptr(), Size(), 2);
}
assert(IsSmallPrime(ConvertToUnsignedLong()));
foundPrime = ETrue;
}
}
else if(*this <= KLastSmallPrimeSquared)
{
//Make sure any number we bother testing is at least odd
SetBit(0);
while(HasSmallDivisorL(*this) && *this <= KLastSmallPrimeSquared)
{
//If not prime, add two and try the next odd number.
//will never carry as the minimum size of an RInteger is 2
//words. Much bigger than KLastSmallPrime on 32bit
//architectures.
IncrementNoCarry(Ptr(), Size(), 2);
}
//If we exited while loop because it had no small divisor then it is
//prime. Otherwise, we've exceeded the limit of what we can provably
//generate. Therefore the normal prime gen routines will be run on it
//now.
if(*this < KLastSmallPrimeSquared)
{
foundPrime = ETrue;
}
else
{
assert(foundPrime == EFalse);
}
}
//This doesn't mean there is no such prime, simply means that the number
//wasn't less than KSmallPrimeSquared and needs to be handled by the normal
//prime generation routines.
return foundPrime;
}
示例10: SetFreeWagon
/**
* Set a vehicle as a free wagon.
*/
FORCEINLINE void SetFreeWagon() { SetBit(this->subtype, GVSF_FREE_WAGON); }
示例11: LOG_NRM
void
SetFeatures::SetAutoPSTransAPSTE(bool enable)
{
LOG_NRM("Setting autonomous PS transision enable (APSTE): %d", enable);
SetBit(enable, 11, 0);
}
示例12: SetBit
/*******************************************************************************
* Function Name : Standard_GetStatus.
* Description : Copy the device request data to "StatusInfo buffer".
* Input : - Length - How many bytes are needed.
* Output : None.
* Return : Return 0, if the request is at end of data block,
* or is invalid when "Length" is 0.
*******************************************************************************/
uint8_t *Standard_GetStatus(uint16_t Length)
{
if (Length == 0)
{
pInformation->Ctrl_Info.Usb_wLength = 2;
return 0;
}
/* Reset Status Information */
StatusInfo.w = 0;
if (Type_Recipient == (STANDARD_REQUEST | DEVICE_RECIPIENT))
{
/*Get Device Status */
uint8_t Feature = pInformation->Current_Feature;
/* Remote Wakeup enabled */
if (ValBit(Feature, 5))
{
SetBit(StatusInfo0, 1);
}
else
{
ClrBit(StatusInfo0, 1);
}
/* Bus-powered */
if (ValBit(Feature, 6))
{
SetBit(StatusInfo0, 0);
}
else /* Self-powered */
{
ClrBit(StatusInfo0, 0);
}
}
/*Interface Status*/
else if (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT))
{
return (uint8_t *)&StatusInfo;
}
/*Get EndPoint Status*/
else if (Type_Recipient == (STANDARD_REQUEST | ENDPOINT_RECIPIENT))
{
uint8_t Related_Endpoint;
uint8_t wIndex0 = pInformation->USBwIndex0;
Related_Endpoint = (wIndex0 & 0x0f);
if (ValBit(wIndex0, 7))
{
/* IN endpoint */
if (_GetTxStallStatus(Related_Endpoint))
{
SetBit(StatusInfo0, 0); /* IN Endpoint stalled */
}
}
else
{
/* OUT endpoint */
if (_GetRxStallStatus(Related_Endpoint))
{
SetBit(StatusInfo0, 0); /* OUT Endpoint stalled */
}
}
}
else
{
return NULL;
}
pUser_Standard_Requests->User_GetStatus();
return (uint8_t *)&StatusInfo;
}
示例13: TEST
TEST(Sample, Simple)
{
int expected = 0x180;
int actual = SetBit(SetBit(0, 7), 8);
TEST_ASSERT_EQUAL_HEX16(expected, actual);
}
示例14: PruneStraightHighwayNodes
//.........这里部分代码省略.........
{
if(!lowerbounded && !upperbounded)
{
nodex=LookupNodeX(nodesx,nodes[lower],1);
lats[lower]=latlong_to_radians(nodex->latitude);
lons[lower]=latlong_to_radians(nodex->longitude);
}
lats[upper]=lats[lower];
lons[upper]=lons[lower];
lowerbounded=1;
upperbounded=1;
}
}
else /* if(segment!=2) */
{
if(current==upper)
upperbounded=1;
if(current==lower)
{
lowerbounded=1;
current=upper;
}
}
}
while(!(lowerbounded && upperbounded));
/* Mark the nodes */
for(current=lower;current<=upper;current++)
SetBit(checked,nodes[current]);
/* Check for straight highway */
for(;lower<(upper-1);lower++)
{
for(current=upper;current>(lower+1);current--)
{
SegmentX *segmentx;
distance_t dist=0;
double dist1,dist2,dist3,distp;
index_t c;
dist3=distance(lats[lower],lons[lower],lats[current],lons[current]);
for(c=lower+1;c<current;c++)
{
dist1=distance(lats[lower] ,lons[lower] ,lats[c],lons[c]);
dist2=distance(lats[current],lons[current],lats[c],lons[c]);
/* Use law of cosines (assume flat Earth) */
if(dist3==0)
distp=dist1; /* == dist2 */
else if((dist1+dist2)<dist3)
distp=0;
else
{
double dist3a=(dist1*dist1-dist2*dist2+dist3*dist3)/(2.0*dist3);
double dist3b=dist3-dist3a;
if(dist3a>=0 && dist3b>=0)
distp=sqrt(dist1*dist1-dist3a*dist3a);
示例15: PruneIsolatedRegions
void PruneIsolatedRegions(NodesX *nodesx,SegmentsX *segmentsx,WaysX *waysx,distance_t minimum)
{
WaysX *newwaysx;
WayX tmpwayx;
transport_t transport;
BitMask *connected,*region;
index_t *regionsegments,*othersegments;
index_t nallocregionsegments,nallocothersegments;
if(nodesx->number==0 || segmentsx->number==0)
return;
/* Map into memory / open the files */
#if !SLIM
nodesx->data=MapFile(nodesx->filename_tmp);
segmentsx->data=MapFileWriteable(segmentsx->filename_tmp);
waysx->data=MapFile(waysx->filename_tmp);
#else
nodesx->fd=SlimMapFile(nodesx->filename_tmp);
segmentsx->fd=SlimMapFileWriteable(segmentsx->filename_tmp);
waysx->fd=SlimMapFile(waysx->filename_tmp);
InvalidateNodeXCache(nodesx->cache);
InvalidateSegmentXCache(segmentsx->cache);
InvalidateWayXCache(waysx->cache);
#endif
newwaysx=NewWayList(0,0);
CloseFileBuffered(newwaysx->fd);
newwaysx->fd=SlimMapFileWriteable(newwaysx->filename_tmp);
connected=AllocBitMask(segmentsx->number);
region =AllocBitMask(segmentsx->number);
logassert(connected,"Failed to allocate memory (try using slim mode?)"); /* Check AllocBitMask() worked */
logassert(region,"Failed to allocate memory (try using slim mode?)"); /* Check AllocBitMask() worked */
regionsegments=(index_t*)malloc((nallocregionsegments=1024)*sizeof(index_t));
othersegments =(index_t*)malloc((nallocothersegments =1024)*sizeof(index_t));
logassert(regionsegments,"Failed to allocate memory (try using slim mode?)"); /* Check malloc() worked */
logassert(othersegments,"Failed to allocate memory (try using slim mode?)"); /* Check malloc() worked */
/* Loop through the transport types */
for(transport=Transport_None+1;transport<Transport_Count;transport++)
{
index_t i,j;
index_t nregions=0,npruned=0,nadjusted=0;
const char *transport_str=TransportName(transport);
transports_t transports=TRANSPORTS(transport);
if(!(waysx->allow&transports))
continue;
/* Print the start message */
printf_first("Pruning Isolated Regions (%s): Segments=0 Adjusted=0 Pruned=0",transport_str);
/* Loop through the segments and find the disconnected ones */
ClearAllBits(connected,segmentsx->number);
ClearAllBits(region ,segmentsx->number);
for(i=0;i<segmentsx->number;i++)
{
index_t nregionsegments=0,nothersegments=0;
distance_t total=0;
SegmentX *segmentx;
WayX *wayx;
if(IsBitSet(connected,i))
goto endloop;
segmentx=LookupSegmentX(segmentsx,i,1);
if(IsPrunedSegmentX(segmentx))
goto endloop;
if(segmentx->way<waysx->number)
wayx=LookupWayX(waysx,segmentx->way,1);
else
SlimFetch(newwaysx->fd,(wayx=&tmpwayx),sizeof(WayX),(segmentx->way-waysx->number)*sizeof(WayX));
if(!(wayx->way.allow&transports))
goto endloop;
othersegments[nothersegments++]=i;
SetBit(region,i);
do
{
index_t thissegment,nodes[2];
thissegment=othersegments[--nothersegments];
if(nregionsegments==nallocregionsegments)
regionsegments=(index_t*)realloc(regionsegments,(nallocregionsegments+=1024)*sizeof(index_t));
//.........这里部分代码省略.........