Exemple #1
0
void printHelper(std::ostream & os, int indent, Node * n) {
    if (n) {
        printHelper(os, indent + 5, n->rightChild);
        os << std::setw(indent) << " " << n->val << std::endl;
        printHelper(os, indent + 5, n->leftChild);
    }
}
void BinarySearchTree::printHelper(BinaryTreeNode* node) {

	if (node == NULL) {
		return;
	}
	printHelper(node->getLeft());
	std::cout << node->getData() << " ";
	printHelper(node->getRight());
}
//---------------------------------------------------------------------------
// printHelper
// This is the helper recursive function for displaying the tree in inorder
// traversal.
void BinTree::printHelper(const Node *ptr) const {
	if(ptr == root){
        ptr->data->displayHead();
    }
    if (ptr != NULL) {
		printHelper (ptr->left);
		ptr->data->display();
		printHelper (ptr->right);
	}
}
//========================printHelper=================================
// A helper method that recursively prints the the given	
// tree in-order.
//
// Preconditions: root is not NULL.
// 		 
// Postconditions: The tree is sent to the output.
//==================================================================== 
void BSTree::printHelper (ostream &output, const Node *root) const
{
	if (root != NULL) {
		printHelper (output, root->left);
		output << *root->item 
		       << " "
		       << root->occurances 
	  	       << endl;
		printHelper (output, root->right);
	}
}
Exemple #5
0
//------------------------------------------------------------------------------
// printHelper
// Recursive helper function for printing the current object.
void SymbolTable::printHelper(Scope *rhs) {
	// Make sure rhs is not NULL.
	if(rhs != NULL) {
		// Output scope entry line.
		ProcFunc *func = dynamic_cast<ProcFunc*>(rhs);
		for(int i = 0; i < 75; i++) {
			cout << '-';
		}
		cout << endl << "enter " << func->name << endl;

		// Display the current scope's symbols.
		rhs->idents.display(rhs->level);

		// Call printHelper for all the current scope's children.
		Scope *current = rhs->child;
		while(current != NULL) {
			printHelper(current);
			current = current->next;
		}

		// Output scope exit line.
		for(int i = 0; i < 75; i++) {
			cout << '*';
		}
		cout << endl << "exit " << func->name << endl << endl;
	}
}
Exemple #6
0
// O(n*w)
void printHelper(const Aho_Corasick::Node *n)
{
    printf("[0x%lX] : {", (unsigned long)n);
    if (!n) return;

    for (auto child = n->matchPath.begin(); child != n->matchPath.end(); child++)
    {
        if (child == n->matchPath.begin())
        {
            printf("(%c, 0x%lX)", child->first, (unsigned long)child->second);
        } else
        {
            printf(" | (%c, 0x%lX)", child->first, (unsigned long)child->second);
        }
    }
    printf("} FAIL: 0x%lX\n", (unsigned long)n->failPath);

    for (auto child=n->matchPath.begin(); child != n->matchPath.end(); child++)
    {
        printHelper(child->second);
    }
}
void printHelper(node *root)
{
	list<node*>::iterator itr;
	
	for(itr=root->childList.begin();itr != root->childList.end();itr++)
	{
		cout<<(*itr)->name<<"--";
		if((*itr)->store.size()!=0)
		{
			list<node*>::iterator itr1;
			for(itr1=(*itr)->store.begin();itr1!=(*itr)->store.end();itr1++)
			{
				cout<<(*itr1)->name<<","<<(*itr1)->address<<","<<(*itr1)->count<<endl;
			}
		}
		
		if((*itr)->childList.size()!=0)
		{
			printHelper(*itr);
		}
		
	//	cout<<endl;
	}
}
void tries::print()
{
	cout<<"********************PRINT***************"<<endl;
	printHelper(root);
}
void BinarySearchTree::print() {
	printHelper(root);
	std::cout<<std::endl;
}
Exemple #10
0
//------------------------------------------------------------------------------
// printST
// Function for printing the current object.
void SymbolTable::printST() {
	printHelper(root);
}
Exemple #11
0
std::ostream & operator<<(std::ostream & os, const BinarySearchTree & bst) {
    printHelper(os, 0, bst.root);
    return os;
}
Exemple #12
0
// O(n*w)
void Aho_Corasick::Trie::print(void)
{
    printf("ROOT:");
    printHelper(root);
}
void GVBrowserExtension::print()
{
    Document::Ptr doc = DocumentFactory::instance()->load(d->mPart->url());
    PrintHelper printHelper(d->mPart->widget());
    printHelper.print(doc);
}