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


C++ InternalNode类代码示例

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


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

示例1: if

void CipherText::compute_node(element_t& v, Node* node){//v amounts to s
  if(node->getType() == LEAF){
    Leaf* leaf = (Leaf*)node;
    leaf->compute(&v, this->pub, this->p);
  //  printf("leaf: %d, %d, computed\n", leaf->getK(), leaf->getNum());

  } else if (node->getType() == INTERNAL_NODE){

    InternalNode* internalNode = (InternalNode*)node;
    int num = internalNode->getNum();
    int k = internalNode->getK();
    Node** sons = internalNode->getSons();//??

  //  printf("internal Node: %d, %d\n", k, num);

    element_t* ys = (element_t*)malloc(sizeof(element_t) *  (num + 1));      
    element_init_Zr(ys[0], *(this->p));
    element_set(ys[0], v);                          //set ys[0] to v
    computePoints(ys, k, num);       //compute other num point, 
    int i = 1;
    for (i = 1; i <= num; i++){
      compute_node(ys[i], sons[i - 1]);
    }
  }
}
开发者ID:bore1,项目名称:cpabe-dec,代码行数:25,代码来源:CipherText.cpp

示例2: processNode

 virtual void processNode(InternalNode &V) 
     {
         V.setLeftSubstMatrix(Q.instantiate(V.getLeftDistance()));
         V.setRightSubstMatrix(Q.instantiate(V.getRightDistance()));
         int id=V.getID();
         if(id>largestID) largestID=id;
         ++numNodes;
     }
开发者ID:bmajoros,项目名称:PhyLib,代码行数:8,代码来源:RCO_Felsenstein.C

示例3: getRightSibling

void InternalNode::borrowRight()
{
  InternalNode * rightSib = (InternalNode *) getRightSibling();
  insert(rightSib->children[0]); //add min value from sibling to borrower
  rightSib->removeDriver(0); //remove min value from sibling
  if(parent)
    parent->resetMinimum(rightSib);
} //InternalNode::borrowRight()
开发者ID:jkh01,项目名称:p2,代码行数:8,代码来源:InternalNode.cpp

示例4: getLeftSibling

void InternalNode::borrowLeft()
{
  InternalNode * leftSib = (InternalNode *) getLeftSibling();
  int max = leftSib->getMaximum();
  insert(leftSib->children[count-1]); //add max value from sibling to front of borrower
  leftSib->removeDriver(getPosition(max)); //remove the max value from sibling
  if(parent)
    parent->resetMinimum(this);
} //InternalNode::borrowLeft()
开发者ID:jkh01,项目名称:p2,代码行数:9,代码来源:InternalNode.cpp

示例5: printf

Policy::Policy(unsigned char* buf, pairing_t* p) {
  //get nodeNum
  int pos = 0;
  int numberOfNode = Utility::str2int(buf);
  pos += 4;

//  printf("node num is %d\n", numberOfNode);
  this->nodeNum = numberOfNode;

  //reconstruct access tree form bytes
  Node** nodes = (Node**)malloc(sizeof(Node*) * this->nodeNum);  //store all nodes
  int index = 0;
  Node* node = NULL;
  int nodeSize = 0;
  for(index = 0; index < numberOfNode; index++){
    printf("index: %d\n", index);
    //get father position
    int father = Utility::str2int(buf + pos);
    
    pos += 4;
    printf("father is %d\t", father);
    //get node size to indentify node type
    nodeSize = Utility::str2int(buf + pos);
    pos += 4;
    //printf("node size is %d\t", nodeSize);
    

    if(nodeSize == -1){
      nodeSize = INTERNAL_NODE_SIZE;
      node = new InternalNode(buf + pos);
      printf("internal node\t");
      InternalNode* t = (InternalNode*)node;
      printf("%d, %d\t", t->getK(), t->getNum());
    } else if(nodeSize == -2){
      nodeSize = LEAF_SIZE;
      node = new Leaf(buf + pos, p);
     // printf("leaf\t");
    } else {
      node = new ExLeaf((char*)(buf + pos), nodeSize);
    //  printf("ex leaf\t");
    }
    pos += nodeSize;
    nodes[index] = node;

    if(father == -1){
      this->root = node;
    } else {
      this->addSon(nodes[father],node);
    }
   // printf("add son to node %d\n", father);
  }

//  printf("reconstruct node ok\n");
  free(nodes);
}
开发者ID:bore1,项目名称:cpabe-dec,代码行数:55,代码来源:Policy.cpp

示例6: context

bool DendrogramTest::run()
{
    context("triangle.pairs");
	Graph *graph = new Graph("data/triangle.pairs");
    Dendrogram *dendro = new Dendrogram(graph);
    testcase(dendro != NULL, "Initialized Dendrogram is NULL!");
    testcase(dendro->getRoot() != NULL, "Dendrogram has NULL root");
    testcase(((InternalNode *)(dendro->getRoot()))->getLeft() != NULL, "Dendrogram root has NULL left child");
    testcase(((InternalNode *)(dendro->getRoot()))->getRight() != NULL, "Dendrogram root has NULL right child");
    
    for (NodeList::iterator iterator=dendro->nodes.begin(); iterator!=dendro->nodes.end(); iterator++) {
        DendrogramNode *node = *iterator;
        
        if (node != dendro->getRoot()) {
            test_not_equal(node->parent,NULL,"Non-root node has NULL parent");
        }
        
        if (node->type == NODE_INTERNAL) {
            InternalNode *internal = (InternalNode *)node;
            if (internal->getLeft() != NULL) {
                test_equal(internal, internal->getLeft()->parent, "Left child of X does not have X as parent");
            }
            
            if (internal->getRight() != NULL) {
                test_equal(internal, internal->getRight()->parent, "Right child of X does not have X as parent");
            }
        }
    }
    
	delete dendro;
	delete graph;
    
    context("triangle.weights");
	graph = new Graph("data/triangle.weights");
    testcase(graph->isValid(), "failed to load valid graph from data/triangle.weights");
    dendro = new Dendrogram(graph);
    testcase(dendro != NULL, "Initialized Dendrogram is NULL!");
    testcase(dendro->getRoot() != NULL, "Dendrogram has NULL root");
    for (int i=0; i<100; i++) {
        dendro->sample();
    }
    testcase(dendro->likelihood() < 0.0f, "Invalid likelihood for post-sampled dendrogram");
    graph->addNode(99);
    graph->addEdge(99,1,0.9);
    std::set<Node> nodes_ab, nodes_z;
    nodes_ab.insert(1);
    nodes_ab.insert(2);
    nodes_z.insert(99);
    testcase(graph->linksBetween(nodes_ab,nodes_z) == 0.9, "Incorrect link weight between [A,B] , [Z]");
    dendro->addLeaf(99,1);
    testcase(graph->linksBetween(nodes_ab,nodes_z) == 0.9, "Incorrect link weight between [A,B] , [Z]");
	
	return this->didPass();
}
开发者ID:doches,项目名称:hrgiew,代码行数:54,代码来源:test_dendrogram.cpp

示例7: InternalNode

void BTree::insert(const int value)
{
  BTreeNode *ptr = root->insert(value);
  if(ptr) // root split
  {
    InternalNode *IPtr = new InternalNode(internalSize, leafSize,
      NULL, NULL, NULL);
    IPtr->insert(root, ptr);
    root = IPtr;
  } // if root split
} // BTree::insert()
开发者ID:zj9205,项目名称:ECS60,代码行数:11,代码来源:BTree.cpp

示例8: while

void BTree::remove(int value)
{  // To be written by students
	root = root->remove(value);
	InternalNode* ptr = dynamic_cast<InternalNode*>(root);
	
	while(root->getCount() <= 1 && ptr != NULL) {
		if(ptr != NULL) root = ptr->getChildren()[0];
		ptr = dynamic_cast<InternalNode*>(root);
	}

} // BTree::remove()
开发者ID:zj9205,项目名称:ECS60,代码行数:11,代码来源:BTree.cpp

示例9: processNode

  virtual void processNode(InternalNode &u) {
    int id=u.getID();
    PhylogenyNode *left=u.getLeft(), *right=u.getRight();
    NthOrdSubstMatrix &leftPt=*u.getLeftSubstMatrix();
    NthOrdSubstMatrix &rightPt=*u.getRightSubstMatrix();
    Array2D<double>::RowIn2DArray<double> row=L[id];
    for(Symbol a=0 ; a<numAlpha ; ++a) {
      row[a]=
	processInternalChild(a,left,leftPt,&u)+
	processInternalChild(a,right,rightPt,&u);
    }
  }
开发者ID:bmajoros,项目名称:PhyLib,代码行数:12,代码来源:LCO_Felsenstein.C

示例10: InternalNode

void BTree::insert(const int value)
{
    //cout << "Root insert\n";
    BTreeNode *ptr = root->insert(value);
    if(ptr) //split
    {
        //cout << "[Root] Split\n";
        InternalNode *nroot = new InternalNode (internalSize, leafSize, NULL, NULL, NULL);
        nroot->insert(root,ptr);
        root = nroot;
    }
} // BTree::insert()
开发者ID:huybnguyen,项目名称:Data-Structure,代码行数:12,代码来源:BTree.cpp

示例11: InternalNode

InternalNode* InternalNode::split(BTreeNode* nodeCausingSplit)
{
  int i;

  //cout << "SPLIT : " << nodeCausingSplit << " : " << nodeCausingSplit->getMinimum() << endl;
  InternalNode* newRight = 
    new InternalNode(internalSize, leafSize, this->parent, this, this->rightSibling);

  /*(internalSize + 1) / 2 gives index of last value guaranteed to move to newRight
  ((internalSize + 1) / 2) - 1 gives the value that could go depending on if the 
  new value or the old value stored at that position in keys[] is larger */

  for (i = internalSize - 1; i >= (internalSize + 1) / 2; i--)
  {
    newRight->insert(children[i]);
    (children[i])->setParent(newRight);
  }
  
  if (nodeCausingSplit->getMinimum() > keys[((internalSize + 1) / 2) - 1] ) // given value is greater than middle position
  {
    nodeCausingSplit->setParent(newRight);
    newRight->insert(nodeCausingSplit);
    (children[i + 1])->setLeftSibling(nodeCausingSplit);
    nodeCausingSplit->setRightSibling(children[i + 1]);
    nodeCausingSplit->setLeftSibling(children[((internalSize + 1) / 2) - 1]);
    (children[((internalSize + 1) / 2) - 1])->setRightSibling(nodeCausingSplit);
  }
  else 
  {
    newRight->insert( children[((internalSize + 1) / 2) - 1] );
    (children[((internalSize + 1) / 2) - 1])->setParent(newRight);

    (children[i + 1])->setLeftSibling(children[((internalSize + 1) / 2) - 1]);
    (children[((internalSize + 1) / 2) - 1])->setRightSibling(children[i + 1]);
    (children[((internalSize + 1) / 2) - 1])->setLeftSibling(nodeCausingSplit);
    nodeCausingSplit->setRightSibling(children[((internalSize + 1) / 2) - 1]);

    children[((internalSize + 1) / 2) - 1] = nodeCausingSplit;
    keys[((internalSize + 1) / 2) - 1] = nodeCausingSplit->getMinimum();
  }
  
  /*if (internalSize % 2 == 0)*/
    count = ((internalSize + 1) / 2);
  /*else
    count = ((internalSize + 1) / 2) + 1;*/

  if (rightSibling)
    rightSibling->setLeftSibling(newRight);
  rightSibling = newRight;

  return newRight;
} // LeafNode::split()
开发者ID:arrajpur,项目名称:ecs60,代码行数:52,代码来源:InternalNode.cpp

示例12: remove

void BTree::remove(int value)
{  
  BTreeNode *ptr = root-> remove(value);
  if(ptr==root)
  {
    InternalNode *IPtr = static_cast < InternalNode * > (ptr);
    ptr = IPtr->firstChild();
    ptr->setParent(NULL);
    root = ptr;
  } 

// To be written by students
} // BTree::remove()
开发者ID:yrsun,项目名称:CollegeHWs,代码行数:13,代码来源:BTree.cpp

示例13: processNode

  virtual void processNode(InternalNode &u) 
  {
    int id=u.getID();
    Array2D<double>::RowIn2DArray<double> row=L[id];
    Taxon *taxon=static_cast<Taxon*>(u.getDecoration());
    SubstitutionMatrix &leftPt=getMatrix(*taxon,LEFT);
    SubstitutionMatrix &rightPt=getMatrix(*taxon,RIGHT);
    int left=u.getLeft()->getID(), right=u.getRight()->getID();
    for(Symbol a=0 ; a<numAlpha ; ++a)
	if(a!=gap) row[a]=
	  processInternalChild(a,left,leftPt)+
	  processInternalChild(a,right,rightPt);
  }
开发者ID:bmajoros,项目名称:alignment,代码行数:13,代码来源:ProfileFelsenstein.C

示例14: InternalNode

/*分裂内部结点,此种情况发生在原先结点的keyNum=MAX_KEY下*/
void InternalNode::splitNode(FatherNode* parentNode, int childIndex) {
	InternalNode* newNode = new InternalNode(); //分裂后的新结点
	newNode->setKeyNum(MIN_KEY);
	int i;
	for (i = 0; i < MIN_KEY; ++i) {
		newNode->setKeyValue(i, m_KeyValues[i + MIN_CHILD]);
	} //向新结点中拷贝键值
	for (i = 0; i < MIN_CHILD; ++i) {
		newNode->setChild(i, m_Childs[i + MIN_CHILD]);
	} //向新结点中拷贝指针
	setKeyNum(MIN_KEY); //更新原先结点中的键值个数
	((InternalNode*)parentNode)->insert(childIndex, childIndex + 1, m_KeyValues[MIN_KEY], newNode); //将新结点插入树中
}
开发者ID:hfr1992,项目名称:FUWA_DBMS,代码行数:14,代码来源:BPlusNode.cpp

示例15: processNode

  virtual void processNode(InternalNode &u) {
    int id=u.getID();
    Array2D<double>::RowIn2DArray<double> row=L[id];
    int left=u.getLeft()->getID(), right=u.getRight()->getID();
    NthOrdSubstMatrix &leftPt=*u.getLeftSubstMatrix();
    NthOrdSubstMatrix &rightPt=*u.getRightSubstMatrix();
    Sequence nmer;
    for(int i=0 ; i<numNmers ; ++i) {
      nmer.fromInt(i,numCols,alphabetMap);
      row[i]=
	processInternalChild(nmer,left,leftPt)+
	processInternalChild(nmer,right,rightPt);
    }
  }
开发者ID:bmajoros,项目名称:PhyLib,代码行数:14,代码来源:ACO_Felsenstein.C


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