Beispiel #1
0
inline void foreach_cell(const MAP& map, FUNC f, TraversalOptim opt)
{
	switch(opt)
	{
		case FORCE_DART_MARKING:
		{
			TraversorCell<MAP, ORBIT,FORCE_DART_MARKING> trav(map, false);
			for (Cell<ORBIT> c = trav.begin(), e = trav.end(); c.dart != e.dart; c = trav.next())
				f(c);
		}
			break;
		case FORCE_CELL_MARKING:
		{
			TraversorCell<MAP, ORBIT,FORCE_CELL_MARKING> trav(map, false);
			for (Cell<ORBIT> c = trav.begin(), e = trav.end(); c.dart != e.dart; c = trav.next())
				f(c);
		}
			break;
		case FORCE_QUICK_TRAVERSAL:
		{
			TraversorCell<MAP, ORBIT,FORCE_QUICK_TRAVERSAL> trav(map, false);
			for (Cell<ORBIT> c = trav.begin(), e = trav.end(); c.dart != e.dart; c = trav.next())
				f(c);
		}
			break;
		case AUTO:
		default:
		{
			TraversorCell<MAP, ORBIT,AUTO> trav(map, false);
			for (Cell<ORBIT> c = trav.begin(), e = trav.end(); c.dart != e.dart; c = trav.next())
				f(c);
		}
			break;
	}
}
Beispiel #2
0
int trav(int m,int n,int i,int j)
{
	if(i==m-1 || j==n-1)
		return 1;
	else
		return(trav(m,n,i+1,j)+trav(m,n,i,j+1));
	
}
Beispiel #3
0
int trav(struct node*parent)
{
	if (parent==NULL)
		return 0;
	printf("%c ",parent->n);
	trav(parent->l);
	trav(parent->r);
}
Beispiel #4
0
void trav(Node *root){
	if(root == NULL)
		return ;
	printf("%c", root->type);
	trav(root->c0);
	trav(root->c1);
	trav(root->c2);
	trav(root->c3);
}
Beispiel #5
0
 bool trav(TreeNode * root) {
     if (root == NULL) {
         return true;
     }
     bool l = trav(root->left);
     if ((long)root->val <= prev) {
         return false;
     } else {
         prev = root->val;
     }
     bool r = trav(root->right);
     return r && l; 
 }
 void ice()
 {
   auto L = [=](auto &&v) { // { dg-warning "implicit capture" "" { target c++2a } }
     push(v);
   };
   trav(L);
 }
Beispiel #7
0
int main(int argc, char **argv)
{
    int upto;
    
    if (argc < 2)
    {
        printf("usage: grep [-i] search files\n");
        return (0);
    }
    upto = 1;
    if (strcmp(argv[upto], "-i") == 0)
    {
        insensitive = 1;
        upto++;
    }
    if ((argc - upto) <= 1)
    {
        dogrep(stdin, argv[upto]);
    }
    else
    {
        search = argv[upto];
        trav(argv[upto + 1], NULL, grepfile, NULL);
    }
    return (0);
}
void TestChainTraverserComments::TestFixAnnotationChrFmt()
{
	RTFFileContext context;
	CRtfDocumentChainBuilder bld(&context);
	CChainTraverser_FixCommentStyles trav(&bld);
	
	CRTF_String string(bld.GetContext(), Detached);
	trav.FixAnnotationChrFmt(&string);
	
	CRTF_Note note(bld.GetContext(), Detached);
	trav.FixAnnotationChrFmt(&note);
	
	CRTF_ParaMarker para(bld.GetContext(), Detached);
	CRTF_CharacterProperties props(&context);
	RTFchrfmt cfmt(&context);
	
	cfmt.SetAnnotationChrfmt(asAnnotationConfirmed);
	cfmt.Flags.byBits.m_iHidden = 1;

	props.SetChrfmt(cfmt);
	para.SetCharFormat(&props);

	assertMessage(para.GetCharFormat()->GetChrfmt().GetAnnotationChrfmt()==asNone, _T("Annotation Chrfmt is always set to asNone now.  We don't write them out any more."));
	assertTest(para.GetCharFormat()->GetChrfmt().get_bHidden());

	trav.FixAnnotationChrFmt(&para);
	
	assertTest(para.GetCharFormat()->GetChrfmt().GetAnnotationChrfmt()==asNone);
	assertTest(!para.GetCharFormat()->GetChrfmt().get_bHidden());
}
void TestChainTraverserComments::TestShouldProcessItem()
{
	CRtfDocumentChainBuilder bld;

	CChainTraverser_CommentConverter trav(&bld);
	CRTF_String*  pElem = new CRTF_String(bld.GetContext(), Detached);
	assertTest(! trav.ShouldProcessItem(pElem) );

	CRTF_Note* pNote = new CRTF_Note(bld.GetContext(), Detached);
	pNote->m_Type = CRTF_Note::ntAnnotation;
	assertTest( trav.ShouldProcessItem(pNote) );

	pNote->MarkMatched();
	assertTest( trav.ShouldProcessItem(pNote));

	pNote->MarkMatched(false);
	pNote->DeleteAll();
	assertTest( trav.ShouldProcessItem(pNote));

	pNote->m_Type = CRTF_Note::ntFootnote;
	assertTest( !trav.ShouldProcessItem(pNote) );
	
	pNote->m_Type = CRTF_Note::ntEndnote;
	assertTest( !trav.ShouldProcessItem(pNote) );
	
	pNote->m_Type = CRTF_Note::ntAnnot;
	assertTest( !trav.ShouldProcessItem(pNote) );

	delete pElem;
	delete pNote;
}
Beispiel #10
0
	shared_ptr<Mapper2d> Mapper2d::
	Create(double robot_radius,
				 double buffer_zone,
				 double padding_factor,
				 shared_ptr<travmap_cost_decay const> decay,
				 const std::string & traversability_file,
				 boost::shared_ptr<travmap_grow_strategy> grow_strategy,
				 std::ostream * err_os)
	{
		ifstream trav(traversability_file.c_str());
    if( ! trav){
      if(err_os) *err_os << "ERROR in Mapper2d::Create():\n"
												 << "  invalid traversability file \""
												 << traversability_file << "\".\n";
      return shared_ptr<Mapper2d>();
    }
    shared_ptr<TraversabilityMap>
      traversability(TraversabilityMap::Parse(trav, err_os));
    if( ! traversability){
      if(err_os) *err_os << "ERROR in Mapper2d::Create():\n"
												 << "  TraversabilityMap::Parse() failed on \""
												 << traversability_file << "\".\n";
      return shared_ptr<Mapper2d>();
    }
		
		shared_ptr<Mapper2d>
			result(new Mapper2d(robot_radius, buffer_zone, padding_factor, decay,
													traversability, grow_strategy));
		return result;
	}
Beispiel #11
0
void foreach_cell_tmpl(MAP& map, FUNC func, unsigned int nbth)
{

	TraversorCell<MAP, ORBIT, OPT> trav(map);
	Cell<ORBIT> cell = trav.begin();

	std::mutex mutex_map;

	// launch threads
	std::thread** threads = new std::thread*[nbth];
	ThreadFunction<OPT,ORBIT,MAP,FUNC>** tfs = new ThreadFunction<OPT,ORBIT,MAP,FUNC>*[nbth];

	for (unsigned int i = 0; i < nbth; ++i)
	{
		std::thread::id& threadId = map.addEmptyThreadId();
		tfs[i] = new ThreadFunction<OPT,ORBIT,MAP,FUNC>(func, 1+i,threadId,mutex_map,trav,cell);
		threads[i] = new std::thread( std::ref( *(tfs[i]) ) );
	}

	// wait for all theads to be finished
	for (unsigned int i = 0; i < nbth; ++i)
	{
		threads[i]->join();
		delete threads[i];
		map.removeThreadId(tfs[i]->getThreadId());
		delete tfs[i];
	}

	delete[] tfs;
	delete[] threads;
}
Beispiel #12
0
int main(void)
{
	struct node **root;
	root=(struct node**)malloc(sizeof(struct node*));
	build(root);
	trav(*root);
	return 0;
}
Beispiel #13
0
int main()
{
	int m,n,i,j;
	scanf("%d %d",&m,&n);
	int count=trav(m,n,0,0);
	printf("%d\n",count);
	return 0;
}
Beispiel #14
0
void drawerAddVolume(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& positions,float k)
{
	typename PFP::VEC3 C = Algo::Geometry::volumeCentroid<PFP>(map,d,positions);

	Traversor3WE<typename PFP::MAP> trav(map,d);
	for (Dart e=trav.begin(); e!=trav.end(); e=trav.next())
		drawerAddEdgeShrink<PFP>(dr,map,e,positions,C,k);
}
void
QvisSubsetPanelWidget::ViewCollection(int id)
{
    avtSILRestriction_p restriction = viewerProxy->GetPlotSILRestriction();
    avtSILCollection_p collection = restriction->GetSILCollection(id);
    numCheckable = 0;
    numChecked = 0;
    tree->clear();

    if(*collection != NULL)
    {
        tree->setEnabled(true);
        blockSignals(true);
          
        SetTitle(collection->GetCategory().c_str());
        const avtSILNamespace *ns = collection->GetSubsets();
        int numElems = ns->GetNumberOfElements();

        avtSILRestrictionTraverser trav(restriction);
        for(int i = 0; i < numElems; ++i)
        {
            int setIdx = ns->GetElement(i);
            avtSILSet_p set = restriction->GetSILSet(setIdx);

            // Create an item for the set and set its checked value.
            CheckedState s = S2S(trav.UsesSetData(setIdx));
            QString cname(set->GetName().c_str());
            QvisSubsetPanelItem *item = new QvisSubsetPanelItem(tree,
                                                                cname,
                                                                s,
                                                                setIdx);
            numCheckable++;

            if(s == CompletelyChecked)
                numChecked++;
            
            // Add all of the collections that come out of the set. Note that
            // they are added as uncheckable items.
            QvisSubsetPanelItem *cItem = NULL;
            const std::vector<int> &mapsOut = set->GetMapsOut();
            for(size_t j = 0; j < mapsOut.size(); ++j)
            {
                int cIndex = mapsOut[j];

                avtSILCollection_p c = restriction->GetSILCollection(cIndex);
                QString collectionName(c->GetCategory().c_str());
                cItem = new QvisSubsetPanelItem(item,
                                                collectionName,
                                                cIndex);
            }
        }
        blockSignals(false);
    }
    EnableButtons(true);
    
    
}
void TestChainTraverserComments::TestApplyCommentStyles()
{
	CRtfDocumentChainBuilder bld;
	CChainTraverser_FixCommentStyles trav(&bld);

	CRTF_String string(bld.GetContext(), Detached);

	assertTest(!string.IsDVPComment());
	trav.ProcessItem(0,&string);
	assertTest(string.IsDVPComment());

}
Beispiel #17
0
void main()
{
 int ch;
 while(1)
 {
   clrscr();
   printf("\n1. Insertion Of The Queue");
   printf("\n2. Deletion Of Queue ");
   printf("\n3. Traversal Of The Queue");
   printf("\n0. Exit");
   printf("\n Enter Your Choice:");
   scanf("%d",&ch);
   switch(ch)
   {
	 case 1:
	 insert();                         //INSERTION FUNCTION CALLED
	 trav();
	 break;

	 case 2:
	 del();
	 trav();                           //DELETION FUNCTION CALLED
	 break;

	 case 3:
	 trav();                           //TRAVERSING FUNCTION CALLED
	 break;

	 case 0:
	 exit(0);

	 default:
	 printf("\n Wrong Choice Entered");
	 getch();
	 break;
   }
 getch();
 }
}
Beispiel #18
0
static void		print_content(t_btree *list, int flags, t_padding paddings)
{
	void		(*trav)(t_btree*, void(*)(void*));
	void		(*print_way)(void*);

	trav = flags & REV ? &btree_apply_infix_rev : &btree_apply_infix;
	print_way = flags & LONG ? &print_long : &print_name_only;
	adjust_padding(list, paddings);
	if (list)
	{
		trav(list, print_way);
		clean_all(&list);
	}
}
Beispiel #19
0
    void Filter<Scalar>::init()
    {
      // construct the union mesh, if necessary
      MeshSharedPtr meshes[H2D_MAX_COMPONENTS];
      for(int i = 0; i < this->num; i++)
        meshes[i] = this->sln[i]->get_mesh();
      this->mesh = meshes[0];
      
      Solution<Scalar>* sln = dynamic_cast<Solution<Scalar>*>(this->sln[0].get());
      if (sln == nullptr)
        this->space_type = HERMES_INVALID_SPACE;
      else
        this->space_type = sln->get_space_type();
      
      unimesh = false;

      for (int i = 1; i < num; i++)

      {
        if(meshes[i] == nullptr)
        {
          this->warn("You may be initializing a Filter with Solution that is missing a Mesh.");
          throw Hermes::Exceptions::Exception("this->meshes[%d] is nullptr in Filter<Scalar>::init().", i);
        }
        if(meshes[i]->get_seq() != this->mesh->get_seq())
        {
          unimesh = true;
          break;
        }
        
        sln = dynamic_cast<Solution<Scalar>*>(this->sln[i].get());
        if(sln == nullptr || sln->get_space_type() != this->space_type)
          this->space_type = HERMES_INVALID_SPACE;
      }

      if(unimesh)
      {
        Traverse trav(this->num);
        this->mesh = MeshSharedPtr(new Mesh);
        unidata = trav.construct_union_mesh(num, meshes, this->mesh);
        trav.finish();
      }

      // misc init
      this->num_components = 1;
      this->order = 0;

      memset(sln_sub, 0, sizeof(sln_sub));
      set_quad_2d(&g_quad_2d_std);
    }
Beispiel #20
0
main() {
  int post[SIZE];
  int pre[SIZE];
  int isFree[SIZE];
  int list;
  int free;
  list = 7;
  post[7] = 0; pre[7] = -1; isFree[7] = 0; 
  post[0] = 3; pre[0] = 7;  isFree[0] = 0;
  post[3] = 6; pre[3] = 7;  isFree[3] = 0;
  post[6] = 2; pre[6] = 3;  isFree[6] = 0;
  post[2] = 5; pre[2] = 6;  isFree[2] = 0;
  post[5] = -1; pre[5] = 2; isFree[5] = 0;
  free = 4;
  post[4] = 1; pre[4] = -1; isFree[4] = 1;
  post[1] = -1; pre[1] = 4; isFree[1] = 1;

  trav(free, post);
  trav(list, post);

  compactify(pre, post, isFree, &list, &free);
  trav(free, post);
  trav(list, post);
}
Beispiel #21
0
 void main()
 {
    node *head=NULL,*tail=NULL;
	int i,j,k;
	for(i=1;i<=5;i++)
	{
		printf("Enter Number %d ",i);
		scanf("%d",&j);
		ins(&head,j,&tail);
	}
	printf("Enter num you want to delete\n");
	scanf("%d",&k);
	del(&head,k);
	trav(head);
	getch();
 }
void main()
{
    clrscr();
    int op, a[20], n;
    cout<<"No of elements: ";
    cin>>n;
    for(int i = 0; i < n; i++)
    {
        cout<<"Element "<<i+1<<": ";
        cin>>a[i];
    }
    char ans;
    do
    {
        clrscr();
        cout<<"1.	Traversing\n";
        cout<<"2.	Adding\n";
        cout<<"3.	Deleting\n";
        cout<<"4.	Sorting\n";
        cout<<"5.	Searching\n";
        cout<<"6.	Exit\n";
        cout<<"Give your option: ";
        cin>>op;
        switch(op)
        {
        case 1:
            trav(a,n);
            break;
        case 2:
            add(a,n);
            break;
        case 3:
            del(a,n);
            break;
        case 4:
            sort(a,n);
            break;
        case 5:
            sea(a,n);
            break;
        case 6:
            exit(0);
        }
        cout<<"\n\nContinue?(y/n) ";
        cin>>ans;
    } while(ans == 'y');
}
void
QvisSubsetPanelWidget::UpdateView()
{
    avtSILRestriction_p restriction = viewerProxy->GetPlotSILRestriction();
    avtSILRestrictionTraverser trav(restriction);
    tree->blockSignals(true);
    QTreeWidgetItemIterator itr(tree);
    while(*itr)
    {
        QvisSubsetPanelItem *item = (QvisSubsetPanelItem *)*itr;
        if(item->parent() == NULL)
            item->setState(S2S(trav.UsesSetData(item->id())));
        ++itr;
    }
    tree->blockSignals(false);
    
}
void TestChainTraverserComments::TestProcessItem2()
{
	CRtfDocumentChainBuilder bld;
	CRTF_Note* pNote = new CRTF_Note(bld.GetContext(), Detached);
	pNote->m_Type = CRTF_Note::ntAnnotation;
	
	CRTF_String* pAfter = new CRTF_String(bld.GetContext(), Detached);
	pNote->SetNext(pAfter);
	
	CChainTraverser_CommentConverter trav(&bld);
	
	assertTest(trav.ProcessItem(0,pNote));
	
	assertTest(pNote->GetNext()==pAfter);
	assertTest(pNote->m_pContent==0);
	
	delete pNote;
}
Beispiel #25
0
/*static*/
bool TranslationMemoryUpdater::FindFilesInPaths(const wxArrayString& paths,
                                                wxArrayString& files,
                                                const wxString& lang)
{
    bool rv = true;
    
    files.Clear();
    TMUDirTraverser trav(&files, lang);

    for (size_t i = 0; i < paths.GetCount(); i++)
    {
        wxDir dir(paths[i]);
        if (!dir.IsOpened() || dir.Traverse(trav) == (size_t)-1) 
            // return false, but don't terminate, try other directories
            // first:
            rv = false;
    }
    return rv;
}
void
QvisSubsetPanelWidget::ViewSet(int id)
{
    avtSILRestriction_p restriction = viewerProxy->GetPlotSILRestriction();
    numCheckable = 0;
    numChecked = 0;
    tree->clear();
    tree->setEnabled(true);
    avtSILSet_p current = restriction->GetSILSet(id);
    const std::vector<int> &mapsOut = current->GetMapsOut();

    // Create a listview item with the name of the whole set.
    QString wholeName(current->GetName().c_str());
    avtSILRestrictionTraverser trav(restriction);
    
    CheckedState s = S2S(trav.UsesSetData(id));
    
    QvisSubsetPanelItem *item = new QvisSubsetPanelItem(tree, wholeName, s, id);

    numCheckable++;    
    if(s == CompletelyChecked)
        numChecked++;

    QvisSubsetPanelItem *checkItem=NULL;
    // Add all of the collections that come out of the whole.
    for(size_t j = 0; j < mapsOut.size(); ++j)
    {
        // cIndex is the j'th collection coming from out of the whole.
        int cIndex = mapsOut[j];

        // Create a new item under the whole and set its checked value.
        avtSILCollection_p collection = restriction->GetSILCollection(cIndex);
        QString collectionName(collection->GetCategory().c_str());
    
        checkItem = new QvisSubsetPanelItem(item,
                                            collectionName,
                                            cIndex);
    }

    item->setExpanded(true);
    EnableButtons(true);
}
Beispiel #27
0
int main(void)
{
	node *head = NULL;
	int n = 1, value;
	while(n)
	{
		printf("\n##1::- insert\n##2::-deletion\n##3::- traverse\n##4::- stop\n");
		scanf("%d",&n);
		switch(n)
		{
			case 1: printf("enter value::-");
				scanf("%d",&value);
				inst(&head,value);
				break;
		/*	case 2: del();
				break;*/
			case 3: trav(&head);
				break;
		}
	}
	return 0;
}
Beispiel #28
0
int main()
{
	int i,j;
while(1){
	printf("1.Add\n2.Delete\n3.Delete in middle\n4.Taverse\n0.End ");
	scanf("%d",&i);
	if(i==1)
	add();
	if(i==2)
	del();
	if(i==3)
	{
		printf("Enter serial no.");
		scanf("%d",&j);
	    mid(j);
	}
    if(i==4)
    trav();
	if(i==0)
	break;
}
}
void UpgradeMessage::convert034 ()
{
  // get all chart paths
  QStringList symbolList;
  Config config;
  QString dataPath;
  config.getData(Config::DataPath, dataPath);
  int t = dataPath.find("/data1/", 0, TRUE);
  dataPath.replace(t + 5, 1, "0");
  Traverse trav(Traverse::File);
  trav.traverse(dataPath);
  trav.getList(symbolList);

  QString s;
  config.getData(Config::IndexPath, s);
  index.open(s);
  
  int loop;
  for (loop = 0; loop < (int) symbolList.count(); loop++)
  {
    progBar->setProgress(loop, (int) symbolList.count());

    if (createDir(symbolList[loop]))
      continue;

    qDebug("Converting %s", symbolList[loop].latin1());
    if (createChart(symbolList[loop]))
      continue;
  }

  index.close();

  copyFiles();

  progBar->setProgress((int) symbolList.count(), (int) symbolList.count());

  qDebug("Conversion complete");
}
Beispiel #30
0
void EarTriangulation<PFP>::triangule()
{
//	DartMarker m(m_map);
//
//	for(Dart d = m_map.begin(); d != m_map.end(); m_map.next(d))
//	{
//		if(!m.isMarked(d))
//		{
//			Dart e = m_map.template phi<111>(d);
//			if (e!=d)
//				trianguleFace(d, m);
//		}
//	}
//	m.unmarkAll();

	TraversorF<typename PFP::MAP> trav(m_map);

	for(Dart d = trav.begin(); d != trav.end(); d = trav.next())
	{
		Dart e = m_map.template phi<111>(d);
		if (e!=d)
			trianguleFace(d);
	}
}