當前位置: 首頁>>代碼示例>>C++>>正文


C++ BITSET函數代碼示例

本文整理匯總了C++中BITSET函數的典型用法代碼示例。如果您正苦於以下問題:C++ BITSET函數的具體用法?C++ BITSET怎麽用?C++ BITSET使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了BITSET函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: defineExchangeReactions

/*
 * read stoichiometric matrix file and searches exchange reactions
 * exchange reactions are defined as those reactions that have only positive
 * or only negative values
 */
void defineExchangeReactions(int *cols, char** exchange_reaction, double
        threshold, char* filename)
{
    double n_thres = -1 * threshold;
    FILE *rx_file = fopen(filename, "r");
    if (!rx_file)
    {
        quitError("Error in opening file\n", ERROR_FILE);
    }
    int rx_count = getRxCount(rx_file);
    fclose(rx_file);
    char* line = NULL;
    size_t len = 0;
    unsigned long bitarray_size = getBitsize(rx_count);
    char* m_exchange_reaction = calloc(1, bitarray_size);
    char* m_pos = calloc(1, bitarray_size);
    char* m_neg = calloc(1, bitarray_size);
    FILE *file = fopen(filename, "r");
    if (!file)
    {
        quitError("Error in opening file\n", ERROR_FILE);
    }
    while ( getline(&line, &len, file) != -1)
    {
        char *ptr;
        ptr = strtok(line, "\n\t ");
        int i = 0;
        while(ptr != NULL) 
        {
            double val = atof(ptr);
            // positive value
            if (val > threshold)
            {
                BITSET(m_pos, i);
            }
            // negative value
            else if (val < n_thres)
            {
                BITSET(m_neg,i);
            }
            i++;
            ptr = strtok(NULL, "\n\t ");
        }
    }
    free(line);
    line = NULL;
    fclose(file);
    int i;
    for (i = 0; i < rx_count; i++) {
        // check if reaction have positive and negative values
        if ( (BITTEST(m_pos,i) && !BITTEST(m_neg,i)) || (!BITTEST(m_pos,i) && BITTEST(m_neg,i)) )
        {
            BITSET(m_exchange_reaction, i);
        }
    }
    free(m_pos);
    free(m_neg);
    *cols = rx_count;
    *exchange_reaction = m_exchange_reaction;
}
開發者ID:mpgerstl,項目名稱:ltcsCalculator,代碼行數:65,代碼來源:calcLtcs.c

示例2: MAIN_Get_Start_Code

/**************************************************************************
DOES:    Determines source of reset.
RETURNS: 0=power-up, 1=external, 2=brown-out, 3=watchdog, 4=J-Tag, 5=jump
**************************************************************************/
static UNSIGNED8 MAIN_Get_Start_Code(void)
{
  UNSIGNED8 return_val;

  if (BITSET(MCUSR,JTRF))
  { 
     return_val = 4;
  }
  else if (BITSET(MCUSR,WDRF))
  { 
     return_val = 3;
  }
  else if (BITSET(MCUSR,BORF))
  { 
    return_val = 2;
  }
  else if (BITSET(MCUSR,EXTRF))
  { 
     return_val = 1;
  }
  else if (BITSET(MCUSR,PORF))
  { 
     return_val = 0;
  }
  else
  { 
    return_val = 5;
  }

  // Reset MCU Status Register
  MCUSR = 0x00;

  return (return_val);
}
開發者ID:OakdaleDaddy,項目名稱:ULC-build,代碼行數:38,代碼來源:main.c

示例3: tcc88xx_osmr0_set_mode

static void
tcc88xx_osmr0_set_mode(enum clock_event_mode mode, struct clock_event_device *c)
{
	unsigned long flags;

#if defined(TICKLESS_DEBUG_TCC)
	printk("%s: mode %s... %d\n", __func__,
	       mode == CLOCK_EVT_MODE_ONESHOT  ? "ONESHOT"   :
	       mode == CLOCK_EVT_MODE_UNUSED   ? "UNUSED"    :
	       mode == CLOCK_EVT_MODE_SHUTDOWN ? "SHUTDOWN"  :
	       mode == CLOCK_EVT_MODE_RESUME   ? "RESUME"    :
	       mode == CLOCK_EVT_MODE_PERIODIC ? "PERIODIC"  : "non",
	       gTimer_cnt++);
#endif

	switch (mode) {
	case CLOCK_EVT_MODE_ONESHOT:
	case CLOCK_EVT_MODE_UNUSED:
	case CLOCK_EVT_MODE_SHUTDOWN:
		raw_local_irq_save(flags);
		BITCLR(pTIMER->TC32IRQ, Hw16);			/* Disable interrupt when the counter value matched with CMP0 */
		BITSET(pPIC->CLR0, TCC_ENABLE_BIT(INT_TC32));	/* PIC Interrupt clear */
		if(pTIMER->TC32IRQ & Hw31)			/* IRQ clear */
			BITSET(pTIMER->TC32IRQ, Hw31);
		raw_local_irq_restore(flags);
		break;

	case CLOCK_EVT_MODE_RESUME:
	case CLOCK_EVT_MODE_PERIODIC:
		break;
	}
}
開發者ID:AmesianX,項目名稱:telechips-linux,代碼行數:32,代碼來源:time.c

示例4: apply_mark_flagstates

void apply_mark_flagstates(struct apply_handle *h) {
    int i;
    struct fsm_state *fsm;

    /* Create bitarray with those states that have a flag symbol on an arc */
    /* This is needed to decide whether we can perform a binary search.    */

    if (!h->has_flags || h->flag_lookup == NULL) {
	return;
    }
    if (h->flagstates) {
	xxfree(h->flagstates);
    }
    h->flagstates = xxcalloc(BITNSLOTS(h->last_net->statecount), sizeof(uint8_t));
    fsm = h->last_net->states;
    for (i=0; (fsm+i)->state_no != -1; i++) {
	if ((fsm+i)->target == -1) { 
	    continue;
	}
	if ((h->flag_lookup+(fsm+i)->in)->type) {
	    BITSET(h->flagstates,(fsm+i)->state_no);
	}
	if ((h->flag_lookup+(fsm+i)->out)->type) {
	    BITSET(h->flagstates,(fsm+i)->state_no);
	}
    }
}
開發者ID:JSefara,項目名稱:foma,代碼行數:27,代碼來源:apply.c

示例5: ModifyLinkStyle

BOOL
CHyperLink:: ModifyLinkStyle( DWORD dwRemove, DWORD dwAdd,
                             BOOL bApply /* =TRUE */ )
{
   // Check if we are adding and removing the same style.
   if ( (dwRemove & dwAdd) != 0 )
      return( FALSE );

   // Remove old styles and set the new ones
   CLEARBITS( m_dwStyle, dwRemove );
   SETBITS( m_dwStyle, dwAdd );

   if ( bApply && mIs_hWnd( GetSafeHwnd( ) ) )
   {
      // If possible, APPLY the new styles on the fly.
      if ( BITSET( dwAdd, StyleUnderline ) ||
           BITSET( dwRemove, StyleUnderline ) )
      {
         SwitchUnderline( );
      }

      if ( BITSET( dwAdd, StyleAutoSize ) )
         AdjustWindow( );

      if ( BITSET( dwRemove, StyleUseHover ) )
         Invalidate( );
   }

   return( TRUE );
}
開發者ID:DeegC,項目名稱:10d,代碼行數:30,代碼來源:ZdCtlHot.cpp

示例6: BITSET

void BloomFilter::add(string item){
  int * keys = this->keys(item);
	BITSET(bitarray, ABS(keys[0]));
	BITSET(bitarray, ABS(keys[1]));
	BITSET(bitarray, ABS(keys[2]));
  delete [] keys;
};
開發者ID:acoffman,項目名稱:narwhal,代碼行數:7,代碼來源:bloomfilter.cpp

示例7: tca_i2c_setgpio

/*****************************************************************************
* Function Name : tca_i2c_setgpio(int ch)
* Description: I2C port configuration
* input parameter:
* 		int core; 	// I2C Core
*       int ch;   	// I2C master channel
******************************************************************************/
void tca_i2c_setgpio(int core, int ch)
{
	PGPIO gpio = (PGPIO)tcc_p2v(HwGPIO_BASE);

	switch (core) {
		case 0:
		{
			if (ch == 0) {
				BITCSET(gpio->GPAFN0, (Hw8-Hw0), Hw4|Hw0);			/* GPIO_A[1:0] */
				BITSET(gpio->GPAEN, Hw1|Hw0);
				BITCLR(gpio->GPADAT, Hw1|Hw0);
			} else if (ch == 1) {
				BITCSET(gpio->GPAFN0, (Hw32-Hw28), Hw28);			/* GPIO_A[7] */
				BITCSET(gpio->GPAFN1, (Hw4-Hw0), Hw0);			    /* GPIO_A[8] */
				BITSET(gpio->GPAEN, Hw8|Hw7);
				BITCLR(gpio->GPADAT, Hw8|Hw7);
			}
			break;
		}
		case 1:
		{
			if (ch == 0) {
                /* Not used */
			} else if (ch == 1) {
                /* Not used */
			}
			break;
		}
	}
}
開發者ID:AmesianX,項目名稱:telechips-linux,代碼行數:37,代碼來源:tca_i2c.c

示例8: SetFocus

void CHyperLink::OnLButtonDown(UINT /*nFlags*/, CPoint /*point*/) 
{
	if (BITSET(m_dwStyle,StyleGetFocusOnClick))
		SetFocus();                // Set the focus and make the link active
	if (BITSET(m_dwStyle,StyleDownClick))
		FollowLink();
	m_bLinkActive = TRUE;
}
開發者ID:6520874,項目名稱:pipiname,代碼行數:8,代碼來源:hyperlink.cpp

示例9: ASSERT

// Move and resize the window so that its client area has the same size
// as the hyperlink text. This prevents the hyperlink cursor being active
// when it is not over the text.
void
CHyperLink::AdjustWindow( )
{
   ASSERT( mIs_hWnd( GetSafeHwnd( ) ) );

   if ( !BITSET( m_dwStyle, StyleAutoSize ) )
        return;

    // Get the current window rect
    CRect rcWnd;
    GetWindowRect( rcWnd );

   // For a child CWnd object, window rect is relative to the
   // upper-left corner of the parent window’s client area.
    CWnd *pParent = GetParent( );
    if ( pParent )
        pParent->ScreenToClient( rcWnd );

   // Get the current client rect
   CRect rcClient;
   GetClientRect( rcClient );

   // Calc border size based on window and client rects.
   int borderWidth = rcWnd.Width( ) - rcClient.Width( );
   int borderHeight = rcWnd.Height( ) - rcClient.Height( );

   // Get the extent of window text
   CString csWndText;
   GetWindowText( csWndText );

   CDC *pDC = GetDC( );
   CFont *pOldFont = pDC->SelectObject( &m_Font );
   CSize Extent = pDC->GetTextExtent( csWndText );
   pDC->SelectObject( pOldFont );
   ReleaseDC( pDC );

   // Get the text justification style.
   DWORD dwStyle = GetStyle( );

   // Recalc window size and position based on text justification.
   if ( BITSET( dwStyle, SS_CENTERIMAGE ) )
      rcWnd.DeflateRect( 0, (rcWnd.Height( ) - Extent.cy) / 2 );
   else
      rcWnd.bottom = rcWnd.top + Extent.cy;

   if ( BITSET( dwStyle, SS_CENTER ) )
      rcWnd.DeflateRect( (rcWnd.Width( ) - Extent.cx) / 2, 0 );
   else
   if ( BITSET( dwStyle, SS_RIGHT ) )
      rcWnd.left  = rcWnd.right - Extent.cx;
   else // SS_LEFT
      rcWnd.right = rcWnd.left + Extent.cx;

   // Move and resize the window.
   MoveWindow( rcWnd.left, rcWnd.top, rcWnd.Width( ) + borderWidth,
               rcWnd.Height( ) + borderHeight );
}
開發者ID:DeegC,項目名稱:10d,代碼行數:60,代碼來源:ZdCtlHot.cpp

示例10: tcc88xx_timer_interrupt

static irqreturn_t tcc88xx_timer_interrupt(int irq, void *dev_id)
{
#ifndef CONFIG_GENERIC_CLOCKEVENTS
	timer_tick();
#endif

	BITSET(pPIC->CLR0, TCC_ENABLE_BIT(irq));
	if(pTIMER->TC32IRQ & Hw31)
		BITSET(pTIMER->TC32IRQ, Hw31);

	return IRQ_HANDLED;
}
開發者ID:AmesianX,項目名稱:telechips-linux,代碼行數:12,代碼來源:time.c

示例11: eth16i_probe_port

static int eth16i_probe_port(int ioaddr)
{
	int i;
	int retcode;
	unsigned char dummy_packet[64];

	/* Powerup the chip */
	outb(0xc0 | POWERUP, ioaddr + CONFIG_REG_1);

	BITSET(ioaddr + CONFIG_REG_0, DLC_EN);

	eth16i_select_regbank(NODE_ID_RB, ioaddr);

	for(i = 0; i < 6; i++) {
		dummy_packet[i] = inb(ioaddr + NODE_ID_0 + i);
		dummy_packet[i+6] = inb(ioaddr + NODE_ID_0 + i);
	}

	dummy_packet[12] = 0x00;
	dummy_packet[13] = 0x04;
	memset(dummy_packet + 14, 0, sizeof(dummy_packet) - 14);

	eth16i_select_regbank(2, ioaddr);

	for(i = 0; i < 3; i++) {
		BITSET(ioaddr + CONFIG_REG_0, DLC_EN);
		BITCLR(ioaddr + CONFIG_REG_0, DLC_EN);
		eth16i_set_port(ioaddr, i);

		if(eth16i_debug > 1)
			printk(KERN_DEBUG "Set port number %d\n", i);

		retcode = eth16i_send_probe_packet(ioaddr, dummy_packet, 64);
		if(retcode == 0) {
			retcode = eth16i_receive_probe_packet(ioaddr);
			if(retcode != -1) {
				if(eth16i_debug > 1)
					printk(KERN_DEBUG "Eth16i interface port found at %d\n", i);
				return i;
			}
		}
		else {
			if(eth16i_debug > 1)
				printk(KERN_DEBUG "TRANSMIT_DONE timeout when probing interface port\n");
		}
	}

	if( eth16i_debug > 1)
		printk(KERN_DEBUG "Using default port\n");

	return E_PORT_BNC;
}
開發者ID:GunioRobot,項目名稱:MI424WR_GEN2_Rev_E-F,代碼行數:52,代碼來源:eth16i.c

示例12: loadEfm

/*
 * stores an EFM into a bitset if it is not an internal loop
 * every reaction is mapped to two bits
 * first bit is if reaction has a positive flux
 * second bit is set if reaction has a negative flux
 * none is set if reaction has no flux
 */
int loadEfm (char* matrix, char* line, char* reversible_reactions, char*
        rxs_fwd, char* rxs_rev, int rx_count, char* exchange_reaction, int
        checkLoops, double threshold)
{
    double n_thres = -1 * threshold;
    char *ptr;
    ptr = strtok(line, "\n\t ");
    int i = 0;
    int j = 0;
    while(ptr != NULL) 
    {
        double x = atof(ptr);
        if (checkLoops > 0 && BITTEST(exchange_reaction, i))
        {
            // check if EFM is an internal loop
            if (x >= threshold || x <= n_thres)
            {
                checkLoops = 0;
            }
        }
        if (BITTEST(reversible_reactions,i))
        {
            // positive flux
            if (x >= threshold)
            {
                BITSET(matrix, 2*j);
                BITSET(rxs_fwd,j);
            }
            // negative flux
            else if (x <= n_thres)
            {
                BITSET(matrix, (2*j)+1);
                BITSET(rxs_rev, j);
            }
            j++;
        }
        i++;
        ptr = strtok(NULL, "\n\t ");
    }
    if (checkLoops > 0)
    {
        // EFM is a loop - free memory
        free(matrix);
        matrix=NULL;
        return(0);
    }
    else
    {
        return(1);
    }
}
開發者ID:mpgerstl,項目名稱:ltcsCalculator,代碼行數:58,代碼來源:calcLtcs.c

示例13: pragmas_gcc

/*
 * gcc-specific pragmas.
 */
int
pragmas_gcc(char *t)
{
	char u;
	int ign, warn, err, i;
	extern bittype warnary[], werrary[];
	extern char *flagstr[], *pragstore;

	if (strcmp((t = pragtok(NULL)), "diagnostic") == 0) {
		ign = warn = err = 0;
		if (strcmp((t = pragtok(NULL)), "ignored") == 0)
			ign = 1;
		else if (strcmp(t, "warning") == 0)
			warn = 1;
		else if (strcmp(t, "error") == 0)
			err = 1;
		else
			return 1;
		if (eat('\"') || eat('-'))
			return 1;
		for (t = pragstore; *t && *t != '\"'; t++)
			;
		u = *t;
		*t = 0;
		for (i = 0; i < NUMW; i++) {
			if (strcmp(flagstr[i], pragstore+1) != 0)
				continue;
			if (err) {
				BITSET(warnary, i);
				BITSET(werrary, i);
			} else if (warn) {
				BITSET(warnary, i);
				BITCLEAR(werrary, i);
			} else {
				BITCLEAR(warnary, i);
				BITCLEAR(werrary, i);
			}
			return 0;
		}
		*t = u;
	} else if (strcmp(t, "poison") == 0) {
		/* currently ignore */;
	} else if (strcmp(t, "visibility") == 0) {
		/* currently ignore */;
	} else if (strcmp(t, "system_header") == 0) {
		/* currently ignore */;
	} else
		werror("gcc pragma unsupported");
	return 0;
}
開發者ID:didickman,項目名稱:pcc,代碼行數:53,代碼來源:gcc_compat.c

示例14: GetWindowText

void
CHyperLink::PreSubclassWindow( )
{
   // If the URL string is empty try to set it to the window text.
   if ( m_csURL.IsEmpty( ) )
      GetWindowText( m_csURL );

   // Check that the window text isn't empty.  If so, set it as URL string.
   CString csWndText;
   GetWindowText( csWndText );
   if ( csWndText.IsEmpty( ) )
   {
      // Set the URL string as the window text
      ASSERT( m_csURL.IsEmpty( ) == FALSE ); // window text and URL both empty!
      CStatic::SetWindowText( m_csURL );
   }

   // Get the current window font
   CFont *pFont = GetFont( );

   if ( pFont )
   {
      LOGFONT lf;
      pFont->GetLogFont( &lf );
      lf.lfUnderline = BITSET( m_dwStyle, StyleUnderline );
      if ( m_Font.CreateFontIndirect( &lf ) )
         CStatic::SetFont( &m_Font );

      // Adjust window size to fit URL if necessary.
      AdjustWindow( );
   }
   else
   {
      // If GetFont returns 0 then the static control is probably not of a
      // text type: it's better to set auto-resizing off.
      CLEARBITS( m_dwStyle, StyleAutoSize );
   }

   if ( !BITSET( m_dwStyle, StyleNoHandCursor ) )
      SetDefaultCursor( );      // try to load a "hand" cursor

    // Create the tooltip.
    CRect rect;
    GetClientRect( rect );
    m_ToolTip.Create( this );
    m_ToolTip.AddTool( this, m_csURL, rect, TOOLTIP_ID );

    CStatic::PreSubclassWindow( );
}
開發者ID:DeegC,項目名稱:10d,代碼行數:49,代碼來源:ZdCtlHot.cpp

示例15: stepper_set_direction

/** Change stepper ic controller direction. 1 is CW, 0 is CCW seen from top
*/
void stepper_set_direction( int8_t dir )
{
	if(dir >= 1)
		BITSET(PORTL,PL3);	//Rotation direcion CW
	else
		BITCLR(PORTL,PL3);	//Rotation direcion to CCW
}
開發者ID:Etimr,項目名稱:cob_environment_perception,代碼行數:9,代碼來源:stepper.c


注:本文中的BITSET函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。