Skip to content

Commit d6e1388

Browse files
committed
Declare *Container::Iterator for-loop iterators inline
1 parent a803ca3 commit d6e1388

File tree

12 files changed

+83
-110
lines changed

12 files changed

+83
-110
lines changed

src/buildings/helper/building-container.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,10 @@ class BuildingContainer
6767
* for-loop to run through the Buildings
6868
*
6969
* @code
70-
* BuildingContainer::Iterator i;
71-
* for (i = container.Begin (); i != container.End (); ++i)
72-
* {
73-
* (*i)->method (); // some Building method
74-
* }
70+
* for (auto i = container.Begin(); i != container.End(); ++i)
71+
* {
72+
* (*i)->method(); // some Building method
73+
* }
7574
* @endcode
7675
*
7776
* @returns an iterator which refers to the first Building in the container.
@@ -88,11 +87,10 @@ class BuildingContainer
8887
* for-loop to run through the Buildings
8988
*
9089
* @code
91-
* BuildingContainer::Iterator i;
92-
* for (i = container.Begin (); i != container.End (); ++i)
93-
* {
94-
* (*i)->method (); // some Building method
95-
* }
90+
* for (auto i = container.Begin(); i != container.End(); ++i)
91+
* {
92+
* (*i)->method(); // some Building method
93+
* }
9694
* @endcode
9795
*
9896
* @returns an iterator which indicates an ending condition for a loop.

src/energy/helper/energy-harvester-container.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,10 @@ class EnergyHarvesterContainer : public Object
9494
* for-loop to run through the EnergyHarvesters.
9595
*
9696
* @code
97-
* EnergyHarvesterContainer::Iterator i;
98-
* for (i = container.Begin (); i != container.End (); ++i)
99-
* {
100-
* (*i)->method (); // some EnergyHarvester method
101-
* }
97+
* for (auto i = container.Begin(); i != container.End(); ++i)
98+
* {
99+
* (*i)->method(); // some EnergyHarvester method
100+
* }
102101
* @endcode
103102
*/
104103
Iterator Begin() const;
@@ -115,11 +114,10 @@ class EnergyHarvesterContainer : public Object
115114
* for-loop to run through the EnergyHarvesters.
116115
*
117116
* @code
118-
* EnergyHarvesterContainer::Iterator i;
119-
* for (i = container.Begin (); i != container.End (); ++i)
120-
* {
121-
* (*i)->method (); // some EnergyHarvester method
122-
* }
117+
* for (auto i = container.Begin(); i != container.End(); ++i)
118+
* {
119+
* (*i)->method(); // some EnergyHarvester method
120+
* }
123121
* @endcode
124122
*/
125123
Iterator End() const;

src/energy/helper/energy-source-container.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,10 @@ class EnergySourceContainer : public Object
9292
* for-loop to run through the EnergySources.
9393
*
9494
* @code
95-
* EnergySourceContainer::Iterator i;
96-
* for (i = container.Begin (); i != container.End (); ++i)
97-
* {
98-
* (*i)->method (); // some EnergySource method
99-
* }
95+
* for (auto i = container.Begin(); i != container.End(); ++i)
96+
* {
97+
* (*i)->method(); // some EnergySource method
98+
* }
10099
* @endcode
101100
*/
102101
Iterator Begin() const;
@@ -113,11 +112,10 @@ class EnergySourceContainer : public Object
113112
* for-loop to run through the EnergySources.
114113
*
115114
* @code
116-
* EnergySourceContainer::Iterator i;
117-
* for (i = container.Begin (); i != container.End (); ++i)
118-
* {
119-
* (*i)->method (); // some EnergySource method
120-
* }
115+
* for (auto i = container.Begin(); i != container.End(); ++i)
116+
* {
117+
* (*i)->method(); // some EnergySource method
118+
* }
121119
* @endcode
122120
*/
123121
Iterator End() const;

src/energy/model/device-energy-model-container.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,10 @@ class DeviceEnergyModelContainer
8787
* for-loop to run through the DeviceEnergyModels.
8888
*
8989
* @code
90-
* DeviceEnergyModelContainer::Iterator i;
91-
* for (i = container.Begin (); i != container.End (); ++i)
92-
* {
93-
* (*i)->method (); // some DeviceEnergyModel method
94-
* }
90+
* for (auto i = container.Begin(); i != container.End(); ++i)
91+
* {
92+
* (*i)->method(); // some DeviceEnergyModel method
93+
* }
9594
* @endcode
9695
*/
9796
Iterator Begin() const;
@@ -108,11 +107,10 @@ class DeviceEnergyModelContainer
108107
* for-loop to run through the DeviceEnergyModels.
109108
*
110109
* @code
111-
* DeviceEnergyModelContainer::Iterator i;
112-
* for (i = container.Begin (); i != container.End (); ++i)
113-
* {
114-
* (*i)->method (); // some DeviceEnergyModel method
115-
* }
110+
* for (auto i = container.Begin(); i != container.End(); ++i)
111+
* {
112+
* (*i)->method(); // some DeviceEnergyModel method
113+
* }
116114
* @endcode
117115
*/
118116
Iterator End() const;

src/energy/model/energy-source.cc

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ EnergySource::FindDeviceEnergyModels(TypeId tid)
7070
{
7171
NS_LOG_FUNCTION(this << tid);
7272
DeviceEnergyModelContainer container;
73-
DeviceEnergyModelContainer::Iterator i;
74-
for (i = m_models.Begin(); i != m_models.End(); i++)
73+
for (auto i = m_models.Begin(); i != m_models.End(); i++)
7574
{
7675
if ((*i)->GetInstanceTypeId() == tid)
7776
{
@@ -86,8 +85,7 @@ EnergySource::FindDeviceEnergyModels(std::string name)
8685
{
8786
NS_LOG_FUNCTION(this << name);
8887
DeviceEnergyModelContainer container;
89-
DeviceEnergyModelContainer::Iterator i;
90-
for (i = m_models.Begin(); i != m_models.End(); i++)
88+
for (auto i = m_models.Begin(); i != m_models.End(); i++)
9189
{
9290
if ((*i)->GetInstanceTypeId().GetName() == name)
9391
{
@@ -105,8 +103,7 @@ EnergySource::InitializeDeviceModels()
105103
* Device models are not aggregated to the node, hence we have to manually
106104
* call dispose method here.
107105
*/
108-
DeviceEnergyModelContainer::Iterator i;
109-
for (i = m_models.Begin(); i != m_models.End(); i++)
106+
for (auto i = m_models.Begin(); i != m_models.End(); i++)
110107
{
111108
(*i)->Initialize();
112109
}
@@ -120,8 +117,7 @@ EnergySource::DisposeDeviceModels()
120117
* Device models are not aggregated to the node, hence we have to manually
121118
* call dispose method here.
122119
*/
123-
DeviceEnergyModelContainer::Iterator i;
124-
for (i = m_models.Begin(); i != m_models.End(); i++)
120+
for (auto i = m_models.Begin(); i != m_models.End(); i++)
125121
{
126122
(*i)->Dispose();
127123
}
@@ -155,8 +151,7 @@ EnergySource::CalculateTotalCurrent()
155151
{
156152
NS_LOG_FUNCTION(this);
157153
double totalCurrentA = 0.0;
158-
DeviceEnergyModelContainer::Iterator i;
159-
for (i = m_models.Begin(); i != m_models.End(); i++)
154+
for (auto i = m_models.Begin(); i != m_models.End(); i++)
160155
{
161156
totalCurrentA += (*i)->GetCurrentA();
162157
}
@@ -190,8 +185,7 @@ EnergySource::NotifyEnergyDrained()
190185
{
191186
NS_LOG_FUNCTION(this);
192187
// notify all device energy models installed on node
193-
DeviceEnergyModelContainer::Iterator i;
194-
for (i = m_models.Begin(); i != m_models.End(); i++)
188+
for (auto i = m_models.Begin(); i != m_models.End(); i++)
195189
{
196190
(*i)->HandleEnergyDepletion();
197191
}
@@ -202,8 +196,7 @@ EnergySource::NotifyEnergyRecharged()
202196
{
203197
NS_LOG_FUNCTION(this);
204198
// notify all device energy models installed on node
205-
DeviceEnergyModelContainer::Iterator i;
206-
for (i = m_models.Begin(); i != m_models.End(); i++)
199+
for (auto i = m_models.Begin(); i != m_models.End(); i++)
207200
{
208201
(*i)->HandleEnergyRecharged();
209202
}
@@ -214,8 +207,7 @@ EnergySource::NotifyEnergyChanged()
214207
{
215208
NS_LOG_FUNCTION(this);
216209
// notify all device energy models installed on node
217-
DeviceEnergyModelContainer::Iterator i;
218-
for (i = m_models.Begin(); i != m_models.End(); i++)
210+
for (auto i = m_models.Begin(); i != m_models.End(); i++)
219211
{
220212
(*i)->HandleEnergyChanged();
221213
}

src/internet/helper/ipv4-interface-container.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,11 @@ class Ipv4InterfaceContainer
7070
* for-loop to run through the pairs
7171
*
7272
* @code
73-
* Ipv4InterfaceContainer::Iterator i;
74-
* for (i = container.Begin (); i != container.End (); ++i)
75-
* {
73+
* for (auto i = container.Begin(); i != container.End(); ++i)
74+
* {
7675
* std::pair<Ptr<Ipv4>, uint32_t> pair = *i;
77-
* method (pair.first, pair.second); // use the pair
78-
* }
76+
* method(pair.first, pair.second); // use the pair
77+
* }
7978
* @endcode
8079
*
8180
* @returns an iterator which refers to the first pair in the container.
@@ -92,12 +91,11 @@ class Ipv4InterfaceContainer
9291
* for-loop to run through the Nodes
9392
*
9493
* @code
95-
* NodeContainer::Iterator i;
96-
* for (i = container.Begin (); i != container.End (); ++i)
97-
* {
94+
* for (auto i = container.Begin(); i != container.End(); ++i)
95+
* {
9896
* std::pair<Ptr<Ipv4>, uint32_t> pair = *i;
99-
* method (pair.first, pair.second); // use the pair
100-
* }
97+
* method(pair.first, pair.second); // use the pair
98+
* }
10199
* @endcode
102100
*
103101
* @returns an iterator which indicates an ending condition for a loop.

src/internet/helper/ipv6-interface-container.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,11 @@ class Ipv6InterfaceContainer
105105
* for-loop to run through the pairs
106106
*
107107
* @code
108-
* Ipv6InterfaceContainer::Iterator i;
109-
* for (i = container.Begin (); i != container.End (); ++i)
110-
* {
108+
* for (auto i = container.Begin(); i != container.End(); ++i)
109+
* {
111110
* std::pair<Ptr<Ipv6>, uint32_t> pair = *i;
112-
* method (pair.first, pair.second); // use the pair
113-
* }
111+
* method(pair.first, pair.second); // use the pair
112+
* }
114113
* @endcode
115114
*
116115
* @returns an iterator which refers to the first pair in the container.
@@ -127,12 +126,11 @@ class Ipv6InterfaceContainer
127126
* for-loop to run through the Nodes
128127
*
129128
* @code
130-
* NodeContainer::Iterator i;
131-
* for (i = container.Begin (); i != container.End (); ++i)
132-
* {
129+
* for (auto i = container.Begin(); i != container.End(); ++i)
130+
* {
133131
* std::pair<Ptr<Ipv6>, uint32_t> pair = *i;
134-
* method (pair.first, pair.second); // use the pair
135-
* }
132+
* method(pair.first, pair.second); // use the pair
133+
* }
136134
* @endcode
137135
*
138136
* @returns an iterator which indicates an ending condition for a loop.

src/lte/doc/source/lte-user.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,8 +1292,7 @@ within the container ``devs``::
12921292

12931293
std::vector<uint8_t> measIdList;
12941294

1295-
NetDeviceContainer::Iterator it;
1296-
for (it = devs.Begin(); it != devs.End(); it++)
1295+
for (auto it = devs.Begin(); it != devs.End(); it++)
12971296
{
12981297
Ptr<NetDevice> dev = *it;
12991298
Ptr<LteEnbNetDevice> enbDev = dev->GetObject<LteEnbNetDevice>();

src/network/helper/application-container.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,10 @@ class ApplicationContainer
6868
* for-loop to run through the Applications
6969
*
7070
* @code
71-
* ApplicationContainer::Iterator i;
72-
* for (i = container.Begin (); i != container.End (); ++i)
73-
* {
74-
* (*i)->method (); // some Application method
75-
* }
71+
* for (auto i = container.Begin(); i != container.End(); ++i)
72+
* {
73+
* (*i)->method(); // some Application method
74+
* }
7675
* @endcode
7776
*
7877
* @returns an iterator which refers to the first Application in the container.
@@ -89,11 +88,10 @@ class ApplicationContainer
8988
* for-loop to run through the Applications
9089
*
9190
* @code
92-
* ApplicationContainer::Iterator i;
93-
* for (i = container.Begin (); i != container.End (); ++i)
94-
* {
95-
* (*i)->method (); // some Application method
96-
* }
91+
* for (auto i = container.Begin(); i != container.End(); ++i)
92+
* {
93+
* (*i)->method(); // some Application method
94+
* }
9795
* @endcode
9896
*
9997
* @returns an iterator which indicates an ending condition for a loop.

src/network/helper/net-device-container.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,10 @@ class NetDeviceContainer
8585
* for-loop to run through the NetDevices
8686
*
8787
* @code
88-
* NetDeviceContainer::Iterator i;
89-
* for (i = container.Begin (); i != container.End (); ++i)
90-
* {
91-
* (*i)->method (); // some NetDevice method
92-
* }
88+
* for (auto i = container.Begin(); i != container.End(); ++i)
89+
* {
90+
* (*i)->method(); // some NetDevice method
91+
* }
9392
* @endcode
9493
*
9594
* @returns an iterator which refers to the first NetDevice in the container.
@@ -106,11 +105,10 @@ class NetDeviceContainer
106105
* for-loop to run through the NetDevices
107106
*
108107
* @code
109-
* NetDeviceContainer::Iterator i;
110-
* for (i = container.Begin (); i != container.End (); ++i)
111-
* {
112-
* (*i)->method (); // some NetDevice method
113-
* }
108+
* for (auto i = container.Begin(); i != container.End(); ++i)
109+
* {
110+
* (*i)->method(); // some NetDevice method
111+
* }
114112
* @endcode
115113
*
116114
* @returns an iterator which indicates an ending condition for a loop.

0 commit comments

Comments
 (0)