本文整理汇总了C++中NewNode函数的典型用法代码示例。如果您正苦于以下问题:C++ NewNode函数的具体用法?C++ NewNode怎么用?C++ NewNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewNode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: NewNode
//------------------------------------------------------------------------------
// Create a star tree with n leaves
void NTree::StarTree (int n)
{
Leaves = n;
Internals = 1;
Root = NewNode();
Root->SetWeight (n);
Root->SetDegree (n);
CurNode = NewNode();
CurNode->SetLeaf(true);
CurNode->SetLeafNumber(1);
CurNode->SetLabelNumber(1);
Root->SetChild (CurNode);
CurNode->SetAnc (Root);
// Remaining leaves
for (int i = 1; i < n; i++)
{
NodePtr q = NewNode ();
q->SetLeaf(true);
q->SetLeafNumber(i+1);
q->SetLabelNumber(i+1);
q->SetAnc (Root);
CurNode->SetSibling (q);;
CurNode = q;
}
MakeNodeList();
Update();
BuildLeafClusters ();
}
开发者ID:goshng,项目名称:treeviewx,代码行数:36,代码来源:ntree.cpp
示例2: NewNode
bool StudentTree::Insert(unsigned int id, char* fullname, unsigned int flags, bool reorder)
{
if ((int)id <= 0 || Exists(id))
return false;
if(!ValidFullname(fullname))
return false;
tempData = (TREE_NODE_DATA*)malloc(sizeof(TREE_NODE_DATA));
tempData->id = id;
tempData->fullname = fullname;
tempData->flags = flags;
tempData->bstId = tempData->bstName = 0;
tempNode = NewNode(tempData);
InsertSortedId(&(bstId->root), tempNode);
tempNode = NewNode(tempData);
InsertSortedName(&(bstName->root), tempNode);
if (reorder)
SetMode(treeMode);
return true;
}
开发者ID:AnwarMohamed,项目名称:StudentBook,代码行数:25,代码来源:studenttree.cpp
示例3: InsertIterative
NODE * InsertIterative (NODE * root ,int data )
{
if(root==NULL )
{
return(NewNode(data));
}
NODE * ptr =root ;
NODE * save =NULL;
NODE * newInsert=NewNode(data);
while(ptr!=NULL)
{
if(ptr->data > data )
{
save =ptr;
ptr=ptr->left;
}
else
{
save =ptr;
ptr=ptr->right;
}
}
if(save->data > data)
{
save->left=newInsert;
}
else
{
save->right=newInsert;
}
return root ;
}
开发者ID:mukeshdewangan,项目名称:ExperimentPrograms,代码行数:33,代码来源:tree+path.cpp
示例4: build123b
// b: by calling newNode() three times, and using only one pointer variable
struct node* build123b()
{
struct node* root = NewNode(2);
root->left = NewNode(1);
root->right = NewNode(3);
return root;
}
开发者ID:syamgk,项目名称:Data_Structures,代码行数:8,代码来源:printPaths.c
示例5: Init
void Init()
{
num[0]=0;
val[0]=0;
NewNode(size=0,rt,0);
NewNode(rt,son[rt][1],0);
makeTree(0,n-1,keyTree,son[rt][1]);
Update(son[rt][1]);
Update(rt);
}
开发者ID:LinKin-22,项目名称:acm-algorithm,代码行数:10,代码来源:1166+2013-03-25+10+53+01.cpp
示例6: buildBSTree
struct node* buildBSTree() {
struct node* root = NewNode(4);
root->left = NewNode(2);
root->left->right = NewNode(3);
root->left->left = NewNode(1);
root->right = NewNode(5);
return root;
}
开发者ID:imwally,项目名称:cmuck,代码行数:10,代码来源:problem06.c
示例7: Init
void Init()
{
for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
root = 0;
rear = head = 0;
f[root] = Node(0, 0, 0, 0, 0, 0, 0);
NewNode(root, 0, -1);
NewNode(f[root].ch[1], root, -1);
Build(Key_value, 1, n, f[root].ch[1]);
}
开发者ID:keroro520,项目名称:ACM,代码行数:10,代码来源:splay_tree.cpp
示例8: build123_a
struct node* build123_a() {
struct node* node1 = NewNode(1);
struct node* node2 = NewNode(2);
struct node* node3 = NewNode(3);
node2->left = node1;
node2->right = node3;
return node2;
}
开发者ID:boyvanduuren,项目名称:cslibrary,代码行数:10,代码来源:binarytrees.c
示例9: build12345
// a: by calling newNode() three times, and using three pointer variables
struct node* build12345()
{
struct node* root = NewNode(4);
struct node* left = NewNode(2);
struct node* right = NewNode(5);
root->left = left;
root->right = right;
root->left->left = NewNode(1);
root->left->right = NewNode(3);
return root; // <<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>
}
开发者ID:syamgk,项目名称:Data_Structures,代码行数:12,代码来源:printPaths.c
示例10: memset
List *InitList()
{
List *L;
L = (List *)malloc(sizeof(List));
memset(L,0,sizeof(List));
L->size = 0;
L->header = NewNode(0,NULL);
L->trailer = NewNode(0,NULL);
L->header->Next = L->trailer;
return L;
}
开发者ID:ctxrr,项目名称:myDataStruct,代码行数:12,代码来源:LinkedList.c
示例11: main
int main()
{
struct edges *Node=NULL;
char ch;
int i,j,weight;
scanf("%d %d",&n,&m);
if(n<=0||n>=200000)
exit(EXIT_FAILURE);
if(m<=0||m>=200000)
exit(EXIT_FAILURE);
struct node *start[n];
struct edges *ptr[n];
for(i=0;i<n;i++)
{
start[i]=NULL;
ptr[i]=NULL;
}
int k;
for(k=0;k<m;k++)
{
scanf("%d %d %d",&i,&j,&weight);
if(i<=0||i>=200000)
exit(EXIT_FAILURE);
if(j<=0||j>=200000)
exit(EXIT_FAILURE);
Node=NewNode();
if(start[i]==NULL)
start[i]=(struct node*)Node;
else
ptr[i]->next=Node;
Node->vertex=j;
Node->weight=weight;
ptr[i]=Node;
Node=NewNode();
if(start[j]==NULL)
start[j]=(struct node*)Node;
else
ptr[j]->next=Node;
Node->vertex=i;
Node->weight=weight;
ptr[j]=Node;
}
for(i=0;i<n;i++)
{
printf("%d ->",i);
PrintList((struct edges*)start[i]);
}
return 0;
}
开发者ID:prabaprakash,项目名称:Data-Structures-and-Algorithms-Programs,代码行数:53,代码来源:Adjacency+List.c
示例12: GetInstChain
static void GetInstChain(RSTREE R,
typrect newrect,
int depth)
{
int i;
refcount c;
i= 1;
while (i < depth) {
if ((*R).NInst[i+1] != NULL) {
/* already in path */
(*R).E[i]= (*R).EInst[i]; (*R).EInst[i]= -1;
i++;
if ((*R).N[i] != (*R).NInst[i]) {
(*R).P[i]= (*(*R).N[i-1]).DIR.entries[(*R).E[i-1]].ptrtosub;
free((*R).N[i]); (*R).N[i]= NULL;
(*R).N[i]= (*R).NInst[i];
}
(*R).NInst[i]= NULL;
}
else if ((*R).EInst[i] != -1) {
/* known ... */
(*R).E[i]= (*R).EInst[i]; (*R).EInst[i]= -1;
i++;
if ((*(*R).N[i-1]).DIR.entries[(*R).E[i-1]].ptrtosub != (*R).P[i]) {
/* but not in path */
NewNode(R,i);
}
}
else {
/* not known */
ChooseSubtree(R,newrect,i,&(*(*R).N[i]).DIR,&(*R).E[i]);
i++;
if ((*(*R).N[i-1]).DIR.entries[(*R).E[i-1]].ptrtosub != (*R).P[i]) {
/* and not in path */
NewNode(R,i);
}
}
}
c= &(*R).count;
if ((*c).countflag) {
if (depth == (*R).parameters._.height) {
(*c).dirvisitcount+= depth - 1;
(*c).datavisitcount++;
}
else {
(*c).dirvisitcount+= depth;
}
}
}
开发者ID:Exteris,项目名称:Gerris,代码行数:52,代码来源:RSTInstDel.c
示例13: NewNode
RedBlackTree::RedBlackTree(int nRootKey /*= -1*/)
{
m_pNull = NewNode(-2, black);
if (nRootKey != -1)
{
m_pRoot = NewNode(nRootKey, black);
}
else
{
m_pRoot = nullptr;
}
}
开发者ID:kinnylee,项目名称:Project,代码行数:13,代码来源:RedBlackTree.cpp
示例14: Init
void Init()
{
root = tot1 = tot2 = 0;
ch[root][0] = ch[root][1] = size[root] = pre[root] = 0;
same[root] = rev[root] = sum[root] = key[root] = 0;
lx[root] = rx[root] = mx[root] = -INF;
NewNode(root,0,-1);
NewNode(ch[root][1],root,-1);
for(int i = 0;i < n;i++)
scanf("%d",&a[i]);
Build(Key_value,0,n-1,ch[root][1]);
push_up(ch[root][1]);
push_up(root);
}
开发者ID:ChouUn,项目名称:chouun.github.io,代码行数:14,代码来源:splay.cpp
示例15: ProjectVals
node_idx Forest::ProjectVals(level k, node_idx p, level cutoff)
{
Node *nodeP;
node_idx result;
node_idx flag;
//Check Base Cases
if (p == 0)
return 0;
if (k == 0)
return 1;
//Check Cache
result = ProjectCache[k]->hit(p);
if (result >= 0) {
return result;
}
nodeP = &FDDL_NODE(k, p);
if (k < cutoff) {
flag = 0;
for (node_idx i = 0; i < nodeP->size; i++) {
flag = ProjectVals(k - 1, FDDL_ARC(k, nodeP, i), cutoff);
if (flag != 0)
break;
}
if (flag != 0) {
result = NewNode(k);
for (node_idx i = 0; i <= maxVals[k]; i++) {
SetArc(k, result, i, flag);
}
result = CheckIn(k, result);
ProjectCache[k]->add(result, p);
return result;
}
} else {
result = NewNode(k);
for (node_idx i = 0; i < nodeP->size; i++) {
SetArc(k, result, i,
ProjectVals(k - 1, FDDL_ARC(k, nodeP, i), cutoff));
}
result = CheckIn(k, result);
ProjectCache[k]->add(result, p);
return result;
}
return 0;
}
开发者ID:eldarerathis,项目名称:FDDL,代码行数:49,代码来源:mdd.cpp
示例16: Projection
node_idx Forest::Projection(level k, node_idx p, level * mask)
{
Node *nodeP;
node_idx result;
node_idx flag;
node_idx u;
//Check Base Cases
if (p == 0)
return 0;
if (k == 0)
return 1;
//Check Cache
result = ProjectCache[k]->hit(p);
if (result >= 0) {
return result;
}
nodeP = &FDDL_NODE(k, p);
if (mask[k] == 0) {
flag = 0;
for (node_idx i = 0; i < nodeP->size; i++) {
u = Projection(k - 1, FDDL_ARC(k, nodeP, i), mask);
flag = InternalMax(k - 1, u, flag);
}
if (flag != 0) {
result = NewNode(k);
for (node_idx i = 0; i <= maxVals[k]; i++) {
SetArc(k, result, i, flag);
}
result = CheckIn(k, result);
ProjectCache[k]->add(result, p);
return result;
}
} else {
result = NewNode(k);
for (node_idx i = 0; i < nodeP->size; i++) {
SetArc(k, result, i,
Projection(k - 1, FDDL_ARC(k, nodeP, i), mask));
}
result = CheckIn(k, result);
ProjectCache[k]->add(result, p);
return result;
}
return 0;
}
开发者ID:eldarerathis,项目名称:FDDL,代码行数:49,代码来源:mdd.cpp
示例17: Insert
void Insert(struct HNode* root,int data){
if(root->next==NULL){
root->next=NewNode(data);
}
else{
struct LNode* tmpNode=root->next;
while(tmpNode->next){
tmpNode=tmpNode->next;
}
tmpNode->next=NewNode(data);
}
root->count++;
}
开发者ID:sidpka,项目名称:repo,代码行数:15,代码来源:GroupReverse.C
示例18: main
int main()
{
struct node *Node=NULL, *ptr=NULL;
struct node *start=NULL,*start1=NULL,*start2=NULL;
char ch;
do
{
ptr=Node;
Node=NewNode();
printf("\nEnter data :");
scanf("%d",&Node->data);
if(start1==NULL)
start1=Node;
else
ptr->next=Node;
printf("Do you want to continue(Y/N)");
}while(toupper((ch=getch()))!='N');
printf("\nComplete Linked list:\n");
PrintList(start1);
do
{
ptr=Node;
Node=NewNode();
printf("\nEnter data :");
scanf("%d",&Node->data);
if(start2==NULL)
start2=Node;
else
ptr->next=Node;
printf("Do you want to continue(Y/N)");
}while(toupper((ch=getch()))!='N');
printf("\nComplete Linked list:\n");
PrintList(start2);
start=SortedMerge(start1,start2);
printf("\n\nMerged Linked list:\n");
PrintList(start);
return 0;
}
开发者ID:prabaprakash,项目名称:Data-Structures-and-Algorithms-Programs,代码行数:48,代码来源:Linked+List+-+SortedMerge+(using+Dummy+Node).c
示例19: ShrinkTree
static void ShrinkTree(RSTREE R)
{
refparameters par;
refcount c;
int i;
par= &(*R).parameters._;
if ((*R).P[2] == 0) {
(*R).E[1]= 0;
NewNode(R,2);
}
free((*R).N[1]);
for (i= 1; i <= (*par).height; i++) {
(*R).N[i]= (*R).N[i+1];
}
(*R).Nmodified[1]= TRUE;
c= &(*R).count;
if ((*c).countflag) {
(*c).dirmodifycount++;
}
PutPageNr(R,(*R).P[2],2);
for (i= 2; i <= (*par).height; i++) {
(*R).P[i]= (*R).P[i+1];
(*R).Nmodified[i]= (*R).Nmodified[i+1];
(*par).pagecountarr[i]= (*par).pagecountarr[i+1];
}
(*R).E[(*par).height]= -1;
(*par).height--;
}
开发者ID:Exteris,项目名称:Gerris,代码行数:33,代码来源:RSTInstDel.c
示例20: ASSERT_VALID
POSITION CPtrList::InsertAfter(POSITION position, void* newElement)
{
ASSERT_VALID(this);
if (position == NULL)
return AddTail(newElement); // insert after nothing -> tail of the list
// Insert it before position
CNode* pOldNode = (CNode*) position;
ASSERT(AfxIsValidAddress(pOldNode, sizeof(CNode)));
CNode* pNewNode = NewNode(pOldNode, pOldNode->pNext);
pNewNode->data = newElement;
if (pOldNode->pNext != NULL)
{
ASSERT(AfxIsValidAddress(pOldNode->pNext, sizeof(CNode)));
pOldNode->pNext->pPrev = pNewNode;
}
else
{
ASSERT(pOldNode == m_pNodeTail);
m_pNodeTail = pNewNode;
}
pOldNode->pNext = pNewNode;
return (POSITION) pNewNode;
}
开发者ID:jbeaurain,项目名称:omaha_vs2010,代码行数:28,代码来源:list_p.cpp
注:本文中的NewNode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论