The following code shows how to delete the tail element of the vtkidlist. Because the vteid of the vtkidlist deletes all the same IDs, we use setnumberofids.
The implementation result is as follows:
5 elements:
0: 10
1: 11
2: 12
3: 13
4: 14
Remove 2 elements:
0: 10
1: 11
2: 12
Insert another 3 elements:
0: 10
1: 11
2: 12
3: 15
4: 16
5: 17
Press any key to continue...
The source code is as follows:
# Include "stdafx. H"
# Include "vtkidlist. H"
Void printidlist (vtkidlist * IDs)
{
For (INT I = 0; I <IDS-> getnumberofids (); I ++)
{
Printf ("% d: % d/N", I, IDS-> GETID (I ));
}
}
Int _ tmain (INT argc, _ tchar * argv [])
{
Vtkidlist * IDs = vtkidlist: New ();
Ids-> insertnextid (10 );
Ids-> insertnextid (11 );
Ids-> insertnextid (12 );
Ids-> insertnextid (13 );
Ids-> insertnextid (14 );
Printf ("5 elements:/N ");
Printidlist (IDS );
Printf ("/nremove 2 elements:/N ");
Ids-> setnumberofids (IDS-> getnumberofids ()-2 );
Printidlist (IDS );
Printf ("/ninsert another 3 elements:/N ");
Ids-> insertnextid (15 );
Ids-> insertnextid (16 );
Ids-> insertnextid (17 );
Printidlist (IDS );
Return 0;
}