-3

Can you help me identify which iterator is being used here? (Trivial, input, output)

        int maxIndx = -1;
        int maxSize = -1;
        for (map<int, set<string> >::iterator itr = partitions.begin(); itr != partitions.end(); ++itr) {
            int size = (*itr).second.size();
            if (size > maxSize) {
                maxSize = size;
                maxIndx = (*itr).first;
            }
        }
Mooing Duck
  • 64,318
  • 19
  • 100
  • 158
nugget
  • 9
  • 3
  • Side note: I recommend using `iter->second.size()` and `iter->first` rather than the dereference and dot notation. It's easier to read. – Fred Larson Oct 29 '20 at 16:33
  • 1
    With problems like this, a good way to solution is to read the documentation. – eerorika Oct 29 '20 at 16:44

1 Answers1

1

std::map is documented as having an iterator typedef that is a LegacyBidirectionalIterator.

(cppreference is not official, but it's free, easy, and pretty darn accurate)

Mooing Duck
  • 64,318
  • 19
  • 100
  • 158