const BoostInfoTree& BoostInfoTree::createSubtree(const string& treeName, const string& value) { ptr_lib::shared_ptr<BoostInfoTree> newTree(new BoostInfoTree(value, this)); addSubtree(treeName, newTree); return *newTree; }
void KisImageLayerRemoveCommand::addSubtree(KisImageWSP image, KisNodeSP node) { // Simple tail-recursion to remove nodes in bottom-up way // // Alert: the nodes must be traversed in last-to-first order, // because each KisImageLayerRemoveCommandImpl stores a // pointer to the previous node of the stack KisNodeSP child = node->lastChild(); while (child) { addSubtree(image, child); child = child->prevSibling(); } new KisImageLayerRemoveCommandImpl(image, node, this); }
/** * Inserts @a a_subtree as a last subtree. */ void insertRight(zsyntree* a_subtree) { addSubtree(a_subtree); }
KisImageLayerRemoveCommand::KisImageLayerRemoveCommand(KisImageWSP image, KisNodeSP node) : KisImageCommand(kundo2_i18n("Remove Layer"), image), m_node(node) { addSubtree(image, node); }
int main() { int i, j, k, l; // Iterators int valuesize; char strInput[LENGTH]; // Buffer for scanning string inputs int values[LENGTH][LENGTH]; // 2D Array to contain integer value equivalents int nattributes; // Number of attributes int nchoices; // Number of choices per attribute int nvalues; // Number of values in test data FILE * file; FILE * file2; att test; tree decisionTree; init(&test); initTree(&decisionTree); init(&glob); attnode * node; /* Format of input.txt: Outlook // 1st Attribute 3 // Number of values for 1st attribute Sunny // 1st value of 1st attribute Overcast // 2nd value of 1st attribute Rain // 3rd value of 1st attribute Temperature // 2nd Attribute 3 // Number of values for 2nd attribute Hot // 1st value of 2nd attribute Mild // 2nd value of 2nd attribute Cool // 3rd value of 2nd attribute */ file=fopen("joinorg.txt", "r"); if(file==NULL) { printf("Missing or empty file.\n"); return 0; } fscanf(file, "%d\n", &nattributes); valuesize=1; j=-1; for(k=0; k<nattributes; k++) { fgets(strInput, LENGTH, file); removeNewline(strInput); addNode(&test, strInput, 0, k, j); j--; fscanf(file, "%d\n", &nchoices); for(i=0; i<nchoices; i++) { fgets(strInput, LENGTH, file); removeNewline(strInput); addNode(&test, strInput, i+1, k, valuesize); valuesize++; } } showList(&test); /* Format of inputvalues.txt: 5 // Number of values Sunny Hot High Light No // 1st input value Sunny Hot High Strong No // 2nd input value Overcast Hot High Light Yes // 3rd input value Rain Mild High Light Yes // 4th input value Rain Cool Normal Light Yes // 5th input value */ file2=fopen("inputsurvey.txt", "r"); if(file==NULL) { printf("Missing or empty file.\n"); return 0; } fscanf(file2, "%d\n", &nvalues); attnode * curr; for(i=0; i<nvalues; i++) { for(j=0; j<nattributes; j++) { fscanf(file2, "%s ", strInput); curr=test.head; while(curr!=NULL) { if(strcmp(strInput, curr->attname)==0) { //printf("%s ", curr->attname); values[i][j]=curr->equivalent; break; } curr=curr->next; } } //printf("\n"); } printf("\n"); /*for(i=0; i<nvalues; i++) { for(j=0; j<nattributes; j++) { printf("%d ", values[i][j]); } printf("\n"); }*/ addSubtree(0, values, nvalues, nattributes, &test, &decisionTree); node=glob.head; while(node!=NULL){ addSubtree(node->equivalent, values, nvalues, nattributes, &test, &decisionTree); node=node->globnext; } node=glob.head; while(node!=NULL){ printf("\n%s pos: %d, neg: %d\n", node->attname, node->positivetracker, node->negativetracker); node=node->globnext; } updatePosNeg(1, 8, values, nvalues, nattributes, &test); updatePosNeg(2, 8, values, nvalues, nattributes, &test); updatePosNeg(3, 8, values, nvalues, nattributes, &test); }