The following code snippet shows an iterator
from the std::vector
C++ lib. What is the C# equivalent to this? Can I simply loop through each item in the vector considering its not a linked list? What exactly is the iterator doing here and how can I do the equivalent in C#? The full code is here.
std::vector<KMeanCluster>::iterator closest_cluster = clusters.begin();
// Figure out which cluster this color is closest to in RGB space.
for (std::vector<KMeanCluster>::iterator cluster = clusters.begin();
cluster != clusters.end(); ++cluster) {
uint distance_sqr = cluster->GetDistanceSqr(r, g, b);
if (distance_sqr < distance_sqr_to_closest_cluster) {
distance_sqr_to_closest_cluster = distance_sqr;
closest_cluster = cluster;
}
}