Beispiel #1
0
int main()
{
	vector<int> k;
	for(int j = 0; j < 10; ++j)
	{
		k.push_back(j);
	}
	VectorContainer test (k);
	test.print();
	cout << test.at(3) << endl;
	cout << "should be 3" << endl;
	test.swap(0,1);
	test.print();
	test.size();
	test.insert(15);
	test.print();
	
	cout << "break" << endl;
	list <int> l;
	for(int j = 0; j < 10; ++j)
	{
		l.push_back(j);
	}
	ListContainer testlst (l);
	testlst.print();
	cout << testlst.at(3) << endl;
	cout << "should be 3" << endl;
	testlst.swap(0,1);
	testlst.print();
	testlst.size();
	testlst.insert(15);
	testlst.print();
	return 0;
}
void FixMoveMesh::get_reference_point(double *point)
{
    VectorContainer<double,3> *refpt;
    char refpt_id[200];

    sprintf(refpt_id, "REFPT_%s",id);
    refpt = mesh_->prop().getGlobalProperty<VectorContainer<double,3> >(refpt_id);

    if(!refpt)
        error->fix_error(FLERR,this,"internal error");

    if(move_->isFirst())
        mesh_->prop().resetGlobalPropToOrig(refpt_id);

    refpt->get(0,point);
    vectorCopy3D(point,reference_point_);
    
}
void FixMoveMesh::reset_reference_point()
{
    
    VectorContainer<double,3> *refpt;
    char refpt_id[200];

    sprintf(refpt_id, "REFPT_%s",id);
    refpt = mesh_->prop().getGlobalProperty<VectorContainer<double,3> >(refpt_id);

    // no error since not all moves have reference points
    if(!refpt)
        return;

    // set value for property
    refpt->set(0,reference_point_);

    // set orig value for property
    mesh_->prop().storeGlobalPropOrig(refpt_id);

}
Beispiel #4
0
int main(){
  Op* op7 = new Op(7);
  Op* op4 = new Op(4);
  Op* op3 = new Op(3);
  Op* op2 = new Op(2);
  Mult* A = new Mult(op7, op4);
  Add* B = new Add(op3, A);
  Sub* C = new Sub(B, op2);
  Sqr* D = new Sqr(C);

  VectorContainer* container = new VectorContainer();
  container->add_element(A);
  container->add_element(B);
  container->add_element(C);
  container->add_element(D);
  cout << "Container Before Sort : " << endl;
  container->print();
  cout << "Container After Sort : " << endl;
  container->set_sort_function(new SelectionSort());
  //container->set_sort_function(new BubbleSort());
  container->sort();
  container->print();



  // //double test = 7/9
  // Div* E = new Div(A, B);
  // cout << "A / B  = " << E->evaluate() << endl;
  //
  // Ceil* myCeiling = new Ceil(E);
  // Floor* myFloor = new Floor(E);
  // Op* negOne = new Op(-1);
  // Abs* myAbs = new Abs(negOne);
  // cout << myCeiling->evaluate() << endl;
  // cout << myFloor->evaluate() << endl;
  // cout << myAbs->evaluate() << endl;
  return 0;
}
Beispiel #5
0
int main() {
	//
	srand(time(NULL));
	
	//vector bubble sort
	cout << "vector bubble sort" << endl;
	VectorContainer vc;
	SortAlgorithm*  bs = new BubbleSort();
	cout << "BEFORE: ";
	vc.print();	
	vc.set_sort(bs);
	vc.sort();
	vc.print();
	cout << endl;
	
	//vector selection sort
	cout << "vector seleciton sort" << endl;
	VectorContainer vc1;
	SortAlgorithm* ss = new SelectionSort();
	cout << "BEFORE: ";
	vc1.print();
	vc1.set_sort(ss);
	vc1.sort();
	vc1.print();	

	//vector merge sort
	cout << "vector merge sort" << endl;
	VectorContainer vc2;
	SortAlgorithm* ms = new MergeSort();
	cout << "BEFORE: ";
	vc2.print();
	vc2.set_sort(ms);
	vc2.sort();
	vc2.print();
	cout << endl;

	//filled vector bubble sort
	cout << "filled vector bubble sort" << endl;
	VectorContainer vc3;
	SortAlgorithm* bs1 = new BubbleSort();
	cout << "BEFORE: ";
	vc3.randHun(20);
	vc3.print();
	vc3.set_sort(bs1);
	vc3.sort();
	vc3.print();
	cout << endl; 

	//filled vector selection sort
	cout << "filled vector selection sort" << endl;
	VectorContainer vc4;
	SortAlgorithm* ss1 = new SelectionSort();
	cout << "BEFORE: ";
	vc4.randHun(20);
	vc4.print();
	vc4.set_sort(ss1);
	vc4.sort();
	vc4.print();
	cout << endl;


	//filled vector merge sort
	cout << "filled vector merge sort" << endl;
	VectorContainer vc5;
	SortAlgorithm* ms1 = new MergeSort();
	cout << "BEFORE: ";
	vc5.randHun(20);
	vc5.print();
	vc5.set_sort(ms1);
	vc5.print();
	cout << endl;
	
	//list bubble sort
	cout << "list bubble sort" << endl;
	ListContainer lc;
	SortAlgorithm*  bs2 = new BubbleSort();
	cout << "BEFORE: ";
	lc.print();	
	lc.set_sort(bs2);
	lc.sort();
	lc.print();
	cout << endl;


	//list selection sort
	cout << "list seleciton sort" << endl;
	ListContainer lc1;
	SortAlgorithm* ss2 = new SelectionSort();
	cout << "BEFORE: ";
	lc1.print();
	lc1.set_sort(ss2);
	lc1.sort();
	lc1.print();	
	cout << endl;

	//list merge sort
	cout << "list merge sort" << endl;
	VectorContainer lc2;
	SortAlgorithm* ms2 = new MergeSort();
	cout << "BEFORE: ";
	lc2.print();
	lc2.set_sort(ms);
	lc2.sort();
	lc2.print();
	cout << endl;

	//filled list buble sort
	cout << "list bubble sort" << endl;
	ListContainer lc3;
	SortAlgorithm*  bs3 = new BubbleSort();
	cout << "BEFORE: ";
	lc3.randHun(20);
	lc3.print();	
	lc3.set_sort(bs3);
//	lc3.sort();
	lc3.print();
	cout << endl;



	//filled list selection sort
	cout << "list selection sort" << endl;
	ListContainer lc4;
	SortAlgorithm* ss3 = new SelectionSort();
	cout << "BEFORE: ";
	lc4.randHun(20);
	lc4.print();
	lc4.set_sort(ss3);
	lc4.sort();
	lc4.print();
	cout << endl;


	//filled list merge sort
	cout << "list merge sort" << endl;
	ListContainer lc5;
	SortAlgorithm* ms3 = new MergeSort();
	cout << "BEFORE: ";
	lc5.randHun(20);
	lc5.print();
	lc5.set_sort(ms3);
	lc5.sort();
	lc5.print();
	cout << endl;
	
	delete bs;
	delete ms;
	delete ss;
	delete bs1;
//	delete ms1;
//	delete ss1;
	
	return 0; 
}