当前位置: 首页>>代码示例>>C++>>正文


C++ deque::size方法代码示例

本文整理汇总了C++中deque::size方法的典型用法代码示例。如果您正苦于以下问题:C++ deque::size方法的具体用法?C++ deque::size怎么用?C++ deque::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在deque的用法示例。


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

示例1: set

 void set(int key, int value) {
     if (dict.count(key) != 0) {// found
         touch(key);
         dict[key] = value;
         ht[key] = keys.end();
         return;
     }
     
     //if not found
     if (keys.size() == cap) {
         //remove oldest one
         dict.erase(keys.front());
         ht.erase(keys.front());
         keys.pop_front();
     }
     keys.push_back(key);
     ht[key] = keys.end();
     dict[key] = value;
 }
开发者ID:wxn7,项目名称:Leetcode,代码行数:19,代码来源:146.LRU.cpp

示例2: bSearch

int bSearch(int x)
{
	int lo = 0;
	int hi = dq.size();
	int mid;
	int ans;
	while(lo <= hi)
	{
		mid = (lo+hi)/2;
		if(x <= dq[mid])
		{
			hi = mid - 1;
			ans = mid;
		}
		else lo = mid + 1;
	}
	
	return ans;
}
开发者ID:habibruetian12,项目名称:LightOj,代码行数:19,代码来源:C.cpp

示例3: DisplayCpp

void DisplayCpp()
{
	size_t i;
	cin.get();
	cout << endl;
	cout << "****************************************************" << endl;
	cout << "*               Display   C++    vip               *" << endl;
	cout << "****************************************************" << endl;
	cout << endl;

    if(vip.empty())
    {
    	cout << endl;
		cout << " There is no C++ vip info." <<endl;
       	cout << endl;
    }


	for(i = 0; i < vip.size(); i++)
	{
		pVip = vip[i];

		if(typeid(*pVip) == typeid(CPP))
		{
            cout << endl;
            cout << "****************************************************" << endl;
            cout << "*                  Press enter key                 *" << endl;
            cout << "****************************************************" << endl;
            cin.get();
			cout<<endl;

			pVip->DisplayInfo();
			pVip->DisplayOtherInfo();
		}
	}

	cout << endl;
	cout << "****************************************************" << endl;
	cout << "*            Press ENTER to back to menu           *" << endl;
	cout << "****************************************************" << endl;
	cin.get();
	cout<<endl;
}
开发者ID:jeakeven,项目名称:VipInfoMgr,代码行数:43,代码来源:VipMgr.cpp

示例4: SearchVip

void SearchVip(const string& studentId)
{
	size_t i;

	for(i = 0; i < vip.size(); i++)
	{
		pVip = vip[i];
		if(0 == studentId.compare(pVip->GetStudentId()))
		{
			cout << endl;
			pVip->DisplayInfo();
			pVip->DisplayOtherInfo();
			return;
		}
	}
    cout << "********************************************************" <<endl;
    cout << "*                 Can't find vip...                    *" <<endl;
    cout << "********************************************************" <<endl;
}
开发者ID:jeakeven,项目名称:VipInfoMgr,代码行数:19,代码来源:VipMgr.cpp

示例5: isDivByThree

bool isDivByThree(const deque<unsigned int>& number){

  if (number.size() == 1){
    if (number[0] == 3 || number[0] == 6 || number[0] == 9)
      return true;
    else
      return false;
  }

  deque<unsigned int> total;

  for (deque<unsigned int>::const_iterator itr = number.begin(), endItr = number.end() ; itr != endItr; itr++)
    vecSum(total, *itr);
     
  if (isDivByThree(total))
    return true;

  return false;
}
开发者ID:bhrzslm,项目名称:practice,代码行数:19,代码来源:10070.cpp

示例6: __copy

void deque::__copy(deque const &other) {
    iterator tmp = __reserve(other.sz);
    size_t r = 0;
    try {
        for (int i = 0; i < other.size(); i++) {
            new((void *) (&*(tmp + i))) value_type(other[i]);
            r++;
        }
        operator delete(&*a);
        a = tmp;
        head =a;
        tail = a+(sz-1);
    } catch (...) {
        for (int i = 0; i <= r; i++) {
            (&*(tmp + i))->~basic_string();
        }
        operator delete(&*tmp);
    }
}
开发者ID:Kirik64rus,项目名称:ClionProjects,代码行数:19,代码来源:deque.cpp

示例7: aux

    void aux(int s, int e) {
        stk.push_front(s);
        if (s == 0) {
            now.clear();
            now += cs.substr(stk[0], stk[1]);
            for (int j = 1; j < stk.size() - 1; j++) {
                now.push_back(' ');
                int t1 = stk[j], t2 = stk[j + 1] - t1;
                now += cs.substr(t1, t2);
            }
            res.push_back(now);
        } else {
            for (auto& i : vec[s]) {
                aux(i, s);
            }
        }

        stk.pop_front();
    }
开发者ID:KKRainbow,项目名称:LeetCode,代码行数:19,代码来源:WordBreakII.cpp

示例8: draw_features

void draw_features( IplImage* img, feature* feat, const deque<int>& kids)
{
	CvScalar color = CV_RGB( 255, 255, 255 );
	int i;

	if( img-> nChannels > 1 )
	{
		color = FEATURE_LOWE_COLOR;
	}
	for( i = 0; i < kids.size(); i++ )
	{
		//draw_lowe_feature( img, feat + i, color );
		int len, hlen, blen, start_x, start_y, end_x, end_y, h1_x, h1_y, h2_x, h2_y;
		double scl, ori;
		double scale = 5.0;
		double hscale = 0.75;
		CvPoint start, end, h1, h2;

		/* compute points for an arrow scaled and rotated by feat's scl and ori */
		start_x = cvRound( feat[kids[i]].x );
		start_y = cvRound( feat[kids[i]].y );
		scl = feat[kids[i]].scl;
		ori = feat[kids[i]].ori;
		len = cvRound( scl * scale );
		hlen = cvRound( scl * hscale );
		blen = len - hlen;
		end_x = cvRound( len *  cos( ori ) ) + start_x;
		end_y = cvRound( len * -sin( ori ) ) + start_y;
		h1_x = cvRound( blen *  cos( ori + CV_PI / 18.0 ) ) + start_x;
		h1_y = cvRound( blen * -sin( ori + CV_PI / 18.0 ) ) + start_y;
		h2_x = cvRound( blen *  cos( ori - CV_PI / 18.0 ) ) + start_x;
		h2_y = cvRound( blen * -sin( ori - CV_PI / 18.0 ) ) + start_y;
		start = cvPoint( start_x, start_y );
		end = cvPoint( end_x, end_y );
		h1 = cvPoint( h1_x, h1_y );
		h2 = cvPoint( h2_x, h2_y );

		cvLine( img, start, end, color, 1, 8, 0 );
		cvLine( img, end, h1, color, 1, 8, 0 );
		cvLine( img, end, h2, color, 1, 8, 0 );
	}

}
开发者ID:landys,项目名称:ndfinder,代码行数:43,代码来源:vwquery.cpp

示例9: ofPushView

//----------------------------------------------------------
void ofPushView() {
	
	GLint viewport[4];
	glGetIntegerv(GL_VIEWPORT, viewport);
	
	ofRectangle currentViewport;
	currentViewport.set(viewport[0], viewport[1], viewport[2], viewport[3]);
	viewportHistory.push_front(currentViewport);
	
	if( viewportHistory.size() > OF_MAX_VIEWPORT_HISTORY ){
		viewportHistory.pop_back();
		//should we warn here?
		//ofLog(OF_LOG_WARNING, "ofPushView - warning: you have used ofPushView more than %i times without calling ofPopView - check your code!", OF_MAX_VIEWPORT_HISTORY);
	}
	
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
}
开发者ID:pampam,项目名称:openFrameworks,代码行数:21,代码来源:ofGraphics.cpp

示例10: process

void Machine::process()
{
    int pos = 0;
    while(_state != _accept) {
        if (pos < 0) {
            _tape.push_front('_');
            pos = 0;
            _start_pos += 1; //Update for printing '|'
        } else if (pos == _tape.size()) {
            _tape.push_back('_');
        }
        char symbol = _tape[pos];
        tuple<string, char> before = make_tuple(_state, symbol);
        tuple<string, char, char> after = _rules[before];
        _state = get<0>(after);
        _tape[pos] = get<1>(after);
        pos += (get<2>(after) == '>') ? 1 : -1;
        _head_pos = max(pos,0); //Update for printing '^'
    }
}
开发者ID:pbscrimmage,项目名称:daily_prog,代码行数:20,代码来源:turing.cpp

示例11: updateDeque

void updateDeque(deque<int> &dq, int k, int newNumber, bool keepSize=true) {
    int poppedCount = 0;
    int initialSize=dq.size();
    for(int i=0; i<k && i<initialSize; i++) {
        if(dq.back()<newNumber) {
            dq.pop_back();
            poppedCount++;
        } else {
            break;
        }
    }

    for(int i=0; i<poppedCount; i++)
        dq.push_back(newNumber);

    if(keepSize) {
        dq.pop_front();
    }
    dq.push_back(newNumber);
}
开发者ID:alchemz,项目名称:hackerrank,代码行数:20,代码来源:DequeSTL.cpp

示例12: dualOperands

 void dualOperands(string& opCode)
 {
   if(s.size() >= 2) {
     double a = s.front(); s.pop_front();
     double b = s.front(); s.pop_front();
     double result;
          if(opCode == "+")  result = a + b;
     else if(opCode == "-")  result = a - b;
     else if(opCode == "*")  result = a * b;
     else if(opCode == "/")  result = a / b;
     else if(opCode == "**") result = exp(b*log(a));
     else {
       cout << "unknown operator " << opCode.c_str() << endl;
       return;
     }
     cout << result << endl;
     s.push_front(result);
   } else
     cout << "need two numbers\n";
 }
开发者ID:CaptGreg,项目名称:SenecaOOP344-attic,代码行数:20,代码来源:stl-calc3.cpp

示例13: apply

	void TriResMultiHalfTone::apply(deque<double>& buff)
	{
		if(buff.size()<m_convolutions[0][0]->size()) return;

		for(size_t h=0; h<m_convolutions.size(); h++)
		{
			m_convolutions[h][0]->apply(buff);
			Math::polar<double> sol = m_convolutions[h][0]->m_trans;

			for(size_t i=1; i<m_convolutions[h].size(); i++)
			{
				m_convolutions[h][i]->apply(buff, 0);
				sol.mod = min(sol.mod, sqrt(norm(m_convolutions[h][i]->m_trans)));
				m_convolutions[h][i]->apply(buff, m_convolutions[h][0]->size()-m_convolutions[h][i]->size());
				sol.mod = min(sol.mod, sqrt(norm(m_convolutions[h][i]->m_trans)));
			}

			m_components[h] = Math::make_complex(sol);
		}
	}
开发者ID:eduardovra,项目名称:coucher,代码行数:20,代码来源:FreqAnalysis.cpp

示例14: AddPacket

    virtual void AddPacket(BYTE *data, UINT size, DWORD timestamp, DWORD pts, PacketType type) override
    {
        packets.emplace_back(make_shared<packet_t>(type, timestamp, pts, vector<BYTE>(data, data + size)));

        if (data[0] != 0x17)
            return;

        HandleSaveTimes(pts);

        keyframes.emplace_back(timestamp, --end(packets));

        while (keyframes.size() > 2)
        {
            if (((long long)timestamp - keyframes[0].first) < (seconds * 1000) || ((long long)timestamp - keyframes[1].first) < (seconds * 1000))
                break;

            packets.erase(begin(packets), keyframes[1].second);
            keyframes.erase(begin(keyframes));
        }
    }
开发者ID:Hell0wor1d,项目名称:OBS,代码行数:20,代码来源:ReplayBuffer.cpp

示例15: insert_lines

void File::insert_lines( const unsigned int& line, deque<string> d, bool break_lines ) {
  unsigned int temp = fun::bound( line, (unsigned int) 0, get_num_lines() );

  if ( break_lines ) {
    deque<string> ready;
    vector<string> lines;
    
    // Break each line in d on \n if specified, before putting into file contents
    for ( unsigned int i = 0; i < d.size(); i++ ) {
      lines = str_breakup( d[i], "\n" );      
      ready.insert( ready.end(), lines.begin(), lines.end() );
    }
    
    d = ready;
  }
  
  m_file.insert( m_file.begin() + line, d.begin(), d.end() );
  
  return;
}
开发者ID:umairsajid,项目名称:my-random-cpp-libraries,代码行数:20,代码来源:file.cpp


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