[linked-list] range-based for loop iteration over all entries (#6945)

This commit enables use of range-based `for` loop for iterating over
all the entries in a `LinkedList`. It adds private implementations of
`Iterator` and `ConstIterator` which inherit from `ItemPtrIterator`
and use the `GetNext()` to go to the next entry. The range-based
`for` loop practically acts as a syntactic sugar helping simplify the
code and does not add any code size (or any expected run-time)
overhead.
This commit is contained in:
Abtin Keshavarzian
2021-08-23 14:50:14 -07:00
committed by GitHub
parent 34366834b0
commit 6895edda59
21 changed files with 241 additions and 197 deletions
+2 -2
View File
@@ -65,13 +65,13 @@ void VerifyMulticastAddressList(const Ip6::Netif &aNetif, Ip6::Address aAddresse
VerifyOrQuit(aNetif.IsMulticastSubscribed(aAddresses[i]));
}
for (const Ip6::Netif::MulticastAddress *addr = aNetif.GetMulticastAddresses(); addr; addr = addr->GetNext())
for (const Ip6::Netif::MulticastAddress &addr : aNetif.GetMulticastAddresses())
{
bool didFind = false;
for (uint8_t i = 0; i < aLength; i++)
{
if (addr->GetAddress() == aAddresses[i])
if (addr.GetAddress() == aAddresses[i])
{
didFind = true;
break;