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

C++ pre函数代码示例

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

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



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

示例1: input

void input()
{
        pre();
        int i;
        printf("enter number of process\n");
        scanf("%d",&n);
        for(i=0;i<n;i++)
        {
                printf("enter arrival time and head location of %d\n",i+1);
                scanf("%d%d",&disk[i].arr_time,&disk[i].head_loc);
                disk[i].process_pid=i+1;
                done[i]=false;
        }
        printf("enter head position\n");
        scanf("%d",&head_pos);
        val=head_pos;
}
开发者ID:yashchauhan28,项目名称:disk-scheduling,代码行数:17,代码来源:main.c


示例2: timestamp

/* time and memory management outputs */
void timestamp(const char* const fmt, ...)
{
    pre(fmt != NULL);

    va_list ap;
    va_start(ap, fmt);
    fflush(stdout);
    fputc('\n', stderr);
    vfprintf(stderr, fmt, ap);
    fputc('\n', stderr);
    va_end(ap);

//    fprintf(stderr, "%s\n", string);
    time_t t1 = time(0);
    fprintf(stderr, "%3.2f sec. elapsed\n", difftime(t1,t0));
    fprintf(stderr, "--------------------------------------------\n");
}
开发者ID:aakrosh,项目名称:indelMINER,代码行数:18,代码来源:resources.c


示例3: isMatch

    bool isMatch(string s, string p) {
        int sLen = s.size(), pLen = p.size();
        vector<bool> pre(pLen + 1, false), cur(pLen + 1, false);

        pre[0] = true;
        for (int pIter = 2; pIter <= pLen; pIter++) pre[pIter] = p[pIter - 1] == '*' && pre[pIter - 2];

        for (int sIter = 1; sIter <= sLen; sIter++) {
            cur[0] = false;
            for (int pIter = 1; pIter <= pLen; pIter++) {
                if (p[pIter - 1] == '*') cur[pIter] = cur[pIter - 2] || pre[pIter] && (s[sIter - 1] == p[pIter - 2] || p[pIter - 2] == '.');
                else cur[pIter] = pre[pIter - 1] && (s[sIter - 1] == p[pIter - 1] || p[pIter - 1] == '.');
            }
            pre = cur;
        }
        return pre[pLen];
    }
开发者ID:XiangyuLi926,项目名称:Online-Judge,代码行数:17,代码来源:LC010-Regular+Expression+Matching.cpp


示例4: bindKeyDownEvent

void bimWorld::CameraManipulator::enableFirstPersonControl()
{

	bindKeyDownEvent(KEY_W, beginMoveForward);
	bindKeyUpEvent(KEY_W, endMoveForward);

	bindKeyDownEvent(KEY_S, beginMoveBackward);
	bindKeyUpEvent(KEY_S, endMoveBackward);

	bindKeyDownEvent(KEY_A, beginMoveLeft);
	bindKeyUpEvent(KEY_A, endMoveLeft);

	bindKeyDownEvent(KEY_D, beginMoveRight);
	bindKeyUpEvent(KEY_D, endMoveRight);
	unbindMouseEvent(MIDDLE_MOUSE_BUTTON);

	return;
	//if (m_isFirstPersonManipEnabled)
	//	return;
	//switchMatrixManipulator(ManipulatorType::Person);
	//m_isFirstPersonManipEnabled = true;
	//getBIMCameraManip()->setRotationHandleBtn(osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON);
	//float totalFrame = 60.0f;
	bimWorld::CameraOperation operation(getBIMCameraManip());
	m_zoomForwardDelta = operation.getZoomDelta(totalFrame_FP);
	std::function<void(float)> prefunc = [this/*, totalFrame*/](float frame){
		//static int frame = 1;
		//static float newF = 1;//-1 / totalFrame * frame*frame + frame;
		bimWorld::CameraOperation operation(getBIMCameraManip());
		operation.zoomForward(m_zoomForwardDelta, frame);
		//if (newF < (totalFrame / 2.0f))
		//{
		//	frame++;
		//	newF += frame;
		//}
		//else
		//{
		//	frame--;
		//	newF -= frame;
		//}
	};
	core::InstanceFunction<void(float)> pre(prefunc, this, "onPreEnableFirstPersonControl");
	std::function<void(float)> postfunc = [](float){};
	core::InstanceFunction<void(float)> post(postfunc, this, "onPostEnableFirstPersonControl");
	m_host->_RenderingThreads()->setBlockAnimation((unsigned int)totalFrame_FP, pre, post);
}
开发者ID:whztt07,项目名称:RefactoringOSG,代码行数:46,代码来源:CameraManipulators.cpp


示例5: look

int look()
{
        pre();
        printf("performing look\n\n");
        int i,curr,j;
        int tot_time=0;
        int time_diff;
        int time;
        curr=head_pos;
        time=0;
        sort_headloc(disk,0,n-1);
        while(1)
        {
                bool check =false;
                for(i=0;i<n;i++)
                        if(done[i]==false)
                                check=true;
                if(check==false)
                        break;
                for(i=0;i<n;i++)
                {
                    time_diff = disk[i].head_loc - head_pos;
                    if(time_diff + time >= disk[i].arr_time && done[i]==false)
                    {
                        done[i]=true;
                        printf("request serve for %d process\n",disk[i].process_pid);
                        time+=time_diff;
                        head_pos=disk[i].head_loc;
                    }
                }
                for(i=n-1;i>=0;i--)
                {
                    time_diff = abs(head_pos-disk[i].head_loc);
                    if(time_diff + time >= disk[i].arr_time && done[i]==false)
                    {
                        done[i]=true;
                        printf("request serve for %d process\n",disk[i].process_pid);
                        time+=time_diff;
                        head_pos=disk[i].head_loc;
                    }
                }
        }
        tot_time=time;
        return tot_time;
}
开发者ID:yashchauhan28,项目名称:disk-scheduling,代码行数:45,代码来源:main.c


示例6: func_hashtable

/* apply this function to every non-null bin in the hashtable */
void func_hashtable(hashtable* const hash, 
					void (*func)(bin* bin))
{
    pre(func != NULL);

	int i;
	bin* iter;
	bin* next;
	
	for(i = 0; i < hash->size; i++){
		iter = hash->bins[i];
		while(iter){
			next = iter->next;
			func(iter);
			iter = next;
		}
	}
}
开发者ID:aakrosh,项目名称:indelMINER,代码行数:19,代码来源:hashtable.c


示例7: PyObject_GetAttrString

EXPORT ICUException::ICUException(UParseError &pe, UErrorCode status)
{
    PyObject *messages = PyObject_GetAttrString(PyExc_ICUError, "messages");
    UnicodeString pre((const UChar *) pe.preContext, U_PARSE_CONTEXT_LEN);
    UnicodeString post((const UChar *) pe.postContext, U_PARSE_CONTEXT_LEN);
    PyObject *tuple = PyTuple_New(5);

    ICUException::code = PyInt_FromLong((long) status);
    
    PyTuple_SET_ITEM(tuple, 0, PyObject_GetItem(messages, code));
    PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(pe.line));
    PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(pe.offset));
    PyTuple_SET_ITEM(tuple, 3, PyUnicode_FromUnicodeString(&pre));
    PyTuple_SET_ITEM(tuple, 4, PyUnicode_FromUnicodeString(&post));
    ICUException::msg = tuple;

    Py_DECREF(messages);
}
开发者ID:kluge-iitk,项目名称:pyicu,代码行数:18,代码来源:common.cpp


示例8: isMatch

    bool isMatch(const char *s, const char *p) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        if(!s || !p || !initCheck(s, p))
			return false;
		if(!*p)
			return !*s;
		int len = strlen(p);
		vector<bool> pre(len, false);
		vector<bool> cur(len, false);
		bool isFirst = true;
		for(int i = 0; i < len; i++)
		{
			if(p[i] == '*')
				pre[i] = (i == 0) || pre[i-1];
			else if((*s == p[i] || p[i] == '?') && isFirst)
			{
				isFirst = false;
				pre[i] = true;
			}
			else
				break;
		}
		s++;
		while(*s)
		{
			for(int i = 0; i < len; i++)
			{
				if(p[i] == '*')
				{
					cur[i] = pre[i] || (i != 0 && cur[i-1]);
				}
				else
				{
					cur[i] = (i != 0 && pre[i-1] && (p[i] == *s || p[i] == '?')); 
				}
			}
			pre.assign(cur.begin(), cur.end());
			cur.assign(len, false);
			s++;
		}
		return pre[len-1];
    }
开发者ID:pkuxxy,项目名称:LeetCode,代码行数:43,代码来源:Wildcard+Matching.cpp


示例9: irg_walk_2_pre

/**
 * specialized version of irg_walk_2, called if only pre callback exists
 */
static void irg_walk_2_pre(ir_node *node, irg_walk_func *pre, void *env)
{
	ir_graph    *irg     = get_irn_irg(node);
	ir_visited_t visited = irg->visited;

	set_irn_visited(node, visited);

	pre(node, env);

	if (!is_Block(node)) {
		ir_node *pred = get_nodes_block(node);
		if (pred->visited < visited)
			irg_walk_2_pre(pred, pre, env);
	}
	foreach_irn_in_r(node, i, pred) {
		if (pred->visited < visited)
			irg_walk_2_pre(pred, pre, env);
	}
}
开发者ID:lamproae,项目名称:libfirm,代码行数:22,代码来源:irgwalk.c


示例10: longest_palindrome

// returns the center of the longest palindrome. for its length search for P[ans]
int longest_palindrome() {
	pre();
	int c=0; int r=0; 
	for(int i=1; i<N-1; i++) {
		int mirror = 2*c-i;
		P[i] = r>i ? min(r-i,P[mirror]) : 0;
		while(A[i+1+P[i]]==A[i-1-P[i]])
			P[i]++;
		if(i+P[i] > r) {
			c=i; r=i+P[i];
		}
	}
	int maxlen=0; int centeri=0;
	for(int i=1; i<n-1; i++) {
		if(P[i]>maxlen) {
			maxlen=P[i]; centeri=i;
		}
	}
	return centeri;
}
开发者ID:tapasjain,项目名称:competitive-programming,代码行数:21,代码来源:manacher.cpp


示例11: main

int main() {
    int cas, d;
    cin >> cas;
    for(int i = 0 ;i < cas;i ++) {
        cin >> d;
        a = 2013;
        b = 3;
        c = 24;
        for(int f = 0 ; f < d;f++)
            next();
        printf("%d/%02d/%02d ", a, b, c);
        a = 2013;
        b = 3;
        c = 24;
        for(int f = 0 ; f < d;f++)
            pre();
        printf("%d/%02d/%02d\n", a, b, c);
    }
    return 0;
}
开发者ID:LinKin-22,项目名称:acm-algorithm,代码行数:20,代码来源:4515+2013-11-25+20+08+36.cpp


示例12: main

int main()
{
	int i, n;
	scanf("%d", &n);
	getchar();
	for(i=0; i<n; i++) {
		char s[10];;
		gets(s);
		if(s[2] == '.') s[2]=0;
		if(s[4] == '.') s[4]=0;
		node[s[0]-'A'][0] = s[2];
		node[s[0]-'A'][1] = s[4];
	}

	pre('A'); puts("");	
	in('A'); puts("");	
	post('A'); puts("");	

	return 0;
}
开发者ID:YongHoonJJo,项目名称:BOJ,代码行数:20,代码来源:1991.c


示例13: lookup_hashtable

/*look up the hash table to see an entry corresponding to the string of length
 * len exists. Return the bin if it does exist*/
void* lookup_hashtable(hashtable* const hash, 
				       const char* const name, 
				       const int len)
{
    pre(name != NULL);

	uint32_t index = hashfunc(name, len);
	index = index & hash->mask;
	
	bin* iter = NULL;
	bin* bin = NULL;
	if(hash->bins[index] != NULL){
		for(iter = hash->bins[index];iter; iter = iter->next){
			if(strncmp(iter->name, name, len) == 0){
				bin = iter;
			}
		}
	}
	return bin;
}
开发者ID:aakrosh,项目名称:indelMINER,代码行数:22,代码来源:hashtable.c


示例14: iterate_parallel_cluster

void
iterate_parallel_cluster(pccluster t, uint tname, uint pardepth,
			 void (*pre) (pccluster t, uint tname, void *data),
			 void (*post) (pccluster t, uint tname, void *data),
			 void *data)
{
  uint     *tname1, tname2;
#ifdef USE_OPENMP
  uint      nthreads;		/* HACK: Solaris workaround */
#endif
  uint      i;

  if (pre)
    pre(t, tname, data);

  if (t->sons > 0) {
    tname1 = (uint *) allocmem((size_t) sizeof(uint) * t->sons);

    tname2 = tname + 1;
    for (i = 0; i < t->sons; i++) {
      tname1[i] = tname2;
      tname2 += t->son[i]->desc;
    }
    assert(tname2 == tname + t->desc);

#ifdef USE_OPENMP
    nthreads = t->sons;
    (void) nthreads;
#pragma omp parallel for if(pardepth > 0), num_threads(nthreads)
#endif
    for (i = 0; i < t->sons; i++)
      iterate_parallel_cluster(t->son[i], tname1[i],
			       (pardepth > 0 ? pardepth - 1 : 0), pre, post,
			       data);

    freemem(tname1);
  }

  if (post)
    post(t, tname, data);
}
开发者ID:H2Lib,项目名称:H2Lib,代码行数:41,代码来源:cluster.c


示例15: configuration

nemo::Configuration
configuration(backend_t backend)
{
	nemo::Configuration conf;

	std::vector<float> pre(20);
	std::vector<float> post(20);
	for(unsigned i = 0; i < 20; ++i) {
		int dt = i;
		pre.at(i) = dwPre(-dt);
		post.at(i) = dwPost(dt);
	}
	/* don't allow negative synapses to go much more negative.
	 * This is to avoid having large negative input currents,
	 * which will result in extra firing (by forcing 'u' to
	 * go highly negative) */
	conf.setStdpFunction(pre, post, -0.5, 2*initWeight);
	setBackend(backend, conf);

	return conf;
}
开发者ID:MogeiWang,项目名称:nemosim,代码行数:21,代码来源:stdp.cpp


示例16: main

int main(int argc, char* argv[])
{
    //=====Empeche de lancer COW plusieurs fois
    QtSingleApplication app(argc, argv);
    if (app.isRunning())
	return 0;
    //==========
	
    QDir::setCurrent(QDir::currentPath());

	//=====Informations
	app.setApplicationName("COW Chat Over the World");
	app.setApplicationVersion("2.0.0.0");
	app.setOrganizationDomain("the-cow.org");
	app.setOrganizationName("Basile Bruneau");
	//==========
	
	//=====Traductions
    QString locale = QLocale::system().name();
    QTranslator trans;
    trans.load(QString(":/translations/qt_") + locale);
    app.installTranslator(&trans);

    QTranslator translator;
    translator.load(QString(":/translations/cow-client_") + locale.section('_', 0, 0));
    app.installTranslator(&translator);

    preFen pre("",locale.section('_', 0, 0));
	//==========
    
    app.setActivationWindow(&pre); //Empeche de lancer COW plusieurs fois
    
    /* Bien sur, il ne suffit pas d'enlever certaines parties du code pour pouvoir lancer
    COW une infinité de fois. Vous vous doutez bien qu'il y a un controle par ip
    sur le serveur */
    
    pre.show();

    return app.exec();
}
开发者ID:NTag,项目名称:thecow,代码行数:40,代码来源:main.cpp


示例17: splitIndicator

bool TreeView::add(const std::string& name,
                   const osg::ref_ptr<osg::Node> node,
                   const bool& enableNode,
                   const bool& showNode,
                   const bool& replace,
                   d3DisplayItem* myParent)
{
    static const std::string splitIndicator("::");

    // get the name split point
    size_t nameSplit( name.find(splitIndicator) );

    // see if we have children
    if ( std::string::npos != nameSplit )
    {
        // the first part is the parent's name
        std::string pre( name.substr(0, nameSplit) );

        // the second part is the children
        std::string post( name.substr(nameSplit + splitIndicator.size(), name.size()) );

        // call the add parent
        return addParent(pre, post, node, enableNode, showNode, replace, myParent);
    }

    // this must be a leaf node... do we already have this child?
    d3DisplayItem* entry(findChild(myParent, name));

    // see if we need to create a new entry
    if ( nullptr == entry )
    {
        return createNewEntry(name, node, enableNode, showNode, myParent);
    }
    else
    {
        return addToEntry(entry, node, enableNode, replace, myParent);
    }

    return false;
};
开发者ID:theidealist,项目名称:developerDebugDisplay,代码行数:40,代码来源:TreeView.cpp


示例18: generate

 vector<vector<int> > generate(int numRows) {
     // Start typing your C/C++ solution below
     // DO NOT write int main() function
     vector<int> pre(1, 1);
     vector<vector<int> > result;
     
     for(int i = 0; i< numRows; i++)
     {
         vector<int> row(i+1);
         for(int j = 1; j < i; j++)
         {
             row[j] = pre[j-1] + pre[j];
         }
         row[0] = 1;
         row[i] = 1; 
         result.push_back(row);
         pre = row;
     }
     
     return result;
     
 }
开发者ID:daimadou,项目名称:LeetCode,代码行数:22,代码来源:Pascal's+Triangle.cpp


示例19: kmp

//returns all positions of matched in given text
vector<int> kmp(string text, string pattern)
{
	vector<int> pre(pattern.size());
	vector<int> ans;
	if (pattern.size() == 0) return ans;
	prefix_function(pre, pattern);
	int j = -1;
	//Complexity is O(n)
	for (int i=0 ; i<text.size(); ++i) {
		while (j>=0 && text[i]!=pattern[j + 1]) {
			j = pre[j];
		}
		if (text[i] == pattern[j + 1]) {
			j++;
			if (j+1 == pattern.size()) {
				ans.push_back(i - j);
				j = pre[j];
			}
		}
	}
	return ans;
}
开发者ID:karthik512,项目名称:Data-Structures,代码行数:23,代码来源:KMP.cpp


示例20: combinationSum

	void combinationSum(vector<int> &candidates, int index, int target, vector<vector<int> > &result) {
		if(target <= 0)
			return;
		
		while(index<candidates.size() && target>=candidates[index]) {
			for(int i=1; candidates[index]*i<=target; ++i) {
				vector<int> pre(i, candidates[index]);
				vector<vector<int> > res;
				if(target == candidates[index]*i) {
					result.push_back(pre);
				} else {
					combinationSum(candidates, index+1, target-candidates[index]*i, res);
					for(int j=0; j<res.size(); ++j) {
						vector<int> item = pre;
						item.insert(item.end(), res[j].begin(), res[j].end());
						result.push_back(item);
					}
				}
			}
			++index;
		}
	}
开发者ID:cselys,项目名称:leetcode-5,代码行数:22,代码来源:95.+Combination+Sum.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ preOrder函数代码示例发布时间:2022-05-30
下一篇:
C++ prctl函数代码示例发布时间: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