int main() { inv_index<3,0> *index1; int att_values[3]; int return_value; return_value = 0; index1 = new inv_index<3,0>; att_values[0] = 3; att_values[1] = 4; att_values[2] = 5; insert_val(att_values, index1); return_value = search_val(&(att_values[0]), index1); if (return_value == 1) { cout<<"values found"<<" "<<return_value<<endl; } else { cout<<"values not found"<<" "<<return_value<<endl; } }
void unify_var(char var[],char x[]) {char val[100],a[100]; i=0; sprintf(a,"%s/",var); while(i<strlen(theta)) { strcpy(val,search_val(a,i)); if(strlen(val)>0) unify(val,x); i=i+strlen(a)-1; } i=0; sprintf(a,"%s/",x); while(i<strlen(theta)) { strcpy(val,search_val(a,i)); if(strlen(val)>0) unify(var,val); i=i+strlen(a)-1; } sprintf(val,"%s/%s;",var,x); if(ispresent(val)) return; sprintf(theta+strlen(theta)-1," %s",val); }
// Function to access a value on Cache void MappingSimulator::access(std::string _val) { m_access_cnt++; unsigned pos; double miss_rate = static_cast<double>(m_miss_cnt)/m_access_cnt; if (search_val(m_current_map, _val, pos) == -1) { m_miss_cnt++; miss_rate = static_cast<double>(m_miss_cnt)/m_access_cnt; std::cout << "[Miss] - Miss rate: " << miss_rate * 100 << '%' << std::endl; // Add element to cache m_cache.setValue(pos, _val); // If the current miss rate pass the limit, switch the associativity if (miss_rate > m_max_miss_rate) m_current_map++, m_miss_cnt = 0, m_access_cnt = 0; return; } std::cout << "[Hit] - Miss rate: " << miss_rate * 100 << '%' << std::endl; }
int main() { int att_array[3]; int i = 0; TransactionManager transact_val1; dct_tree *tree_val = NULL; dct_tree *tree_val2 = NULL; dct_tree *tree_val3 = NULL; dct_node *temp = NULL; tree_val = build_dcttree(3); tree_val3 = build_dcttree(3); att_array[0] = 1; att_array[1] = 2; att_array[2] = 3; try { insert_val(att_array, tree_val, transact_val1); insert_val(att_array, tree_val3, transact_val1); //throw -1; transact_val1.commit_transaction(); tree_val2 = copy_val((tree_val->getdummy()), (tree_val->getnumber_of_nodes())); }catch (int e) { cout<<"exception caught"<<" "<<e<<endl; return 1; } //att_array[2] = 3; if (search_val(att_array, tree_val)) { cout<<"All values found"<<endl; } else { cout<<"All values not found"<<endl; } temp = search_val(att_array, tree_val2); if (temp != NULL) { cout<<" All values found copy tree"<<endl; } else { cout<<"All values not found copy tree"<<endl; } if (search_val(att_array, tree_val3)) { cout<<"All values found3"<<endl; } else { cout<<"All values not found3"<<endl; } delete tree_val; delete tree_val2; delete tree_val3; delete temp; }