[ace-users] ACE_DLList::remove method not working

Johnny Willemsen jwillemsen at remedy.nl
Wed Aug 29 04:02:29 CDT 2007


Hi,
 
Your ACE version is ancient, can you try x.5.10 which you can obtain from
http://download.dre.vanderbilt.edu. Have a look at
ACE_wrappers/tests/DLList_Test.cpp, extend that test with your use case if
things still doesn't work.
 
Regards,
 
Johnny Willemsen
Remedy IT
Postbus 101
2650 AC  Berkel en Rodenrijs
The Netherlands
www.theaceorb.nl / www.remedy.nl 

*** Integrated compile and test statistics see
http://scoreboard.theaceorb.nl <http://scoreboard.theaceorb.nl/>  ***
*** Commercial service and support for ACE/TAO/CIAO             ***
*** See http://www.theaceorb.nl/en/support.html                 *** 

 


________________________________

	From: ace-users-bounces at cse.wustl.edu
[mailto:ace-users-bounces at cse.wustl.edu] On Behalf Of Srinivas Rao
Chiguruparti
	Sent: Wednesday, August 29, 2007 11:11 AM
	To: ace-users at cs.wustl.edu
	Subject: [ace-users] ACE_DLList::remove method not working
	
	

	Hi All, 

	I am new to ACE (using version 5.4.6). I am observing remove method
of ACE_DLList not working or I am not using this method correctly. 

	Please point me whether my code is wrong or is it bug in ACE_DLList
implementation? 

	  

	In the following code I am inserting 2 new elements at head of the
list. 

	Later after printing number of elements in list (using size method),
first removing one element using delete_head (it is working fine) 

	 and later removing other element from list using remove method,
which is not working. 

	  

	I need to use in my application remove method of ACE_DLList to
directly remove node. I want to store Node pointer when inserting 

	and want to delete using remove method without iterating through the
list for performance reasons. 

	  

	Simple code used to test remove method of ACE_DLList: 

	  

	#include <iostream> 

	#include "ace/OS_Memory.h" 

	#include "ace/Log_Msg.h" 

	  

	#include "ace/Containers.h" 

	#include "ace/Containers_T.h" 

	  

	typedef struct Heads_t{ 

	            int ptr2head; 

	}HeadPtr; 

	  

	class ace_dll_test 

	{ 

	            public: 

	                        ace_dll_test() { memset((void
*)&head,0x00,(sizeof(HeadPtr)));}; 

	                        ~ace_dll_test() {}; 

	                        void CreateDLList(); 

	                        void InsertIntoList(); 

	                        void FreeTheNode(); 

	                        HeadPtr head; 

	                        int *i,*j; 

	}; 

	void 

	ace_dll_test::CreateDLList() 

	{ 

	    if(head.ptr2head == 0) 

	    { 

	        printf("***** Creating a New Head List *****\n"); 

	        head.ptr2head = (int) new ACE_DLList<int> (); 

	    } 

	} 

	  

	void 

	ace_dll_test::InsertIntoList() 

	{ 

	   printf("Before Inserting the Node Size of list is:%d\n", 

	                                                   ((ACE_DLList<int>
*)(head.ptr2head))->size()); 

	            i = (int *) malloc(sizeof(int)); 

	            j = (int *) malloc(sizeof(int)); 

	            *i=2; *j=3; 

	   ((ACE_DLList<int>*)(head.ptr2head))->insert_head(i); 

	   ((ACE_DLList<int>*)(head.ptr2head))->insert_head(j); 

	   

	   printf("After Inserting the Node Size of list is:%d \n", 

	            ((ACE_DLList<int>*)(head.ptr2head))->size()); 

	} 

	  

	  

	void 

	ace_dll_test::FreeTheNode() 

	{ 

	    if(head.ptr2head != 0) 

	    { 

	            printf("Before deleting the Node Size of list is:%d \n",


	
((ACE_DLList<int>*)(head.ptr2head))->size()); 

	  

	                        int *p =
((ACE_DLList<int>*)(head.ptr2head))->delete_head(); 

	  

	                        printf("After deleting the Node using
delete_head() Size of list is:%d \n", 

	
((ACE_DLList<int>*)(head.ptr2head))->size()); 

	                        

	
((ACE_DLList<int>*)(head.ptr2head))->remove((ACE_DLList_Node *)i); 

	  

	                        printf("After deleting the Node using
remove() Size of list is:%d \n", 

	
((ACE_DLList<int>*)(head.ptr2head))->size()); 

	    } else { 

	        printf("In CancleTimer tmrName is EXPIRATION_TIMEOUT_TMR but
Head List in NULL\n"); 

	    } 

	} 

	  

	int main() 

	{ 

	            ace_dll_test obj; 

	            obj.CreateDLList(); 

	            obj.InsertIntoList(); 

	            obj.FreeTheNode(); 

	            return 1; 

	 } 

	  

	The output of above program is: 

	***** Creating a New Head List ***** 

	Before Inserting the Node Size of list is:0 

	After Inserting the Node Size of list is:2 

	Before deleting the Node Size of list is:2 

	After deleting the Node using delete_head() Size of list is:1 

	After deleting the Node using remove() Size of list is:1 

	  

	  

	Thanks & Regards 

	Srinivasa Rao Chigurupati 

	  




More information about the Ace-users mailing list