There appears to be a logic issue in vtkInformationVector::Remove() that causes incorrect behavior when removing information objects from the vector, particularly when the same object appears multiple times.
The current implementation iterates forward through the vector and erases elements without adjusting the loop index:
Issues identified:
After erase(), all subsequent elements shift left by one position, but the loop continues with i++, effectively skipping the next element.
Reproduction Test Case:
#include <iostream>
#include "vtkInformation.h"
#include "vtkInformationVector.h"
int main()
{
vtkInformation *info = vtkInformation::New();
vtkInformationVector *vec = vtkInformationVector::New();
// Append the same info object twice
vec->Append(info);
vec->Append(info);
std::cout << "Before Remove: " << vec->GetNumberOfInformationObjects() << std::endl; // 2
vec->Remove(info);
std::cout << "After Remove: " << vec->GetNumberOfInformationObjects() << std::endl;
// Expected: 0, but got 1
info->Delete();
vec->Delete();
return 0;
}