TMMBRSet become vector<rtcp::TmmbItem>

this is a slice of https://codereview.webrtc.org/1474693002/
All TMMBRSet functions intentionally left unchanged. Goal to make them obsolete, not to clear.

BUG=webrtc:5565

Review URL: https://codereview.webrtc.org/1669323002

Cr-Commit-Position: refs/heads/master@{#11813}
diff --git a/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc b/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc
index 1001bf4..da43204 100644
--- a/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc
+++ b/webrtc/modules/rtp_rtcp/source/tmmbr_help.cc
@@ -19,81 +19,47 @@
 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
 
 namespace webrtc {
-TMMBRSet::TMMBRSet() :
-    _sizeOfSet(0),
-    _lengthOfSet(0)
-{
-}
-
-TMMBRSet::~TMMBRSet()
-{
-    _sizeOfSet = 0;
-    _lengthOfSet = 0;
-}
-
 void
 TMMBRSet::VerifyAndAllocateSet(uint32_t minimumSize)
 {
-    if(minimumSize > _sizeOfSet)
-    {
-        // make sure that our buffers are big enough
-        _data.resize(minimumSize);
-        _sizeOfSet = minimumSize;
-    }
-    // reset memory
-    for(uint32_t i = 0; i < _sizeOfSet; i++)
-    {
-        _data.at(i).tmmbr = 0;
-        _data.at(i).packet_oh = 0;
-        _data.at(i).ssrc = 0;
-    }
-    _lengthOfSet = 0;
+  clear();
+  reserve(minimumSize);
 }
 
 void
 TMMBRSet::VerifyAndAllocateSetKeepingData(uint32_t minimumSize)
 {
-    if(minimumSize > _sizeOfSet)
-    {
-        {
-          _data.resize(minimumSize);
-        }
-        _sizeOfSet = minimumSize;
-    }
+  reserve(minimumSize);
 }
 
 void TMMBRSet::SetEntry(unsigned int i,
                          uint32_t tmmbrSet,
                          uint32_t packetOHSet,
                          uint32_t ssrcSet) {
-  assert(i < _sizeOfSet);
-  _data.at(i).tmmbr = tmmbrSet;
-  _data.at(i).packet_oh = packetOHSet;
-  _data.at(i).ssrc = ssrcSet;
-  if (i >= _lengthOfSet) {
-    _lengthOfSet = i + 1;
+  RTC_DCHECK_LT(i, capacity());
+  if (i >= size()) {
+    resize(i+1);
   }
+  (*this)[i].set_bitrate_bps(tmmbrSet * 1000);
+  (*this)[i].set_packet_overhead(packetOHSet);
+  (*this)[i].set_ssrc(ssrcSet);
 }
 
 void TMMBRSet::AddEntry(uint32_t tmmbrSet,
                         uint32_t packetOHSet,
                         uint32_t ssrcSet) {
-  assert(_lengthOfSet < _sizeOfSet);
-  SetEntry(_lengthOfSet, tmmbrSet, packetOHSet, ssrcSet);
+  RTC_DCHECK_LT(size(), capacity());
+  SetEntry(size(), tmmbrSet, packetOHSet, ssrcSet);
 }
 
 void TMMBRSet::RemoveEntry(uint32_t sourceIdx) {
-  assert(sourceIdx < _lengthOfSet);
-  _data.erase(_data.begin() + sourceIdx);
-  _lengthOfSet--;
-  _data.resize(_sizeOfSet);  // Ensure that size remains the same.
+  RTC_DCHECK_LT(sourceIdx, size());
+  erase(begin() + sourceIdx);
 }
 
 void TMMBRSet::SwapEntries(uint32_t i, uint32_t j) {
-    SetElement temp;
-    temp = _data[i];
-    _data[i] = _data[j];
-    _data[j] = temp;
+  using std::swap;
+  swap((*this)[i], (*this)[j]);
 }
 
 void TMMBRSet::ClearEntry(uint32_t idx) {
@@ -122,7 +88,7 @@
 {
     CriticalSectionScoped lock(_criticalSection);
 
-    if(minimumSize > _boundingSet.sizeOfSet())
+    if(minimumSize > _boundingSet.capacity())
     {
         // make sure that our buffers are big enough
         if(_ptrIntersectionBoundingSet)
@@ -202,10 +168,9 @@
 
     // Work on local variable, will be modified
     TMMBRSet    candidateSet;
-    candidateSet.VerifyAndAllocateSet(_candidateSet.sizeOfSet());
+    candidateSet.VerifyAndAllocateSet(_candidateSet.capacity());
 
-    // TODO(hta) Figure out if this should be lengthOfSet instead.
-    for (uint32_t i = 0; i < _candidateSet.sizeOfSet(); i++)
+    for (uint32_t i = 0; i < _candidateSet.size(); i++)
     {
         if(_candidateSet.Tmmbr(i))
         {
@@ -229,7 +194,7 @@
     if (numSetCandidates > 0)
     {
         numBoundingSet =  FindTMMBRBoundingSet(numSetCandidates, candidateSet);
-        if(numBoundingSet < 1 || (numBoundingSet > _candidateSet.sizeOfSet()))
+        if(numBoundingSet < 1 || (numBoundingSet > _candidateSet.size()))
         {
             return -1;
         }
@@ -245,12 +210,11 @@
     CriticalSectionScoped lock(_criticalSection);
 
     uint32_t numBoundingSet = 0;
-    VerifyAndAllocateBoundingSet(candidateSet.sizeOfSet());
+    VerifyAndAllocateBoundingSet(candidateSet.capacity());
 
     if (numCandidates == 1)
     {
-        // TODO(hta): lengthOfSet instead of sizeOfSet?
-        for (uint32_t i = 0; i < candidateSet.sizeOfSet(); i++)
+        for (uint32_t i = 0; i < candidateSet.size(); i++)
         {
             if (candidateSet.Tmmbr(i) > 0)
             {
@@ -264,7 +228,7 @@
     }
 
     // 1. Sort by increasing packetOH
-    for (int i = candidateSet.sizeOfSet() - 1; i >= 0; i--)
+    for (int i = candidateSet.size() - 1; i >= 0; i--)
     {
         for (int j = 1; j <= i; j++)
         {
@@ -275,7 +239,7 @@
         }
     }
     // 2. For tuples with same OH, keep the one w/ the lowest bitrate
-    for (uint32_t i = 0; i < candidateSet.sizeOfSet(); i++)
+    for (uint32_t i = 0; i < candidateSet.size(); i++)
     {
         if (candidateSet.Tmmbr(i) > 0)
         {
@@ -283,7 +247,7 @@
             uint32_t currentPacketOH = candidateSet.PacketOH(i);
             uint32_t currentMinTMMBR = candidateSet.Tmmbr(i);
             uint32_t currentMinIndexTMMBR = i;
-            for (uint32_t j = i+1; j < candidateSet.sizeOfSet(); j++)
+            for (uint32_t j = i+1; j < candidateSet.size(); j++)
             {
                 if(candidateSet.PacketOH(j) == currentPacketOH)
                 {
@@ -295,7 +259,7 @@
                 }
             }
             // keep lowest bitrate
-            for (uint32_t j = 0; j < candidateSet.sizeOfSet(); j++)
+            for (uint32_t j = 0; j < candidateSet.size(); j++)
             {
               if(candidateSet.PacketOH(j) == currentPacketOH
                   && j != currentMinIndexTMMBR)
@@ -310,7 +274,7 @@
     // (If more than 1, choose the one w/ highest OH).
     uint32_t minTMMBR = 0;
     uint32_t minIndexTMMBR = 0;
-    for (uint32_t i = 0; i < candidateSet.sizeOfSet(); i++)
+    for (uint32_t i = 0; i < candidateSet.size(); i++)
     {
         if (candidateSet.Tmmbr(i) > 0)
         {
@@ -320,7 +284,7 @@
         }
     }
 
-    for (uint32_t i = 0; i < candidateSet.sizeOfSet(); i++)
+    for (uint32_t i = 0; i < candidateSet.size(); i++)
     {
         if (candidateSet.Tmmbr(i) > 0 && candidateSet.Tmmbr(i) <= minTMMBR)
         {
@@ -354,7 +318,7 @@
 
     // 4. Discard from candidate list all tuple w/ lower OH
     // (next tuple must be steeper)
-    for (uint32_t i = 0; i < candidateSet.sizeOfSet(); i++)
+    for (uint32_t i = 0; i < candidateSet.size(); i++)
     {
         if(candidateSet.Tmmbr(i) > 0
             && candidateSet.PacketOH(i) < _boundingSet.PacketOH(0))
@@ -381,7 +345,7 @@
         if (getNewCandidate)
         {
             // 5. Remove first remaining tuple from candidate list
-            for (uint32_t i = 0; i < candidateSet.sizeOfSet(); i++)
+            for (uint32_t i = 0; i < candidateSet.size(); i++)
             {
                 if (candidateSet.Tmmbr(i) > 0)
                 {
@@ -455,7 +419,7 @@
     return false;
   }
   for(uint32_t i = 0;
-      (i < length) && (i < _boundingSet.sizeOfSet()); ++i) {
+      (i < length) && (i < _boundingSet.size()); ++i) {
     if(_boundingSet.Ssrc(i) == ssrc) {
       return true;
     }
@@ -466,7 +430,7 @@
 bool TMMBRHelp::CalcMinBitRate( uint32_t* minBitrateKbit) const {
   CriticalSectionScoped lock(_criticalSection);
 
-  if (_candidateSet.sizeOfSet() == 0) {
+  if (_candidateSet.size() == 0) {
     // Empty bounding set.
     return false;
   }