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

C++ createNode函数代码示例

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

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



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

示例1: insert

//插入节点  
bool insert(skiplist *sl,int key,int value)  
{  
    nodeStructure *update[MAX_LEVEL];  
    nodeStructure *p, *q = NULL;  
    p=sl->header;  
    int k=sl->level;  
    //从最高层往下查找需要插入的位置  
    //填充update  
    for(int i=k-1; i >= 0; i--){  
        while((q=p->forward[i])&&(q->key<key))  
        {  
            p=q;  
        }  
        update[i]=p;  
    }  
    //不能插入相同的key  
    if(q&&q->key==key)  
    {  
        return false;  
    }  
    
    //产生一个随机层数K  
    //新建一个待插入节点q  
    //一层一层插入  
    k=randomLevel();  
    //更新跳表的level  
    if(k>(sl->level))  
    {  
        for(int i=sl->level; i < k; i++){  
            update[i] = sl->header;  
        }  
        sl->level=k;  
    }  
    
    q=createNode(k,key,value);  
    //逐层更新节点的指针,和普通列表插入一样  
    for(int i=0;i<k;i++)  
    {  
        q->forward[i]=update[i]->forward[i];  
        update[i]->forward[i]=q;  
    }  
    return true;  
}  
开发者ID:wangweichaogit,项目名称:exc,代码行数:44,代码来源:skiplist.c


示例2: createNode

void LinkedList::appendNodeBack (int key)
{
	node *newNode = createNode(key);

	//if tree is empty
	if (head == NULL)
	{
		head = newNode;
		return;
	}

	//if tree is not empty
	//traverse to the last node in the list
	node *temp = head;
	while (temp->next != NULL)
		temp = temp->next;

	temp->next = newNode;
}
开发者ID:faizabidi,项目名称:CPlusPlus_Random,代码行数:19,代码来源:node.cpp


示例3: while

AglLooseBspTreeConstructor::AglLooseBspTreeConstructor(unsigned int p_targetMesh, vector<AglVector3> p_vertices, vector<unsigned int> p_indices)
{
	int count = 1;
	while (count < (int)(p_indices.size() / 3))
	{
		count *= 2;
	}
	count += count-1;
	m_nodes = vector<AglBspNode>(count);
	m_root = 0;
	m_targetMesh = p_targetMesh;

	for (unsigned int i = 0; i < p_indices.size() / 3; i++)
	{
		AglBspTriangle t(i, p_vertices, p_indices);
		m_triangles.push_back(t);
	}
	m_root = createNode(0, m_triangles.size(), 0);
}
开发者ID:MattiasLiljeson,项目名称:Amalgamation,代码行数:19,代码来源:AglLooseBspTree.cpp


示例4: lladdNpos

void lladdNpos(linklist* ll,data* d,int n){

  int i = 1;
  node* newNode = createNode(d);
  node* temp = ll->head;
  node* prev = NULL;
  for(i;i < n;i++){

    prev = temp;
    temp = prev->next;
  }
  if(i == 1){

    temp->next = ll->head;
    ll->head = temp;
  }
  prev->next = newNode;
  newNode->next = temp;
}
开发者ID:dmcarr92,项目名称:Sophomore-Year-C-CPP,代码行数:19,代码来源:linklist.c


示例5: LBASSERT

bool Client::_setupClient( const std::string& clientArgs )
{
    LBASSERT( isListening( ));
    if( clientArgs.empty( ))
        return true;

    size_t nextPos = clientArgs.find( CO_SEPARATOR );
    if( nextPos == std::string::npos )
    {
        LBERROR << "Could not parse working directory: " << clientArgs
                << std::endl;
        return false;
    }

    const std::string workDir = clientArgs.substr( 0, nextPos );
    std::string description = clientArgs.substr( nextPos + 1 );

    Global::setWorkDir( workDir );
    if( !workDir.empty() && chdir( workDir.c_str( )) == -1 )
        LBWARN << "Can't change working directory to " << workDir << ": "
               << lunchbox::sysError << std::endl;

    nextPos = description.find( CO_SEPARATOR );
    if( nextPos == std::string::npos )
    {
        LBERROR << "Could not parse server node type: " << description
                << " is left from " << clientArgs << std::endl;
        return false;
    }

    co::NodePtr server = createNode( fabric::NODETYPE_SERVER );
    if( !server->deserialize( description ))
        LBWARN << "Can't parse server data" << std::endl;

    LBASSERTINFO( description.empty(), description );
    if( !connect( server ))
    {
        LBERROR << "Can't connect server node using " << *server << std::endl;
        return false;
    }

    return true;
}
开发者ID:tribal-tec,项目名称:Equalizer,代码行数:43,代码来源:client.cpp


示例6: insert

int insert(trie_t  * troot, char key[]){

    int i, index;
    trieNode_t *temp  = troot->root;
    int len = strlen(key);

    for(i=0;i<len;i++){

        index = key[i]-'a';
        if(!temp->child[index]){
            temp->child[index] = createNode();
        }

        temp = temp->child[index];
    }
    troot->count++;

    temp->eos =troot->count ;
}
开发者ID:mayurdabhi,项目名称:CodingPractice,代码行数:19,代码来源:main.c


示例7: tgtAssert

VolumeOctreeNode* VolumeOctreeBase::createNode(size_t numChannels) {
    tgtAssert(numChannels > 0 && numChannels <= 4, "number of channels must be between 1 and 4");
    uint16_t* avgValues = new uint16_t[numChannels];
    uint16_t* minValues = new uint16_t[numChannels];
    uint16_t* maxValues = new uint16_t[numChannels];
    for (size_t c=0; c<numChannels; c++) {
        avgValues[c] = 0;
        minValues[c] = 0;
        maxValues[c] = 0;
    }

    VolumeOctreeNode* node = createNode(numChannels, avgValues, minValues, maxValues);

    delete[] avgValues;
    delete[] minValues;
    delete[] maxValues;

    return node;
}
开发者ID:emmaai,项目名称:fractalM,代码行数:19,代码来源:volumeoctreebase.cpp


示例8: main

int main() {
	int val;
	printf("Enter some numbers, ending with -1: ");
	while (1) {
		scanf("%d",&val);
		if (val == -1) {
			break;
		}
		IntNode *node = createNode(val);
		//printf("%d\n",val);
		if (first == NULL) {
			first = node;
		}
		//printf("first is: %d\n",first -> item);
		insert(node,val);
	}

	printAll(first);
}
开发者ID:dlee37,项目名称:Computer-Systems,代码行数:19,代码来源:intsort.c


示例9: Balance

NodeT *insertNode(NodeT *root, int value)
{
    if(root == NULL)
    {
        NodeT *p=createNode(value);
        return p;
    }
    else
    {
        if(value > root->data)
            root -> right = insertNode(root->right, value);
        else
            root -> left = insertNode(root->left, value);

        root->height = maxim(compHeight(root->left), compHeight(root->right)) +1;

        return Balance(root);
    }
}
开发者ID:Alecs94,项目名称:DSA-lab,代码行数:19,代码来源:insdelFunctions.c


示例10:

NodeT *getTreeFromList()
{
    NodeT *p;
    int data;
    data=head->data;
    head=head->next;
    if (data=='*')
    {
        return NULL;
        //printf("amajunsaici ");
    }
    else
    {
        p=createNode(data);
        p->left=getTreeFromList( );
        p->right=getTreeFromList();
    }
    return p;
}
开发者ID:Alecs94,项目名称:DSA-lab,代码行数:19,代码来源:main.c


示例11: START_TEST

END_TEST

START_TEST(replaceOldNode) {
    UA_Node* n1 = createNode(0,2253);
    ns.insertNode(ns.context, n1, NULL);
    UA_NodeId in1 = UA_NODEID_NUMERIC(0,2253);
    UA_Node* n2;
    UA_Node* n3;
    ns.getNodeCopy(ns.context, &in1, &n2);
    ns.getNodeCopy(ns.context, &in1, &n3);

    /* shall succeed */
    UA_StatusCode retval = ns.replaceNode(ns.context, n2);
    ck_assert_int_eq(retval, UA_STATUSCODE_GOOD);

    /* shall fail */
    retval = ns.replaceNode(ns.context, n3);
    ck_assert_int_ne(retval, UA_STATUSCODE_GOOD);
}
开发者ID:jpfr,项目名称:open62541,代码行数:19,代码来源:check_nodestore.c


示例12: main

int main(int argc, char **argv) {
	int i, n;
	Node *root;
	while (scanf("%s", string) != EOF) {
		poolPos = 0;
		n = strlen(string);
		root = createNode();
		for (i = 0; i < n; i++)
			addToTrie(root, i, n);
		
		findSuffix(root);
		getSuffix(root, 0);
		printf("%s\n", suffix);
		
//		destroyNode(root);
	}
	
	return EXIT_SUCCESS;
}
开发者ID:wkoder,项目名称:CINVESTAV,代码行数:19,代码来源:suffixtree.c


示例13: rootInsertion

nodePtr rootInsertion(char* word, nodePtr leaf)
{
	if(leaf == NULL)
		return createNode(word);

	if(strcmp(word,leaf->info.word ) < 0)
	{
		leaf->left = rootInsertion(word, leaf->left);
		leaf = rightRotation(leaf);
	}
	
	else if((strcmp(word,leaf->info.word) > 0))
	{
		leaf->right = rootInsertion(word,leaf->right);
		leaf = leftRotation(leaf);
	}
	
	return leaf;
}
开发者ID:jpbat,项目名称:aed2011,代码行数:19,代码来源:F.c


示例14: main

int main()
{
    char line[BUFSIZE];
    char name[NAME]; /*name of the sale itme*/
    double uPrice, sMass; /*unit price and sold mass of the item*/
    pSALE head;
    pSALE sd;
    FILE *stream;
    /*** Read the sales data into four structures s1,s2,s3,s4 and link them together ***/
    stream = fopen("sale.dat","r");
    if(stream == NULL)
    {
        fprintf(stderr,"Error: cannot open 'sale.dat'\n");
        return NULL;
    }
    head = NULL;
    fgets(line, BUFSIZE, stream); // read a line into a buffer
    while(!feof(stream)) {
        while(line[0] == '#') {
            fgets(line,BUFSIZE,stream);
        }
        sscanf(line, "%s%lf%lf",name,&uPrice,&sMass);
        sd = createNode(name,uPrice,sMass);
        appendNode(&head, sd);
        printf("%s %lf %lf\n",sd->name, sd->unitPrice, sd->soldMass);
        fgets(line,BUFSIZE,stream);
    }
    fclose(stream);
    double maxWeight, maxDollar;
    pSALE tmp = head;
    while(tmp->next) {
        if(maxWeight < tmp->soldMass)
            maxWeight = tmp->soldMass;
        if(maxDollar < ((tmp->soldMass)*(tmp->unitPrice)))
            maxDollar = (tmp->soldMass)*(tmp->unitPrice);
        tmp = tmp->next;
    }
    printf("The largest volume in weight is %lf\n", maxWeight);
    printf("The largest volume in weight is %lf\n", maxDollar);
// clear the link list
    clearList(head);
    return 0;
}
开发者ID:caseypen,项目名称:learngit,代码行数:43,代码来源:7_15_10.c


示例15: insertBST

/* Insert data at appropriate place in BST, return new tree root. */
struct TreeNode* insertBST(struct TreeNode* root, int data)
{
	if(root == NULL)
	{
		return createNode(data);
	}
	else
	{
		if (data <= root->data)
		{
			root->left = insertBST(root->left, data);
		}
		else
		{
			root->right = insertBST(root->right, data);
		}
		return root;
	}
}
开发者ID:mhosanna,项目名称:binarytree,代码行数:20,代码来源:binarytree.c


示例16: restoreState

int restoreState (char *file) {
    char type = 0, whiteSpace = 0;
    char buff[128];
    FILE *fp = fopen(file, "r");
    
    if (fp == NULL) {
        return 0;
    }
    
    fscanf(fp, "%c", &type);
    fscanf(fp, "%s", buff);
    fscanf(fp, "%c", &whiteSpace);
    
    if ((buff[0] != '/') || (type != 'D')) {
        printf("\tReload file not in proper format.\n");
        return 0;
    }
    // Set up tree to be restored
    cwd = root;
    if (root->childPtr != NULL) {
        // Dealocate Previous tree if it exists 
        recursiveDeallocateNode(root);
        root->childPtr = NULL;
    }
    
    while (!feof(fp)) {
        fscanf(fp, "%c", &type);
        fscanf(fp, "%s", buff);
        fscanf(fp, "%c", &whiteSpace);
        if (!feof(fp)) {
            strcpy(pathname, buff);
            //pathname[strlen(pathname) + 1] = '\n';
            validateAndParsePathname();
            printf("Recovery attempt: %c %s\n", type, buff);
            createNode(type);
        } else {
            break;
        }
    }
    
    fclose(fp);
    return 1;
}
开发者ID:CHawk32,项目名称:Homework,代码行数:43,代码来源:Functions.c


示例17: main

int main(int argc, char *argv[])
{
  struct Node *head = createNode(11.0);
  
  append(head, 22.1);
  append(head, 33.2);
  append(head, 44.3);

  printList(head);
  
  insertIntoList(head, 2, 999.99);
  
  printList(head);
  
  printf("now deleting list\n");
  deleteList(head);
  
  return 0;
}
开发者ID:DawidLoubser,项目名称:reference,代码行数:19,代码来源:linkedlist.c


示例18: EQASSERT

bool LocalNode::_cmdGetNodeDataReply( Command& command )
{
    EQASSERT( _inReceiverThread( ));

    const NodeGetNodeDataReplyPacket* packet = 
        command.get< NodeGetNodeDataReplyPacket >();
    EQVERB << "cmd get node data reply: " << packet << std::endl;

    const uint32_t requestID = packet->requestID;
    const NodeID& nodeID = packet->nodeID;

    // No locking needed, only recv thread writes
    NodeHash::const_iterator i = _nodes->find( nodeID );
    if( i != _nodes->end( ))
    {
        // Requested node connected to us in the meantime
        NodePtr node = i->second;
        
        node->ref( CO_REFERENCED_PARAM );
        serveRequest( requestID, node.get( ));
        return true;
    }

    if( packet->nodeType == NODETYPE_CO_INVALID )
    {
        serveRequest( requestID, (void*)0 );
        return true;
    }

    // new node: create and add unconnected node
    NodePtr node = createNode( packet->nodeType );
    EQASSERT( node.isValid( ));

    std::string data = packet->nodeData;
    if( !node->deserialize( data ))
        EQWARN << "Failed to initialize node data" << std::endl;
    EQASSERT( data.empty( ));

    node->ref( CO_REFERENCED_PARAM );
    serveRequest( requestID, node.get( ));
    return true;
}
开发者ID:MichaelVlad,项目名称:Equalizer,代码行数:42,代码来源:localNode.cpp


示例19: buildTree

void buildTree(void) {
	buildQueue();
	printQueue();

	int lvalue,rvalue;
	if ( !head ) exit(EXIT_FAILURE);
	while ( head -> right ) {
		Node* temp = createNode();
		temp 	-> bottomleft = head;
		temp	-> bottomright = head -> right;
		head 	=  head  -> right -> right;

		temp	-> bottomleft	-> right = NULL;
		temp	-> bottomright	-> right = NULL;
		
		if ( temp -> bottomleft -> data.datatype.type == LETTER ) 
			lvalue	= characters[ temp -> bottomleft -> data.dataletter.letter ].count;
		else 	lvalue	= temp -> bottomleft -> data.datanum.num;

		if ( temp -> bottomright -> data.datatype.type == LETTER ) 
			rvalue = characters[ temp -> bottomright -> data.dataletter.letter ].count;
		else rvalue	= temp -> bottomright -> data.datanum.num;

		temp -> data.datatype.type = NUMBER;
		temp -> data.datanum.num= lvalue + rvalue;

		if ( !head ) head	= temp;
		else addToQueue( temp );
		}
	buffer	= (unsigned char*)malloc	( currsize );
	traverseTree(head,0UL);
	
	//creation of code is done.

	// tester started..
	for ( int var = 0; var <128 ;++ var ) {
		if ( characters[var].count ){
			printf("%c\t%s\n",var,characters[var].bitstring);
		//	writeBits( characters[var].bitstring );	
			}
		}
	}
开发者ID:saikiran638,项目名称:MyPrograms,代码行数:42,代码来源:tree.c


示例20: nextNode

/**
 * The exploration policy for selecting the next node
 */
treeNode* nextNode(treeNode* current, POLICY p) {
	int ret,move;
	if ((ret = _DOM->getGameStatus(current->rep))!= _DOM->incomplete) {
		return NULL;
	}
	if (current->n == 0){
		move = validMove(current);	
		rep_t newRep = _DOM->cloneRep(current->rep);
		int newSide = current->side; 
		_DOM->makeMove(newRep,&newSide, move); 
		current->children[move] = createNode(newRep,newSide,current);
		return current->children[move];
	}
	if (p == EXPLORATION){
		move = validRandomMove(current);
	} else {
		move =  selectMoveExploitation(current);
	}
	return current->children[move];
}
开发者ID:zahybnaya,项目名称:generic-best-first-bandit,代码行数:23,代码来源:brue.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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