• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ decrement函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中decrement函数的典型用法代码示例。如果您正苦于以下问题:C++ decrement函数的具体用法?C++ decrement怎么用?C++ decrement使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了decrement函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: power

int power(struct NUMBER *a,struct NUMBER *b,struct NUMBER *c)
{
	int res = 0;
	struct NUMBER tmp_b,tmp_c,tmp;

	if(isZero(b) == 0)//bが最初から0ならば
	{
		setInt(c,1);//cを1に
		return(0);//n^0は(0を除いて)必ず1になるため
	}

	if(getSign(b) == -1)//bが負なら
		return(-1);

	copyNumber(b,&tmp_b);//bが破壊されないようにtmp_bに
	copyNumber(a,c);//aをcにコピー、cの初期値をaとする

	copyNumber(&tmp_b,&tmp);//tmp_bにtmpを代入、グダグダなのはわかってる。
	decrement(&tmp,&tmp_b);//もうすでにcにはa^1があるので、1をまず引く

	while(1)
	{
		if(isZero(&tmp_b) == 0)
			break;//bが0になったら終了
		copyNumber(c,&tmp_c);//tmp_cに現在のcの値を代入する
		res = multiple(a,&tmp_c,c);
		if(res == -1)
			break;
		
		copyNumber(&tmp_b,&tmp);//tmp_bにtmpを代入、グダグダなのはわかってる。
		decrement(&tmp,&tmp_b);//tmp_b--;を実行してます
	}
	return(res);
}
开发者ID:sa2taka,项目名称:alogorithm,代码行数:34,代码来源:machin.c


示例2: FIRFilter

double FIRFilter(TRMFIRFilter *filter, double input, int needOutput)
{
    if (needOutput) {
	int i;
	double output = 0.0;

	/*  PUT INPUT SAMPLE INTO DATA BUFFER  */
	filter->FIRData[filter->FIRPtr] = input;

	/*  SUM THE OUTPUT FROM ALL FILTER TAPS  */
	for (i = 0; i < filter->numberTaps; i++) {
	    output += filter->FIRData[filter->FIRPtr] * filter->FIRCoef[i];
	    filter->FIRPtr = increment(filter->FIRPtr, filter->numberTaps);
	}

	/*  DECREMENT THE DATA POINTER READY FOR NEXT CALL  */
	filter->FIRPtr = decrement(filter->FIRPtr, filter->numberTaps);

	/*  RETURN THE OUTPUT VALUE  */
	return output;
    } else {
	/*  PUT INPUT SAMPLE INTO DATA BUFFER  */
	filter->FIRData[filter->FIRPtr] = input;

	/*  ADJUST THE DATA POINTER, READY FOR NEXT CALL  */
	filter->FIRPtr = decrement(filter->FIRPtr, filter->numberTaps);

	return 0.0;
    }
}
开发者ID:knoguchi,项目名称:py-trm,代码行数:30,代码来源:fir.c


示例3: increment

double
FIRFilter::filter(double input, int needOutput)
{
	if (needOutput) {
		int i;
		double output = 0.0;

		/*  PUT INPUT SAMPLE INTO DATA BUFFER  */
		data_[ptr_] = input;

		/*  SUM THE OUTPUT FROM ALL FILTER TAPS  */
		for (i = 0; i < numberTaps_; i++) {
			output += data_[ptr_] * coef_[i];
			ptr_ = increment(ptr_, numberTaps_);
		}

		/*  DECREMENT THE DATA POINTER READY FOR NEXT CALL  */
		ptr_ = decrement(ptr_, numberTaps_);

		/*  RETURN THE OUTPUT VALUE  */
		return output;
	} else {
		/*  PUT INPUT SAMPLE INTO DATA BUFFER  */
		data_[ptr_] = input;

		/*  ADJUST THE DATA POINTER, READY FOR NEXT CALL  */
		ptr_ = decrement(ptr_, numberTaps_);

		return 0.0;
	}
}
开发者ID:jaoregan,项目名称:gnuspeechsa,代码行数:31,代码来源:FIRFilter.cpp


示例4: push_front

    /**
     * @brief push_front
     */
    void push_front(const T& val)
    {
        assert(!full());

        if(head == c.end())
            head = decrement(head);

        *head = val;
        head = decrement(head);
    }
开发者ID:HongfeiXu,项目名称:CLRS-1,代码行数:13,代码来源:deque.hpp


示例5: comment_section

void CompilerStubs::generate_compiler_new_object() {
  comment_section("Compiler new object (any size)");
  comment("Register edx holds the instance size, register ebx holds the prototypical near of the instance class");
  Label slow_case;
  entry("compiler_new_object");

  comment("Get _inline_allocation_top");
  movl(eax, Address(Constant("_inline_allocation_top")));

  comment("Compute new top");
  leal(ecx, Address(eax, edx, times_1));

  if (GenerateDebugAssembly) {
    comment("Check ExcessiveGC");
    testl(Address(Constant("ExcessiveGC")), Constant(0));
    jcc(not_zero, Constant(slow_case));
  }

  comment("Compare against _inline_allocation_end");
  cmpl(ecx, Address(Constant("_inline_allocation_end")));
  jcc(above, Constant(slow_case));

  comment("Allocation succeeded, set _inline_allocation_top");
  movl(Address(Constant("_inline_allocation_top")), ecx);

  comment("Set prototypical near in object; no need for write barrier");
  movl(Address(eax), ebx);

  comment("Compute remaining size");
  decrement(edx, oopSize);

  comment("One-word object?");
  Label init_done;
  jcc(zero, Constant(init_done));

  comment("Zero object fields");
  xorl(ecx, ecx);
  Label init_loop;
  bind(init_loop);
  movl(Address(eax, edx, times_1), ecx);
  decrement(edx, oopSize);
  jcc(not_zero, Constant(init_loop));
  bind(init_done);

  comment("The newly allocated object is in register eax");
  ret();

  comment("Slow case - call the VM runtime system");
  bind(slow_case);
  leal(eax, Address(Constant("newobject")));
  goto_shared_call_vm(T_OBJECT);

  entry_end(); // compiler_new_object
}
开发者ID:jiangxilong,项目名称:yari,代码行数:54,代码来源:CompilerStubs_i386.cpp


示例6: setHead

FFEvent* TimeTable::getUpcomingEvent(){
	FFEvent* upEvent = head;
	if ( size() > 1 ) {
		setHead(head->getNext());
		decrement();
	} else if ( size() == 1 ) {
		// this is the only event left
		decrement();
	} else {
		// no events left to be treated (size=0)
		cout << "ForeFire simulation ended with no more event to be treated" << endl;
		upEvent = 0;
	}
	return upEvent;
}
开发者ID:forefireAPI,项目名称:firefront,代码行数:15,代码来源:TimeTable.cpp


示例7: main

int main()
{
    int i = 0;
    std::string str = "asdf";

    decrement(i);
    decrement(str);

    std::cout << i << " "<<str<<std::endl;

    F foo;
    foo.decrement(i);
    foo.decrement(str);
    std::cout << i << " "<<str<<std::endl;
}
开发者ID:erichkeane,项目名称:playground,代码行数:15,代码来源:static_if_test.cpp


示例8: pop_back

 void pop_back()
 {
     MGBASE_ASSERT(!empty());
     --size_;
     
     decrement(&last_);
 }
开发者ID:endowataru,项目名称:mgbase,代码行数:7,代码来源:circular_buffer.hpp


示例9: advance

		void advance(difference_type dist)
		{
			for (; dist != 0; --dist)
				{
					decrement();
				}
		}
开发者ID:GuapoTaco,项目名称:Modular-ECS,代码行数:7,代码来源:segmented_map.hpp


示例10: increment

void Demo::DepthZoom::on_incNear_pressed() {
    float z = increment(mN);
    float f = decrement(mF - mN);
    mN += z < f ? z : f;
    mUI->nearValue->setText(QString("%1").arg((double) mN, 0, 'f', 2, QChar('0')));
    emit valuesChanged(mN, mF);
}
开发者ID:jusirkka,项目名称:OpenGLDemo,代码行数:7,代码来源:depthzoom.cpp


示例11: decrement

void Task< Kokkos::Serial , void >::schedule_dependence_reserve(int n)
{
  if ( STATE_CONSTRUCTING != m_state && STATE_EXECUTING != m_state ) {
    throw std::runtime_error(std::string("Kokkos::Impl::Task spawn or respawn state error"));
  }

  m_state = STATE_WAITING ;

  for ( int i = 0 ; i < m_dep_count ; ++i ) {
    decrement( m_dep[i] );
    m_dep[i] = 0 ;
  }

  if ( DEP_COUNT_BASE < n && m_dep_alloc < n ) {
    if ( m_dep_alloc ) {
      // Thread safety and scalability of 'free' ?
      free( m_dep );
    }
    m_dep_alloc = n ;
    // Thread safety and scalability of 'malloc' ?
    m_dep = reinterpret_cast<Task**>( malloc( n * sizeof(Task*) ) );

    for ( int i = 0 ; i < m_dep_alloc ; ++i ) { m_dep[i] = 0 ; }
  }

  m_dep_count = n ;
}
开发者ID:00liujj,项目名称:trilinos,代码行数:27,代码来源:Kokkos_Serial_Task.cpp


示例12: decrement

long IOPMchangeNoteList::previousChangeNote ( unsigned long ordinal )
{
    if ( ordinal == firstInList )  {
        return -1;
    }
    return decrement(ordinal);
}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:7,代码来源:IOPMchangeNoteList.cpp


示例13: pushToBuffer

// Arbitrary-size push function
unsigned int pushToBuffer(buffer_t *b, void *d, unsigned int l) {
    unsigned int elementIndex, byteIndex;
    
    // Loop through all elements
    for (elementIndex = 0; elementIndex < l; elementIndex++) {

        // Loop through all bytes of each element
        for (byteIndex = 0; byteIndex < b->width; byteIndex++) {
        
            // Only push to buffer if it is not full or overwriting is allowed
            if ( (!isBufferFull(b)) || (b->behavior.bits.overwrite) ) {
                pushByte(b, *( (unsigned char*)(d + elementIndex * (b->width) + byteIndex) ));
            }
            
            // If buffer is full, return a count of those elments not pushed
            else {
                
                // Pop all bytes of incomplete elements
                // -This should never run, but added just in case
                unsigned int failedbytes;
                for (failedbytes = byteIndex; failedbytes > 0; failedbytes--) {
                   
                    // If it is a queue pop comes from tail, so decrement head
                    decrement(b, &(b->head));
                }
                
                // Return a count of failed push operations
                // -Include partial pushes in count
                return l - elementIndex;
            }
        }
    }
    return 0;
}
开发者ID:danielwilkinsonthompson,项目名称:source-code-library,代码行数:35,代码来源:buffer.c


示例14: FIT_TEST_CASE

FIT_TEST_CASE()
{
    constexpr auto f = fit::compose(increment(), decrement());
    static_assert(std::is_empty<decltype(f)>::value, "Compose function not empty");
    int r = f(3);
    FIT_TEST_CHECK(r == 3);
    FIT_STATIC_TEST_CHECK(f(3) == 3);
}
开发者ID:jbrownson,项目名称:Fit,代码行数:8,代码来源:compose.cpp


示例15: if

void CGUINumberControl::processLogic()
{
    GsPointingState &pointingState = gPointDevice.mPointingState;

    const bool hasPoint = mRect.HasPoint(pointingState.mPos);
    const bool bDown = (pointingState.mActionButton>0);

    const float xMid = mRect.x+(mRect.w/2.0f);

    mReleased = false;

    mDecSel = false;
    mIncSel = false;

    Vector2D<float> mousePos = pointingState.mPos;

    if( mousePos.x < xMid )
        mDecSel = true;
    else if( mousePos.x > xMid )
        mIncSel = true;


    if(!bDown && mPressed)
    {
        mPressed = false;

        if(hasPoint)
        {
            mReleased = true;
        }
    }

    if(!bDown || mPressed)
    {
        mHovered = hasPoint;
    }

    if(mHovered && bDown)
    {
        mPressed = true;

        if( mDecSel )
        {
            // Cycle through the values -> go one value down
            if( mValue > mStartValue )
                decrement();
        }
        else if( mIncSel )
        {
            // Cycle through the values -> go one value up
            if( mValue < mEndValue )
                increment();
        }

        mMustRedraw = true;
    }

}
开发者ID:z33ky,项目名称:Commander-Genius,代码行数:58,代码来源:GsNumberControl.cpp


示例16: switch

////////////////////////////////////////////////////////////////////////////////
// Do 'bars[epoch] = Bar' for every bar that may appear on a chart.
void Chart::generateBars ()
{
  Bar bar;

  // Determine the last bar date.
  Date cursor;
  switch (period)
  {
  case 'D': cursor = Date ().startOfDay ();   break;
  case 'W': cursor = Date ().startOfWeek ();  break;
  case 'M': cursor = Date ().startOfMonth (); break;
  }

  // Iterate and determine all the other bar dates.
  char str[12];
  for (int i = 0; i < estimated_bars; ++i)
  {
    // Create the major and minor labels.
    switch (period)
    {
    case 'D': // month/day
      {
        std::string month = Date::monthName (cursor.month ());
        bar.major_label = month.substr (0, 3);

        sprintf (str, "%02d", cursor.day ());
        bar.minor_label = str;
      }
      break;

    case 'W': // year/week
      sprintf (str, "%d", cursor.year ());
      bar.major_label = str;

      sprintf (str, "%02d", cursor.weekOfYear (0));
      bar.minor_label = str;
      break;

    case 'M': // year/month
      sprintf (str, "%d", cursor.year ());
      bar.major_label = str;

      sprintf (str, "%02d", cursor.month ());
      bar.minor_label = str;
      break;
    }

    bar.offset = i;
    bars[cursor.toEpoch ()] = bar;

    // Record the earliest date, for use as a cutoff when scanning data.
    earliest = cursor;

    // Move to the previous period.
    cursor = decrement (cursor);
  }
}
开发者ID:georgebrock,项目名称:task,代码行数:59,代码来源:CmdBurndown.cpp


示例17:

void
shared_count::release_shared()
{
    if (decrement(shared_owners_) == -1)
    {
        on_zero_shared();
        delete this;
    }
}
开发者ID:eightcien,项目名称:lldb,代码行数:9,代码来源:SharingPtr.cpp


示例18: push_front

 void push_front(const T& val)
 {
     MGBASE_ASSERT(!full());
     ++size_;
     
     decrement(&first_);
     
     // Copy the value after decrement.
     data()[first_] = val;
 }
开发者ID:endowataru,项目名称:mgbase,代码行数:10,代码来源:circular_buffer.hpp


示例19: decrement

	Ptr<T>& operator=(const Ptr<Y>& other)
	{
	    if(this != &other) {
		decrement();
		if(fRef = other.fRef) {
		    fRef->AddReference();
		}
	    }
	    return *this;
	}
开发者ID:hengne,项目名称:d0wmass,代码行数:10,代码来源:Ptr.hpp


示例20: decrement

void WeaponUpdater::update(float dt)
{
    const u32 dtMs = static_cast<u32>(dt * 1000.0f);

    for (auto& it : _modules)
    {
        WeaponModule& moduleInstance = it.second;
        moduleInstance.cooldownMs = decrement(moduleInstance.cooldownMs, dtMs);
    }
}
开发者ID:Ryp,项目名称:Reaper,代码行数:10,代码来源:WeaponModule.cpp



注:本文中的decrement函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ decrgpulse函数代码示例发布时间:2022-05-30
下一篇:
C++ decref函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap