void test_Traverse(void) {
	Status status = ERROR;
	GENERALIZED_LIST_TYPE list = list = getGeneralizedList(
			"((11,12,13),(21,22,23,24,25),3,(4,(51,52,53,(501,502))))");
	if (list == NULL)
		return;

	status = Traverse(&list, &visit);
	CU_ASSERT_EQUAL(status, OK);
	assertEqual(list,
			"((12,13,14),(22,23,24,25,26),4,(5,(52,53,54,(502,503))))");
}
Exemplo n.º 2
0
int films3(void)
{
    List movies;
    Item temp;


/* initialize       */
    InitializeList(&movies);
    if (ListIsFull(&movies))
    {
        fprintf(stderr,"No memory available! Bye!\n");
        exit(1);
    }
    
/* gather and store */
    puts("Enter first movie title:");
    while (gets(temp.title) != NULL && temp.title[0] != '\0')
    {
        puts("Enter your rating <0-10>:");
        scanf("%d", &temp.rating);
        while(getchar() != '\n')
            continue;
        if (AddItem(temp, &movies)==false)
        {
            fprintf(stderr,"Problem allocating memory\n");
            break;
        }
        if (ListIsFull(&movies))
        {
            puts("The list is now full.");
            break;
        }
        puts("Enter next movie title (empty line to stop):");
    }
   
/* display          */
    if (ListIsEmpty(&movies))
        printf("No data entered. ");
    else
    {
        printf ("Here is the movie list:\n");
        Traverse(&movies, showmovies);
    }
    printf("You entered %d movies.\n", ListItemCount(&movies));


/* clean up         */
    EmptyTheList(&movies);
    printf("Bye!\n");
   
    return 0;
}
Exemplo n.º 3
0
int main()
{
	SearchTree T = NULL;

	T = MakeRandomTree( T, 0, 10 );

	Traverse( T );
	printf("\n");

	TraverseInOrder( T );
	printf("\n");

}
Exemplo n.º 4
0
//显示列表内容
void show(List * plist)
{
	if (ListIsEmpty(plist))
	{
		puts("No data!");
	}
	else
	{
		printf("Here is the car's information:\n");
		Traverse(plist, showList);
	}
	printf("There is %d car in your list.\n", ListItemCount(plist));
}
Exemplo n.º 5
0
int HaploTree::Traverse(IntArray & pointer, IntArray & state, double minfreq) const
   {
   while (true)
      {
      int result = Traverse(pointer, state);

      if (result == -1)
         return -1;

      if (freqs[result] > minfreq)
         return result;
      }
   }
int main()
{
	LinkList l;
	CreateList(l, 10);
	Traverse(l, print);
	ElemType e;
	if(Delete(l,1,e)){
		printf("删除第个1元素后:\n");
		Traverse(l,print);
	}
	if(Insert(l,1,-55)){
		printf("在第1个位置插入-55之后:\n");
		Traverse(l,print);
	}
	printf("\n");	
	LinkList l2,l3;
	CreateList(l2,5);
	Traverse(l2,print);
	CreateList(l3,0);
/*	if(Merge(l,l2,l3)){
		printf("归并l,l2为:\n");
		Traverse(l3,print);
	}
	if(Intersect(l,l2,l3)){
		printf("l,l2取交集为:\n");
		Traverse(l3,print);
	}
	if(Unite(l,l2,l3)){
		printf("l,l2取并集为:\n");
		Traverse(l3,print);
	}
*/	
	if(Differ(l,l2,l3)){
		printf("l,l2取差集(l-l2)为:\n");
		Traverse(l3,print);
	}
	return 0;
}
Exemplo n.º 7
0
Arquivo: pe17-3.cpp Projeto: jnksu/CPP
int main(int argc, char ** argv)
{
	List movies;
	Item temp;

	/* 初始化 */
	InitializeList(&movies);
	if (ListIsFull(&movies)){
		fprintf(stderr, "No memory available! Bye!\n");
		exit(EXIT_FAILURE);
	}
	/* 收集并存储 */
	fputs("Enter first movie title: \n", stdout);
	while (fgets(temp.title, TSIZE, stdin) != NULL && temp.title[0] != '\n'){
		reject_ch(temp.title, '\n');

		fputs("Enter your rating<0-10>: \n", stdout);
		scanf_s("%d", &temp.rating);
		while (getchar() != '\n'){
			continue;
		}

		if (false == AddItem(&temp, &movies)){
			fprintf(stderr, "Problem allocating memory\n");
			exit(EXIT_FAILURE);
		}

		if (ListIsFull(&movies)){
			fputs("The list is now full.\n", stdout);
			break;
		}
		fputs("Enter next movie title(empty line to stop): \n", stdout);
	}

	/* 显示 */
	if (ListIsEmpty(&movies))
		printf("No data entered.");
	else{
		printf("Here is the movie list: \n");
		Traverse(&movies, showMovies);
	}
	printf("You entered %d movies.\n", ListItemCount(&movies));

	/* 清除 */
	EmptyTheList(&movies);
	printf("Bye!\n");

	_CrtDumpMemoryLeaks();
	return EXIT_SUCCESS;
}
Exemplo n.º 8
0
int main() {
  SqQueue *q, qq;
  Init(q = &qq);
  Traverse(q, ev);
  printf("CMD e/d/q:\n$ ");
  char c[STRLEN];
  int x;
  while (fgets(c, STRLEN, stdin) != NULL) {
    if (c[0] == 'q') {                  // quit
      break;
    } else if (c[0] == 'e') {           // enqueue
      sscanf(c, "e %d", &x);
      printf("enqueue: %d\n", x);
      EnQueue(q, x);
      Traverse(q, ev);
    } else if (c[0] == 'd') {           // dequeue
      printf("dequeue: %d\n", DeQueue(q));
      Traverse(q, ev);
    }
    printf("$ ");
  }
  return 0;
}
Exemplo n.º 9
0
Arquivo: tree.c Projeto: jainsahab/DSA
TreeNode* Traverse(List *list, void* parentData,int (*compare)(void*,void*)){
	TreeNode* temp;
	Iterator it = getIterator(list);
	while(it.hasNext(&it)){
		temp = it.next(&it);
		if (1 == compare(temp->data,parentData)){
			return temp;
		}
		if(NULL != temp->children->head){
			return Traverse(temp->children, parentData, compare);
		}
	}
	return NULL;
}
Exemplo n.º 10
0
int main(void)
{
    List list;
    InitializeList(&list); // test Initialize

    if(ListIsEmpty(&list)) //test ListIsEmpty
        printf("the list is empty\n");
    else
        printf("the list is not empty\n");
    
//    unsigned int counter=0;
//    counter=ListItemCount(&list);

    Node* pnode;

    pnode=(Node*)malloc(sizeof(Node));
    
    Item *pitem;

    pitem=(Item*)malloc(sizeof(Item));

    pitem->ID=001;
    strcpy(pitem->content, "hello list");
    pitem->value=1;
    
    pnode->item=*pitem;

    list=pnode;

    list=AddNew(list);    //test AddNew

    unsigned int counter=0;
    counter=ListItemCount(&list);
    printf("there are %u items in the list\n", counter);
    
//    void (*pfun)(Item item)=showitem;

    Traverse(&list,showitem);    //test Traverse
    
//    EmptyTheList(&list);d
    if(ListIsEmpty(&list))
        printf("list is empty!\n");
    else 
        printf("list is not empty!\n");

    EmptyTheList(&list);

    return 0;
}
Exemplo n.º 11
0
int CDistanceFuncGridModel<T>::PointInside(const CBoundingVolumeNode3<AABB3<T>,T,CTraits> *pNode, const Vector3<T> &vQuery)
{
  //needed world transformed triangles, world transformed BVH
  //world transformed triangles in BVH, BVH is in world space
  typename std::list<const CBoundingVolumeNode3<AABB3<T>,T,CTraits> *>::const_iterator i;
  //early out test
  //test point in bvh
  if(!pNode->m_BV.isPointInside(vQuery))
    return 0;

  //determine ray direction
  Vector3<T> dir(0.9,0.8,0.02);/// = vQuery - pNode->m_BV.GetCenter();

  //CRay3(const Vector3<T> &vOrig, const Vector3<T> &vDir);
  Ray3<T> ray(vQuery,dir);

  Traverse(pNode,ray);

  //loop through nodes and test for intersection 
  //with the contained triangles
  i=m_pNodes.begin();
  int nIntersections=0;
  for(;i!=m_pNodes.end();i++)
  {
    const CBoundingVolumeNode3<AABB3<T>,T,CTraits> *node = *i;
    typename std::vector<Triangle3<T> >::const_iterator j=node->m_Traits.m_vTriangles.begin();
    for(;j!=node->m_Traits.m_vTriangles.end();j++)
    {
      const Triangle3<T> &tri3 = *j;
      CIntersectorRay3Tri3<T> intersector(ray, tri3);
      //test for intersection
      if(intersector.Intersection())
        nIntersections++;
    }//end for j
  }//end for i
  //we finished looping through the triangles
  //if the number of intersection is even
  //we return false else true
  if(!(nIntersections % 2 == 0))
  {
    m_pNodes.clear();
    return 1;
  }
  else
  {
    m_pNodes.clear();
    return 0;
  }
}
Exemplo n.º 12
0
int main(){
int i;
int data;
struct HNode* root=(struct HNode* )malloc(sizeof(struct HNode));
root->count=0;
root->next=NULL;
struct HNode* root1=(struct HNode* )malloc(sizeof(struct HNode));
root1->count=0;
root1->next=NULL;
struct HNode* root2=(struct HNode* )malloc(sizeof(struct HNode));
root2->count=0;
root2->next=NULL;
int n;
printf("\nEnter data for first lsit \n");
getch();
for(i=0;i<6;i++){
printf("\nenter data for %dth node : ",i);
scanf("%d",&data);
Insert(root,data);
}

printf("\n%d Nodes inserted...",i);
getch();

printf("\nEnter to traverse..\n\n");
getch();
Traverse(root);
getch();
printf("\nEnter to reverse in group \nEnter group length : ");
scanf("%d",&n);
root->next=ReverseGroup(root->next,n);

getch();
Traverse(root);
return 0;
}
Exemplo n.º 13
0
	void Branch(wxInt32 currentID, wxInt32 otherID, wxInt32 branchID, 
		Segment &segment, wxInt32 cornerID)
	{
		// See if the branch exists.  If it does, and it differs in type from 
		// the current segment, there has to be a bridge corner, otherwise, 
		// we're free to traverse.
		SegmentHash::iterator it = mSegmentHash.find(branchID);
		if( (mSegmentHash.end() != it) &&
			(false == it->second.counted) &&
			((typeid(*segment.object) == typeid(*(it->second.object))) ||
			(mBridgeCorners.end() != mBridgeCorners.find(cornerID)))
			)
		{
			Traverse(branchID, currentID, otherID);
		}
	}
Exemplo n.º 14
0
void showResults( List* resultsList, Item* resultsLevel, HWND hContsLBox )
{
    if ( ListIsEmpty( resultsList ) )
        MessageBox( NULL, TEXT( "No results - showResults()" ),
            TEXT( "Dir Glance" ), MB_ICONERROR );
    else
    {
        // Display founded entries
        Traverse( resultsList, showItem, hContsLBox );

        // Display totals
        SendMessage( hContsLBox, LB_ADDSTRING, 0,
            ( LPARAM )TEXT( " =================== ================ ========== ================== ================================" ) );
        showItem( resultsLevel, hContsLBox );
    }
}
Exemplo n.º 15
0
void KRoleManager::CalculateCampActivePlayerCount()
{
    KCalculateCampActivePlayerCount Calculate;

    memset(Calculate.m_nActivePlayerCount, 0, sizeof(Calculate.m_nActivePlayerCount));

    Traverse(Calculate);
    
    memcpy(
        g_pSO3GameCenter->m_CampManager.m_nActivePlayerCount, 
        Calculate.m_nActivePlayerCount, 
        sizeof(g_pSO3GameCenter->m_CampManager.m_nActivePlayerCount)
    );

    g_pSO3GameCenter->m_GameServer.DoSyncCampInfo(-1);
}
Exemplo n.º 16
0
int main(void)
{
	List movies;
	Item temp;

	/*初始化*/
	InitializeList(&movies);
	if(ListIsFull(&movies))
	{
		fprintf(stderr,"no memory available!\n");
		exit(1);
	}

	/*收集并存储*/
	puts("enter first movie title");
	while(fgets(temp.title,TSIZE,stdin) != NULL && temp.title[0] != '\n')
	{
		puts("enter your rating <0-10>:");
		scanf("%d",&temp.rating);
		while(getchar() != '\n')
			continue;
		if(AddItem(temp,&movies) == false)
		{
			fprintf(stderr,"problem allocating memory\n");
			break;
		}
		if(ListIsFull(&movies))
		{
			puts("the list is now full.");
			break;
		}
		puts("enter next movie title(empty line to stop)");
	}
		if( ListIsEmpty(&movies) )
			printf("no data entered.");
		else
		{
			printf("here is the movie list:\n");
			Traverse(&movies,showmovies);
		}
		printf("your entered %d movies.\n",ListItemCount(&movies) );
		/*清除*/
		EmptyTheList(&movies);
		printf("bye!\n");
		return 0;
			}
Exemplo n.º 17
0
int main()
{
    List movies;
    Item temp;

    InitializeList(&movies);
    if(ListIsFull(&movies))
    {
        fprintf(stderr,"no memory available!\nBye!\n");
        exit(1);
    }

    puts("enter first movie title:");
    while(gets(temp.title) != NULL && temp.title[0] != '\0')
    {
        puts("enter your rating:");
        scanf("%d",&temp.rating);
        while(getchar() != '\n')
            continue;
        if(AddItem(temp,&movies) == false)
        {
            fprintf(stderr,"Problem allocating memory\n");
            break;
        }
        if(ListIsFull(&movies))
        {
            puts("the list is full");
            break;
        }
        puts("enter next movie title:");
    }

    if(ListIsEmpty(&movies))
    {
        printf("no data entered.");
    }
    else
    {
        printf("here is the movie list:\n");
        Traverse(&movies,ShowMovies);
    }
    printf("you entered %d movies.\n",ListItemCount(&movies));
    EmptyTheList(&movies);
    printf("Bye!\n");
    return 0;
}
Exemplo n.º 18
0
void main()
{
	SSTable st;
	SOSTree t;
	Status i;
	KeyType s;
	Creat_Ord(&st, N); /* 由全局数组产生非降序静态查找表st */
	Traverse(st, print);
	CreateSOSTree(&t, st); /* 由有序表构造一棵次优查找树 */
	printf("\n请输入待查找的字符: ");
	scanf("%c", &s);
	i = Search_SOSTree(&t, s);
	if (i)
		printf("%c的权值是%d\n", s, t->data.weight);
	else
		printf("表中不存在此字符\n");
}
Exemplo n.º 19
0
Arquivo: tree.c Projeto: jainsahab/DSA
int insertNode(Tree* tree, void* parentData, void* data){
	TreeNode* parent;
	TreeNode* treenode;
	if(parentData == NULL){
		treenode = getNode(parentData,data);
		tree->root = create();
		insert((List*)tree->root, 0, treenode);
		return 1;
	}
	parent = Traverse((List*)tree->root,parentData,tree->compare);
	if(parent == NULL)
		return 0;
	treenode = getNode(parent, data);
	insert(parent->children,0,treenode);
	return 1;

}
Exemplo n.º 20
0
void JObjectTree::Render()
{
    Traverse( &JObjectTree::DrawNodeCallback );

    //  draw dragged node
    if (m_pDraggedNode)
    {
        Vec2 mPos;
        g_pWindowServer->GetMousePos( mPos );
        Frame ext( mPos.x - m_DragShift.x, mPos.y - m_DragShift.y, m_NodeWidth, m_NodeHeight );
        RenderNode( m_pDraggedNode, ext, false );
        if (m_bCanDrop)
        {
            g_pDrawServer->DrawRect( m_InsExt, m_InsColor );
        }
    }
    g_pDrawServer->Flush();
} // JObjectTree::Render
Exemplo n.º 21
0
TraversalState BVH::Traverse(const SlimRay& ray, HitRecord* nearest,
 function<bool (uint32_t index, const SlimRay& ray, HitRecord* hit, bool* request_suspend)> intersector) {
    // Initialize fresh state.
    TraversalState traversal;

    // Quick test for special cases.
    if (!_nodes[0].bounds.IsValid()) {
        traversal.current = 0;
        traversal.state = TraversalState::State::FROM_CHILD;
        return traversal;
    }

    // Start by going down the root's near child.
    traversal.current = NearChild(0, ray.direction);
    traversal.state = TraversalState::State::FROM_PARENT;

    return Traverse(traversal, ray, nearest, intersector, false);
}
Exemplo n.º 22
0
 void Algo9_1_main()
 {
   SSTable st;
   int i,s;
   for(i=0;i<N;i++) // 计算总分
     r[i].total=r[i].politics+r[i].Chinese+r[i].English+r[i].math+r[i].physics+r[i].chemistry+r[i].biology;
   Creat_Seq(st,N); // 由全局数组产生静态查找表st
   printf("准考证号  姓名  政治 语文 外语 数学 物理 化学 生物 总分\n");
   Traverse(st,print); // 按顺序输出静态查找表st
   printf("请输入待查找人的总分: ");
   scanf("%d",&s);
   i=Search_Seq(st,s); // 顺序查找
   if(i)
     print(*(st.elem+i));
   else
     printf("没找到\n");
   Destroy(st);
 }
Exemplo n.º 23
0
void Traverse(std::vector<GPU_Voxel<NC>> _voxels, std::vector<GPU_Node> _nodes, GPU_Node& _currentNode)
{
	counter++;

	if (_currentNode.NChildren() <= 0)
		return;

	//printf("%i: I have %i children\n", counter, _currentNode.NChildren());
	

	for (int i = 0; i < 8; ++i)
	{
		if (_currentNode.HasChild(i))
		{
			Traverse(_voxels, _nodes, _nodes[_currentNode.GetChildAddress(i)]);
		}
	}
}
Exemplo n.º 24
0
int main() {

	while(scanf("%d",&target) != EOF) {
		node *root;
		root = Build();
		
		bool op;
		if(root == NULL)	op = false;
		else	 op = Traverse(root,0);
		
		if(op)	puts("yes");
		else	puts("no");
		
		Erase(root);
	}

	return 0;
}
Exemplo n.º 25
0
int main(void){
	List movies;
	Item temp;
	
	//初始化 
	InitializeList(&movies);
	if(ListIsFull(&movies)){
		fprintf(stderr,"No memory available!");
		exit(1);
	}
	
	//收集并储存 
	puts("Enter first movie title:");
	while(gets(temp.title ) != NULL && temp.title [0] != '\0' ){
		puts("Enter your rating <0-10>:");
		scanf("%d",&temp.rating );
		while(getchar()!='\n'){
			continue;
		}
		if(AddItem(temp,&movies)==false){
			fprintf(stderr,"Problem allocating memory\n");
			break;
		}
		if(ListIsFull(&movies)){
			puts("The list is full.");
			break; 
		}
		puts("Enter next movie title(empty line to stop))");
	}
	
	//显示 
	if(ListIsEmpty(&movies)){
		printf("No data entered.");
	}
	else{
		printf("Here is the movie list:\n");
		Traverse(&movies,showmovies);
	}
	
	//清除 
	EmptyTheList(&movies);
	printf("Bye!");
	return 0;	
}
Exemplo n.º 26
0
initrd_inode_t* ResolvePath(int fd, initrd_superblock_t* sb,
                            initrd_inode_t* inode, const char* path)
{
	if ( !path[0] ) { return CloneInode(inode); }
	if ( path[0] == '/' )
	{
		if ( !INITRD_S_ISDIR(inode->mode) ) { errno = ENOTDIR; return NULL; }
		return ResolvePath(fd, sb, inode, path+1);
	}
	size_t elemlen = strcspn(path, "/");
	char* elem = Substring(path, 0, elemlen);
	uint32_t ino = Traverse(fd, sb, inode, elem);
	free(elem);
	if ( !ino ) { return NULL; }
	initrd_inode_t* child = GetInode(fd, sb, ino);
	if ( !child ) { return NULL; }
	if ( !path[elemlen] ) { return child; }
	initrd_inode_t* result = ResolvePath(fd, sb, child, path + elemlen);
	free(child);
	return result;
}
void CoverTree<MetricType, RootPointPolicy, StatisticType>::
DualTreeTraverser<RuleType>::Traverse(
    CoverTree<MetricType, RootPointPolicy, StatisticType>& queryNode,
    CoverTree<MetricType, RootPointPolicy, StatisticType>& referenceNode)
{
  // Start by creating a map and adding the reference root node to it.
  std::map<int, std::vector<DualCoverTreeMapEntry> > refMap;

  DualCoverTreeMapEntry rootRefEntry;

  rootRefEntry.referenceNode = &referenceNode;

  // Perform the evaluation between the roots of either tree.
  rootRefEntry.score = rule.Score(queryNode, referenceNode);
  rootRefEntry.baseCase = rule.BaseCase(queryNode.Point(),
      referenceNode.Point());
  rootRefEntry.traversalInfo = rule.TraversalInfo();

  refMap[referenceNode.Scale()].push_back(rootRefEntry);

  Traverse(queryNode, refMap);
}
void GreedySingleTreeTraverser<TreeType, RuleType>::Traverse(
    const size_t queryIndex,
    TreeType& referenceNode)
{
  // Run the base case as necessary for all the points in the reference node.
  for (size_t i = 0; i < referenceNode.NumPoints(); ++i)
    rule.BaseCase(queryIndex, referenceNode.Point(i));

  size_t bestChild = rule.GetBestChild(queryIndex, referenceNode);
  size_t numDescendants;

  // Check that referencenode is not a leaf node while calculating number of
  // descendants of it's best child.
  if (!referenceNode.IsLeaf())
    numDescendants = referenceNode.Child(bestChild).NumDescendants();
  else
    numDescendants = referenceNode.NumPoints();

  // If number of descendants are more than minBaseCases than we can go along
  // with best child otherwise we need to traverse for each descendant to
  // ensure that we calculate at least minBaseCases number of base cases.
  if (!referenceNode.IsLeaf())
  {
    if (numDescendants > minBaseCases)
    {
      // We are prunning all but one child.
      numPrunes += referenceNode.NumChildren() - 1;
      // Recurse the best child.
      Traverse(queryIndex, referenceNode.Child(bestChild));
    }
    else
    {
      // Run the base case over first minBaseCases number of descendants.
      for (size_t i = 0; i <= minBaseCases; ++i)
        rule.BaseCase(queryIndex, referenceNode.Descendant(i));
    }
  }
}
Exemplo n.º 29
0
static  void    FlowConditions( void )
/*************************************
    For each block in the program, first "GatherSources" to determine
    what the state of the condition codes are on entry to the routine,
    then "Traverse" the block, to see if there is an instruction that
    sets the condition codes for the conditional branches at the end of
    the block correctly, or if the condition codes from previous blocks
    are unaffected by the block and will suffice for the final branch.
*/
{
    block       *blk;
    name        *zero;
    bool        change;

    zero = AllocIntConst( 0 );
    do {
        change = false;
        for( blk = HeadBlock; blk != NULL; blk = blk->next_block ) {
            GatherSources( blk );
            change |= Traverse( blk, zero );
        }
    } while( change );
}
Exemplo n.º 30
0
bool ClangToSageTranslator::VisitEnumDecl(clang::EnumDecl * enum_decl, SgNode ** node) {
#if DEBUG_VISIT_DECL
    std::cerr << "ClangToSageTranslator::VisitEnumDecl" << std::endl;
#endif
    bool res = true;

    SgName name(enum_decl->getNameAsString());


    clang::EnumDecl * prev_enum_decl = enum_decl->getPreviousDeclaration();
    SgEnumSymbol * sg_prev_enum_sym = isSgEnumSymbol(GetSymbolFromSymbolTable(prev_enum_decl));
    SgEnumDeclaration * sg_prev_enum_decl = sg_prev_enum_sym == NULL ? NULL : isSgEnumDeclaration(sg_prev_enum_sym->get_declaration());
    sg_prev_enum_decl = sg_prev_enum_decl == NULL ? NULL : isSgEnumDeclaration(sg_prev_enum_decl->get_definingDeclaration());

    SgEnumDeclaration * sg_enum_decl = SageBuilder::buildEnumDeclaration(name, SageBuilder::topScopeStack());
    *node = sg_enum_decl;

    if (sg_prev_enum_decl == NULL || sg_prev_enum_decl->get_enumerators().size() == 0) {
      clang::EnumDecl::enumerator_iterator it;
      for (it = enum_decl->enumerator_begin(); it != enum_decl->enumerator_end(); it++) {
          SgNode * tmp_enumerator = Traverse(*it);
          SgInitializedName * enumerator = isSgInitializedName(tmp_enumerator);

          ROSE_ASSERT(enumerator);

          enumerator->set_scope(SageBuilder::topScopeStack());
          sg_enum_decl->append_enumerator(enumerator);
      }
    }
    else {
      sg_enum_decl->set_definingDeclaration(sg_prev_enum_decl);
      sg_enum_decl->set_firstNondefiningDeclaration(sg_prev_enum_decl->get_firstNondefiningDeclaration());
    }

    return VisitDecl(enum_decl, node) && res;
}