In the legacy implementation, there is a Queue (which stored the PDUs) which need to be retransmitted. The queue has been implementated as stl map (c++). So the last element in the Queue may not be the largest SN, as per transmit window.
Is there any easy way to derive the largest SN (key) in the map ?


What is the map using for the key? The SN? If so, then it should be the last element in the collection, and you should be able to use the map::crbegin() method on the map (reverse iterator to quickly access the biggest SN since it will be the key for the last element). Show the code that is being used now. And by SN, I assume mean the sequence number and that this is a networking application? What OS?