From 1f438ce6f4ed30e2c39c96622e282481627d3252 Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Mon, 18 Sep 2023 00:36:46 +0100 Subject: [PATCH] Fix clang-tidy modernize-use-auto warnings --- .../three-gpp-v2v-channel-example.cc | 2 +- examples/energy/energy-model-example.cc | 4 +- .../energy-model-with-harvesting-example.cc | 4 +- examples/ipv6/radvd-two-prefix.cc | 6 +- ...global-routing-multi-switch-plus-router.cc | 4 +- examples/tcp/tcp-pacing.cc | 6 +- examples/wireless/wifi-hidden-terminal.cc | 4 +- .../wifi-power-adaptation-distance.cc | 4 +- .../wifi-power-adaptation-interference.cc | 8 +- examples/wireless/wifi-sleep.cc | 2 +- src/aodv/helper/aodv-helper.cc | 2 +- src/aodv/model/aodv-id-cache.cc | 2 +- src/aodv/model/aodv-neighbor.cc | 12 +- src/aodv/model/aodv-packet.cc | 12 +- src/aodv/model/aodv-routing-protocol.cc | 57 ++-- src/aodv/model/aodv-rqueue.cc | 10 +- src/aodv/model/aodv-rtable.cc | 55 ++-- src/aodv/test/aodv-test-suite.cc | 4 +- src/applications/helper/bulk-send-helper.cc | 2 +- src/applications/helper/on-off-helper.cc | 4 +- src/applications/helper/packet-sink-helper.cc | 2 +- .../helper/three-gpp-http-helper.cc | 4 +- .../helper/udp-client-server-helper.cc | 6 +- src/applications/helper/udp-echo-helper.cc | 4 +- .../model/three-gpp-http-server.cc | 39 +-- .../model/three-gpp-http-variables.cc | 2 +- src/bridge/helper/bridge-helper.cc | 2 +- src/bridge/model/bridge-channel.cc | 12 +- src/bridge/model/bridge-net-device.cc | 14 +- src/brite/helper/brite-topology-helper.cc | 15 +- .../outdoor-group-mobility-example.cc | 2 +- .../examples/outdoor-random-walk-example.cc | 2 +- src/buildings/helper/building-container.cc | 4 +- .../helper/building-position-allocator.cc | 9 +- src/buildings/helper/buildings-helper.cc | 2 +- src/buildings/model/building-list.cc | 2 +- .../buildings-channel-condition-model.cc | 2 +- .../model/buildings-propagation-loss-model.cc | 5 +- src/buildings/model/mobility-building-info.cc | 2 +- .../random-walk-2d-outdoor-mobility-model.cc | 2 +- .../test/building-position-allocator-test.cc | 8 +- .../helper/click-internet-stack-helper.cc | 22 +- src/click/model/ipv4-click-routing.cc | 9 +- src/click/model/ipv4-l3-click-protocol.cc | 27 +- src/config-store/model/attribute-iterator.cc | 5 +- src/config-store/model/model-node-creator.cc | 14 +- .../model/model-typeid-creator.cc | 6 +- src/config-store/model/raw-text-config.cc | 2 +- src/config-store/model/xml-config.cc | 2 +- src/core/examples/hash-example.cc | 2 +- .../examples/main-random-variable-stream.cc | 2 +- src/core/helper/event-garbage-collector.cc | 2 +- src/core/model/attribute-construction-list.cc | 4 +- src/core/model/attribute.cc | 2 +- src/core/model/calendar-scheduler.cc | 20 +- src/core/model/callback.h | 2 +- src/core/model/config.cc | 21 +- src/core/model/default-simulator-impl.cc | 5 +- src/core/model/double.cc | 6 +- src/core/model/enum.cc | 10 +- src/core/model/global-value.cc | 8 +- src/core/model/int64x64.cc | 2 +- src/core/model/integer.cc | 6 +- src/core/model/list-scheduler.cc | 4 +- src/core/model/log.cc | 8 +- src/core/model/map-scheduler.cc | 6 +- src/core/model/names.cc | 21 +- src/core/model/nstime.h | 2 +- src/core/model/object-base.cc | 4 +- src/core/model/object-factory.cc | 6 +- src/core/model/object-map.h | 6 +- src/core/model/object-ptr-container.cc | 4 +- src/core/model/object-ptr-container.h | 4 +- src/core/model/object-vector.h | 6 +- src/core/model/object.cc | 3 +- src/core/model/pointer.h | 6 +- src/core/model/realtime-simulator-impl.cc | 5 +- src/core/model/system-path.cc | 4 +- src/core/model/test.cc | 17 +- src/core/model/time.cc | 16 +- src/core/model/timer-impl.h | 12 +- src/core/model/traced-callback.h | 7 +- src/core/model/tuple.h | 6 +- src/core/model/type-id.cc | 16 +- src/core/model/uinteger.cc | 6 +- src/core/model/wall-clock-synchronizer.cc | 2 +- src/core/test/global-value-test-suite.cc | 2 +- src/core/test/int64x64-test-suite.cc | 12 +- src/csma/examples/csma-ping.cc | 2 +- src/csma/examples/csma-raw-ip-socket.cc | 2 +- src/csma/helper/csma-helper.cc | 4 +- src/csma/model/backoff.cc | 2 +- src/csma/model/csma-channel.cc | 15 +- src/dsdv/model/dsdv-packet-queue.cc | 12 +- src/dsdv/model/dsdv-routing-protocol.cc | 65 ++--- src/dsdv/model/dsdv-rtable.cc | 48 ++-- src/dsr/helper/dsr-main-helper.cc | 2 +- src/dsr/model/dsr-errorbuff.cc | 20 +- src/dsr/model/dsr-gratuitous-reply-table.cc | 2 +- src/dsr/model/dsr-maintain-buff.cc | 28 +- src/dsr/model/dsr-network-queue.cc | 13 +- src/dsr/model/dsr-option-header.cc | 21 +- src/dsr/model/dsr-options.cc | 39 ++- src/dsr/model/dsr-passive-buff.cc | 20 +- src/dsr/model/dsr-rcache.cc | 128 ++++----- src/dsr/model/dsr-rcache.h | 4 +- src/dsr/model/dsr-routing.cc | 73 ++--- src/dsr/model/dsr-rreq-table.cc | 23 +- src/dsr/model/dsr-rsendbuff.cc | 17 +- src/dsr/test/dsr-test-suite.cc | 10 +- .../helper/energy-harvester-container.cc | 10 +- src/energy/helper/energy-harvester-helper.cc | 3 +- src/energy/helper/energy-model-helper.cc | 6 +- src/energy/helper/energy-source-container.cc | 6 +- .../helper/generic-battery-model-helper.cc | 8 +- .../model/device-energy-model-container.cc | 2 +- src/energy/model/energy-source.cc | 3 +- src/fd-net-device/examples/fd-emu-onoff.cc | 2 +- src/fd-net-device/examples/fd-emu-ping.cc | 2 +- src/fd-net-device/examples/fd-emu-send.cc | 8 +- src/fd-net-device/examples/fd-emu-tc.cc | 4 +- .../helper/fd-net-device-helper.cc | 2 +- src/fd-net-device/model/fd-net-device.cc | 6 +- .../helper/flow-monitor-helper.cc | 4 +- src/flow-monitor/model/flow-monitor.cc | 24 +- src/flow-monitor/model/flow-probe.cc | 2 +- .../model/ipv4-flow-classifier.cc | 26 +- .../model/ipv6-flow-classifier.cc | 26 +- src/internet-apps/examples/ping-example.cc | 10 +- src/internet-apps/helper/dhcp-helper.cc | 8 +- src/internet-apps/helper/ping-helper.cc | 2 +- src/internet-apps/helper/ping6-helper.cc | 2 +- src/internet-apps/helper/radvd-helper.cc | 3 +- src/internet-apps/helper/v4ping-helper.cc | 2 +- .../helper/v4traceroute-helper.cc | 2 +- src/internet-apps/model/dhcp-header.cc | 2 +- src/internet-apps/model/dhcp-server.cc | 7 +- src/internet-apps/model/ping.cc | 9 +- src/internet-apps/model/ping6.cc | 2 +- src/internet-apps/model/radvd-interface.cc | 2 +- src/internet-apps/model/radvd.cc | 19 +- src/internet-apps/model/v4ping.cc | 6 +- src/internet-apps/model/v4traceroute.cc | 4 +- src/internet-apps/test/ping-test.cc | 46 ++- src/internet/helper/internet-stack-helper.cc | 20 +- src/internet/helper/internet-trace-helper.cc | 24 +- .../helper/ipv4-interface-container.cc | 4 +- .../helper/ipv4-list-routing-helper.cc | 11 +- .../helper/ipv4-static-routing-helper.cc | 2 +- .../helper/ipv6-interface-container.cc | 3 +- .../helper/ipv6-list-routing-helper.cc | 11 +- .../helper/ipv6-static-routing-helper.cc | 2 +- src/internet/helper/rip-helper.cc | 12 +- src/internet/helper/ripng-helper.cc | 12 +- src/internet/model/arp-cache.cc | 16 +- src/internet/model/arp-l3-protocol.cc | 4 +- src/internet/model/candidate-queue.cc | 12 +- .../model/global-route-manager-impl.cc | 53 ++-- src/internet/model/global-router-interface.cc | 50 ++-- src/internet/model/icmpv6-header.cc | 12 +- src/internet/model/icmpv6-l4-protocol.cc | 24 +- src/internet/model/ipv4-address-generator.cc | 18 +- src/internet/model/ipv4-end-point-demux.cc | 24 +- src/internet/model/ipv4-global-routing.cc | 35 ++- src/internet/model/ipv4-interface.cc | 10 +- src/internet/model/ipv4-l3-protocol.cc | 74 ++--- src/internet/model/ipv4-list-routing.cc | 35 +-- src/internet/model/ipv4-raw-socket-impl.cc | 2 +- src/internet/model/ipv4-route.cc | 3 +- src/internet/model/ipv4-static-routing.cc | 41 ++- src/internet/model/ipv6-address-generator.cc | 10 +- src/internet/model/ipv6-end-point-demux.cc | 22 +- src/internet/model/ipv6-extension-demux.cc | 4 +- src/internet/model/ipv6-extension-header.cc | 12 +- src/internet/model/ipv6-extension.cc | 55 ++-- src/internet/model/ipv6-interface.cc | 19 +- src/internet/model/ipv6-l3-protocol.cc | 66 ++--- src/internet/model/ipv6-list-routing.cc | 38 +-- src/internet/model/ipv6-option-demux.cc | 4 +- src/internet/model/ipv6-pmtu-cache.cc | 2 +- src/internet/model/ipv6-raw-socket-impl.cc | 2 +- src/internet/model/ipv6-route.cc | 3 +- src/internet/model/ipv6-static-routing.cc | 45 ++- src/internet/model/ndisc-cache.cc | 12 +- src/internet/model/rip-header.cc | 6 +- src/internet/model/rip.cc | 67 +++-- src/internet/model/ripng-header.cc | 6 +- src/internet/model/ripng.cc | 82 +++--- src/internet/model/tcp-header.cc | 19 +- src/internet/model/tcp-htcp.cc | 2 +- src/internet/model/tcp-hybla.cc | 4 +- src/internet/model/tcp-ledbat.cc | 2 +- src/internet/model/tcp-option-sack.cc | 10 +- src/internet/model/tcp-rx-buffer.cc | 9 +- src/internet/model/tcp-socket-base.cc | 10 +- src/internet/model/tcp-tx-buffer.cc | 36 +-- src/internet/model/tcp-yeah.cc | 2 +- src/internet/model/udp-l4-protocol.cc | 6 +- .../global-route-manager-impl-test-suite.cc | 117 ++++---- .../test/ipv4-global-routing-test-suite.cc | 4 +- src/internet/test/ipv4-rip-test.cc | 2 +- src/internet/test/ipv6-ripng-test.cc | 2 +- .../test/tcp-advertised-window-test.cc | 2 +- src/internet/test/tcp-bytes-in-flight-test.cc | 4 +- src/internet/test/tcp-fast-retr-test.cc | 2 +- src/internet/test/tcp-rate-ops-test.cc | 2 +- src/internet/test/tcp-rtt-estimation.cc | 4 +- src/internet/test/tcp-rx-buffer-test.cc | 3 +- src/internet/test/tcp-test.cc | 2 +- src/lr-wpan/examples/lr-wpan-bootstrap.cc | 4 +- src/lr-wpan/helper/lr-wpan-helper.cc | 8 +- .../model/lr-wpan-interference-helper.cc | 3 +- src/lr-wpan/model/lr-wpan-mac-trailer.cc | 4 +- src/lr-wpan/model/lr-wpan-mac.cc | 12 +- src/lte/examples/lena-cc-helper.cc | 4 +- src/lte/examples/lena-deactivate-bearer.cc | 2 +- src/lte/examples/lena-distributed-ffr.cc | 4 +- src/lte/examples/lena-dual-stripe.cc | 10 +- src/lte/examples/lena-frequency-reuse.cc | 4 +- src/lte/examples/lena-radio-link-failure.cc | 4 +- .../helper/lte-global-pathloss-database.cc | 13 +- src/lte/helper/lte-helper.cc | 48 ++-- src/lte/helper/no-backhaul-epc-helper.cc | 2 +- .../helper/radio-bearer-stats-calculator.cc | 42 ++- .../helper/radio-bearer-stats-connector.cc | 4 +- .../helper/radio-environment-map-helper.cc | 4 +- .../model/a2-a4-rsrq-handover-algorithm.cc | 18 +- src/lte/model/a3-rsrp-handover-algorithm.cc | 3 +- src/lte/model/cqa-ff-mac-scheduler.cc | 267 +++++++----------- src/lte/model/epc-enb-application.cc | 24 +- src/lte/model/epc-mme-application.cc | 22 +- src/lte/model/epc-pgw-application.cc | 16 +- src/lte/model/epc-sgw-application.cc | 6 +- src/lte/model/epc-tft-classifier.cc | 4 +- src/lte/model/epc-tft.cc | 4 +- src/lte/model/epc-ue-nas.cc | 5 +- src/lte/model/epc-x2-header.cc | 3 +- src/lte/model/fdbet-ff-mac-scheduler.cc | 224 ++++++--------- src/lte/model/fdmt-ff-mac-scheduler.cc | 194 +++++-------- src/lte/model/fdtbfq-ff-mac-scheduler.cc | 221 ++++++--------- src/lte/model/lte-amc.cc | 5 +- src/lte/model/lte-anr.cc | 10 +- src/lte/model/lte-chunk-processor.cc | 4 +- src/lte/model/lte-common.cc | 4 +- .../lte-enb-component-carrier-manager.cc | 6 +- src/lte/model/lte-enb-mac.cc | 62 ++-- src/lte/model/lte-enb-phy.cc | 43 ++- src/lte/model/lte-enb-rrc.cc | 73 ++--- .../model/lte-ffr-distributed-algorithm.cc | 55 ++-- src/lte/model/lte-ffr-enhanced-algorithm.cc | 32 +-- src/lte/model/lte-ffr-soft-algorithm.cc | 8 +- src/lte/model/lte-fr-soft-algorithm.cc | 8 +- src/lte/model/lte-fr-strict-algorithm.cc | 8 +- src/lte/model/lte-harq-phy.cc | 15 +- src/lte/model/lte-interference.cc | 39 +-- src/lte/model/lte-mi-error-model.cc | 2 +- src/lte/model/lte-rlc-am-header.cc | 15 +- src/lte/model/lte-rlc-am.cc | 28 +- src/lte/model/lte-rlc-header.cc | 8 +- src/lte/model/lte-rlc-um.cc | 30 +- src/lte/model/lte-rrc-header.cc | 73 ++--- src/lte/model/lte-rrc-protocol-ideal.cc | 18 +- src/lte/model/lte-rrc-protocol-real.cc | 21 +- src/lte/model/lte-spectrum-phy.cc | 22 +- src/lte/model/lte-spectrum-value-helper.cc | 12 +- .../model/lte-ue-component-carrier-manager.cc | 3 +- src/lte/model/lte-ue-mac.cc | 34 +-- src/lte/model/lte-ue-net-device.cc | 3 +- src/lte/model/lte-ue-phy.cc | 37 +-- src/lte/model/lte-ue-rrc.cc | 200 +++++-------- .../model/no-op-component-carrier-manager.cc | 7 +- src/lte/model/pf-ff-mac-scheduler.cc | 213 ++++++-------- src/lte/model/pss-ff-mac-scheduler.cc | 256 +++++++---------- src/lte/model/rr-ff-mac-scheduler.cc | 156 ++++------ .../simple-ue-component-carrier-manager.cc | 41 ++- src/lte/model/tdbet-ff-mac-scheduler.cc | 204 +++++-------- src/lte/model/tdmt-ff-mac-scheduler.cc | 190 +++++-------- src/lte/model/tdtbfq-ff-mac-scheduler.cc | 201 +++++-------- src/lte/model/tta-ff-mac-scheduler.cc | 197 +++++-------- src/lte/test/epc-test-gtpu.cc | 2 +- src/lte/test/epc-test-s1u-downlink.cc | 11 +- src/lte/test/epc-test-s1u-uplink.cc | 11 +- src/lte/test/lte-ffr-simple.cc | 7 +- src/lte/test/lte-simple-helper.cc | 7 +- src/lte/test/lte-test-carrier-aggregation.cc | 7 +- src/lte/test/lte-test-cell-selection.cc | 2 +- src/lte/test/lte-test-cqa-ff-mac-scheduler.cc | 2 +- src/lte/test/lte-test-deactivate-bearer.cc | 2 +- src/lte/test/lte-test-entities.cc | 9 +- .../test/lte-test-fdbet-ff-mac-scheduler.cc | 2 +- .../test/lte-test-fdtbfq-ff-mac-scheduler.cc | 2 +- src/lte/test/lte-test-frequency-reuse.cc | 14 +- src/lte/test/lte-test-ipv6-routing.cc | 7 +- src/lte/test/lte-test-pf-ff-mac-scheduler.cc | 2 +- src/lte/test/lte-test-phy-error-model.cc | 4 +- src/lte/test/lte-test-pss-ff-mac-scheduler.cc | 2 +- src/lte/test/lte-test-radio-link-failure.cc | 16 +- .../test/lte-test-tdbet-ff-mac-scheduler.cc | 2 +- .../test/lte-test-tdtbfq-ff-mac-scheduler.cc | 2 +- src/lte/test/lte-test-ue-measurements.cc | 20 +- src/lte/test/test-asn1-encoding.cc | 20 +- src/lte/test/test-lte-epc-e2e-data.cc | 13 +- src/lte/test/test-lte-rlc-header.cc | 6 +- src/lte/test/test-lte-rrc.cc | 12 +- src/lte/test/test-lte-x2-handover-measures.cc | 14 +- src/lte/test/test-lte-x2-handover.cc | 19 +- src/mesh/examples/mesh.cc | 2 +- src/mesh/helper/dot11s/dot11s-installer.cc | 4 +- src/mesh/helper/mesh-helper.cc | 6 +- src/mesh/model/dot11s/hwmp-protocol-mac.cc | 38 +-- src/mesh/model/dot11s/hwmp-protocol.cc | 64 ++--- src/mesh/model/dot11s/hwmp-rtable.cc | 19 +- .../model/dot11s/ie-dot11s-beacon-timing.cc | 18 +- src/mesh/model/dot11s/ie-dot11s-perr.cc | 4 +- src/mesh/model/dot11s/ie-dot11s-preq.cc | 16 +- .../model/dot11s/peer-management-protocol.cc | 66 ++--- src/mesh/model/flame/flame-protocol.cc | 9 +- src/mesh/model/flame/flame-rtable.cc | 4 +- .../model/mesh-information-element-vector.cc | 16 +- src/mesh/model/mesh-point-device.cc | 7 +- src/mesh/model/mesh-wifi-interface-mac.cc | 10 +- src/mesh/test/dot11s/dot11s-test-suite.cc | 3 +- src/mobility/examples/main-grid-topology.cc | 2 +- src/mobility/helper/group-mobility-helper.cc | 4 +- src/mobility/helper/mobility-helper.cc | 6 +- ...ate-random-waypoint-mobility-model-test.cc | 10 +- .../test/waypoint-mobility-model-test.cc | 8 +- src/mpi/model/distributed-simulator-impl.cc | 7 +- .../granted-time-window-mpi-interface.cc | 18 +- src/mpi/model/null-message-mpi-interface.cc | 32 +-- src/mpi/model/null-message-simulator-impl.cc | 7 +- .../model/remote-channel-bundle-manager.cc | 11 +- src/netanim/examples/uan-animation.cc | 2 +- src/netanim/model/animation-interface.cc | 95 +++---- src/network/helper/application-container.cc | 8 +- src/network/helper/net-device-container.cc | 2 +- src/network/helper/node-container.cc | 4 +- src/network/helper/packet-socket-helper.cc | 2 +- .../helper/simple-net-device-helper.cc | 2 +- src/network/helper/trace-helper.cc | 12 +- src/network/model/buffer.cc | 12 +- src/network/model/byte-tag-list.cc | 12 +- src/network/model/channel-list.cc | 2 +- src/network/model/node-list.cc | 2 +- src/network/model/node.cc | 30 +- src/network/model/packet-metadata.cc | 8 +- src/network/model/packet-tag-list.cc | 2 +- src/network/model/packet.cc | 10 +- src/network/model/tag-buffer.cc | 4 +- src/network/test/buffer-test.cc | 2 +- src/network/test/packet-metadata-test.cc | 12 +- src/network/test/packet-test-suite.cc | 6 +- src/network/utils/error-channel.cc | 4 +- src/network/utils/error-model.cc | 4 +- src/network/utils/ipv4-address.cc | 8 +- src/network/utils/mac16-address.cc | 2 +- src/network/utils/mac48-address.cc | 6 +- src/network/utils/output-stream-wrapper.cc | 2 +- src/network/utils/packet-burst.cc | 9 +- src/network/utils/packet-socket.cc | 2 +- src/network/utils/packetbb.cc | 70 +++-- src/network/utils/pcap-file.cc | 4 +- src/network/utils/simple-channel.cc | 7 +- .../examples/nms-p2p-nix.cc | 6 +- .../model/nix-vector-routing.cc | 31 +- src/olsr/helper/olsr-helper.cc | 6 +- src/olsr/model/olsr-header.cc | 18 +- src/olsr/model/olsr-header.h | 4 +- src/olsr/model/olsr-routing-protocol.cc | 195 +++++-------- src/olsr/model/olsr-state.cc | 74 +++-- src/olsr/test/hello-regression-test.cc | 6 +- src/openflow/model/openflow-interface.cc | 18 +- .../model/openflow-switch-net-device.cc | 2 +- .../model/point-to-point-dumbbell.cc | 4 +- .../examples/main-propagation-loss.cc | 2 +- src/propagation/model/propagation-cache.h | 2 +- .../model/propagation-loss-model.cc | 6 +- src/sixlowpan/helper/sixlowpan-helper.cc | 2 +- src/sixlowpan/model/sixlowpan-net-device.cc | 33 +-- ...ideal-phy-matrix-propagation-loss-model.cc | 9 +- .../adhoc-aloha-noack-ideal-phy-helper.cc | 2 +- .../helper/spectrum-analyzer-helper.cc | 6 +- .../helper/tv-spectrum-transmitter-helper.cc | 10 +- .../helper/waveform-generator-helper.cc | 2 +- .../constant-spectrum-propagation-loss.cc | 4 +- .../model/friis-spectrum-propagation-loss.cc | 4 +- .../model/multi-model-spectrum-channel.cc | 32 +-- .../model/multi-model-spectrum-channel.h | 2 +- .../model/single-model-spectrum-channel.cc | 4 +- src/spectrum/model/spectrum-converter.cc | 13 +- src/spectrum/model/spectrum-error-model.cc | 4 +- src/spectrum/model/spectrum-model.cc | 7 +- src/spectrum/model/spectrum-value.cc | 48 ++-- src/spectrum/model/trace-fading-loss-model.cc | 15 +- src/spectrum/model/tv-spectrum-transmitter.cc | 2 +- .../model/wifi-spectrum-value-helper.cc | 52 ++-- src/spectrum/test/spectrum-test.h | 8 +- .../test/tv-spectrum-transmitter-test.cc | 6 +- src/stats/helper/file-helper.cc | 3 +- src/stats/helper/gnuplot-helper.cc | 3 +- src/stats/model/gnuplot.cc | 14 +- src/stats/model/histogram.cc | 2 +- src/stats/model/omnet-data-output.cc | 9 +- src/stats/model/sqlite-data-output.cc | 5 +- src/tap-bridge/model/tap-bridge.cc | 2 +- src/test/csma-system-test-suite.cc | 4 +- .../ns3tc/pfifo-fast-queue-disc-test-suite.cc | 2 +- src/test/ns3tcp/ns3tcp-loss-test-suite.cc | 2 +- src/test/ns3tcp/ns3tcp-state-test-suite.cc | 2 +- .../examples/topology-example-sim.cc | 8 +- .../helper/queue-disc-container.cc | 2 +- .../helper/traffic-control-helper.cc | 16 +- src/traffic-control/model/pie-queue-disc.cc | 2 +- src/traffic-control/model/queue-disc.cc | 28 +- src/traffic-control/model/red-queue-disc.cc | 2 +- .../model/traffic-control-layer.cc | 12 +- src/uan/examples/uan-6lowpan-example.cc | 10 +- src/uan/examples/uan-cw-example.cc | 2 +- src/uan/examples/uan-ipv4-example.cc | 10 +- src/uan/examples/uan-ipv6-example.cc | 10 +- src/uan/examples/uan-raw-example.cc | 10 +- src/uan/helper/uan-helper.cc | 8 +- src/uan/model/uan-channel.cc | 6 +- src/uan/model/uan-header-rc.cc | 4 +- src/uan/model/uan-mac-cw.cc | 2 +- src/uan/model/uan-mac-rc-gw.cc | 20 +- src/uan/model/uan-mac-rc.cc | 18 +- src/uan/model/uan-phy-dual.cc | 2 +- src/uan/model/uan-phy-gen.cc | 24 +- src/uan/model/uan-prop-model.cc | 2 +- src/uan/model/uan-transducer-hd.cc | 12 +- src/uan/model/uan-tx-mode.cc | 6 +- src/visualizer/model/pyviz.cc | 43 +-- src/wifi/examples/wifi-manager-example.cc | 4 +- src/wifi/helper/athstats-helper.cc | 4 +- src/wifi/helper/wifi-helper.cc | 4 +- src/wifi/helper/yans-wifi-helper.cc | 4 +- src/wifi/model/channel-access-manager.cc | 10 +- src/wifi/model/ctrl-headers.cc | 2 +- src/wifi/model/edca-parameter-set.cc | 16 +- .../model/eht/eht-frame-exchange-manager.cc | 3 +- .../model/eht/tid-to-link-mapping-element.cc | 6 +- src/wifi/model/frame-exchange-manager.cc | 16 +- .../model/he/he-frame-exchange-manager.cc | 48 ++-- src/wifi/model/he/he-phy.cc | 6 +- .../model/ht/ht-frame-exchange-manager.cc | 7 +- src/wifi/model/interference-helper.cc | 4 +- src/wifi/model/mac-rx-middle.cc | 6 +- src/wifi/model/mac-tx-middle.cc | 13 +- src/wifi/model/mgt-headers.cc | 2 +- src/wifi/model/non-ht/dsss-phy.cc | 2 +- .../model/rate-control/aarf-wifi-manager.cc | 10 +- .../model/rate-control/aarfcd-wifi-manager.cc | 14 +- .../model/rate-control/amrr-wifi-manager.cc | 12 +- .../model/rate-control/aparf-wifi-manager.cc | 17 +- .../model/rate-control/arf-wifi-manager.cc | 10 +- .../model/rate-control/cara-wifi-manager.cc | 12 +- .../constant-rate-wifi-manager.cc | 2 +- .../model/rate-control/ideal-wifi-manager.cc | 14 +- .../rate-control/minstrel-ht-wifi-manager.cc | 20 +- .../rate-control/minstrel-wifi-manager.cc | 18 +- .../model/rate-control/onoe-wifi-manager.cc | 18 +- .../model/rate-control/parf-wifi-manager.cc | 17 +- .../model/rate-control/rraa-wifi-manager.cc | 18 +- .../model/rate-control/rrpaa-wifi-manager.cc | 25 +- .../thompson-sampling-wifi-manager.cc | 2 +- src/wifi/model/supported-rates.cc | 6 +- .../model/wifi-default-protection-manager.cc | 3 +- src/wifi/model/wifi-mac-header.cc | 2 +- src/wifi/model/wifi-mac-queue-container.cc | 4 +- src/wifi/model/wifi-mac-queue.cc | 2 +- src/wifi/model/wifi-mode.cc | 9 +- src/wifi/model/wifi-remote-station-manager.cc | 13 +- src/wifi/model/yans-wifi-channel.cc | 2 +- src/wifi/test/block-ack-test-suite.cc | 2 +- src/wifi/test/channel-access-manager-test.cc | 2 +- src/wifi/test/spectrum-wifi-phy-test.cc | 2 +- src/wifi/test/wifi-primary-channels-test.cc | 4 +- src/wifi/test/wifi-test.cc | 4 +- src/wimax/examples/wimax-ipv4.cc | 10 +- src/wimax/helper/wimax-helper.cc | 10 +- src/wimax/model/bandwidth-manager.cc | 12 +- src/wimax/model/bs-link-manager.cc | 2 +- src/wimax/model/bs-net-device.cc | 17 +- src/wimax/model/bs-scheduler-rtps.cc | 20 +- src/wimax/model/bs-scheduler-simple.cc | 16 +- src/wimax/model/bs-service-flow-manager.cc | 2 +- src/wimax/model/bs-uplink-scheduler-mbqos.cc | 41 +-- src/wimax/model/bs-uplink-scheduler-rtps.cc | 21 +- src/wimax/model/bs-uplink-scheduler-simple.cc | 11 +- src/wimax/model/burst-profile-manager.cc | 16 +- src/wimax/model/connection-manager.cc | 27 +- src/wimax/model/cs-parameters.cc | 2 +- src/wimax/model/ipcs-classifier-record.cc | 65 ++--- src/wimax/model/service-flow-manager.cc | 27 +- src/wimax/model/service-flow.cc | 2 +- src/wimax/model/simple-ofdm-wimax-channel.cc | 10 +- src/wimax/model/simple-ofdm-wimax-phy.cc | 8 +- .../model/snr-to-block-error-rate-manager.cc | 45 ++- src/wimax/model/ss-manager.cc | 25 +- src/wimax/model/ss-net-device.cc | 18 +- src/wimax/model/ss-record.cc | 20 +- src/wimax/model/ss-scheduler.cc | 12 +- src/wimax/model/ss-service-flow-manager.cc | 2 +- src/wimax/model/wimax-mac-queue.cc | 20 +- src/wimax/model/wimax-net-device.cc | 2 +- src/wimax/model/wimax-tlv.cc | 55 ++-- src/wimax/test/wimax-fragmentation-test.cc | 8 +- src/wimax/test/wimax-service-flow-test.cc | 4 +- src/wimax/test/wimax-tlv-test.cc | 6 +- utils/bench-scheduler.cc | 2 +- utils/print-introspected-doxygen.cc | 12 +- 512 files changed, 3616 insertions(+), 5523 deletions(-) diff --git a/examples/channel-models/three-gpp-v2v-channel-example.cc b/examples/channel-models/three-gpp-v2v-channel-example.cc index 346a69327..682cdb8fe 100644 --- a/examples/channel-models/three-gpp-v2v-channel-example.cc +++ b/examples/channel-models/three-gpp-v2v-channel-example.cc @@ -161,7 +161,7 @@ PrintGnuplottableBuildingListToFile(std::string filename) return; } uint32_t index = 0; - for (BuildingList::Iterator it = BuildingList::Begin(); it != BuildingList::End(); ++it) + for (auto it = BuildingList::Begin(); it != BuildingList::End(); ++it) { ++index; Box box = (*it)->GetBoundaries(); diff --git a/examples/energy/energy-model-example.cc b/examples/energy/energy-model-example.cc index ab42be174..a59b043c5 100644 --- a/examples/energy/energy-model-example.cc +++ b/examples/energy/energy-model-example.cc @@ -289,9 +289,7 @@ main(int argc, char* argv[]) Simulator::Stop(Seconds(10.0)); Simulator::Run(); - for (DeviceEnergyModelContainer::Iterator iter = deviceModels.Begin(); - iter != deviceModels.End(); - iter++) + for (auto iter = deviceModels.Begin(); iter != deviceModels.End(); iter++) { double energyConsumed = (*iter)->GetTotalEnergyConsumption(); NS_LOG_UNCOND("End of simulation (" diff --git a/examples/energy/energy-model-with-harvesting-example.cc b/examples/energy/energy-model-with-harvesting-example.cc index 99fd3ba24..4ee5639a8 100644 --- a/examples/energy/energy-model-with-harvesting-example.cc +++ b/examples/energy/energy-model-with-harvesting-example.cc @@ -354,9 +354,7 @@ main(int argc, char* argv[]) Simulator::Stop(Seconds(10.0)); Simulator::Run(); - for (DeviceEnergyModelContainer::Iterator iter = deviceModels.Begin(); - iter != deviceModels.End(); - iter++) + for (auto iter = deviceModels.Begin(); iter != deviceModels.End(); iter++) { double energyConsumed = (*iter)->GetTotalEnergyConsumption(); NS_LOG_UNCOND("End of simulation (" diff --git a/examples/ipv6/radvd-two-prefix.cc b/examples/ipv6/radvd-two-prefix.cc index d6087aebf..a9633ec1a 100644 --- a/examples/ipv6/radvd-two-prefix.cc +++ b/examples/ipv6/radvd-two-prefix.cc @@ -164,8 +164,7 @@ main(int argc, char** argv) routerInterface->SetMaxRtrAdvInterval(2000); routerInterface->SetMinRtrAdvInterval(1000); RadvdInterface::RadvdPrefixList prefixList = routerInterface->GetPrefixes(); - for (RadvdInterface::RadvdPrefixListI iter = prefixList.begin(); iter != prefixList.end(); - iter++) + for (auto iter = prefixList.begin(); iter != prefixList.end(); iter++) { (*iter)->SetPreferredLifeTime(3); (*iter)->SetValidLifeTime(5); @@ -179,8 +178,7 @@ main(int argc, char** argv) routerInterface->SetMaxRtrAdvInterval(2000); routerInterface->SetMinRtrAdvInterval(1000); prefixList = routerInterface->GetPrefixes(); - for (RadvdInterface::RadvdPrefixListI iter = prefixList.begin(); iter != prefixList.end(); - iter++) + for (auto iter = prefixList.begin(); iter != prefixList.end(); iter++) { (*iter)->SetPreferredLifeTime(3); (*iter)->SetValidLifeTime(5); diff --git a/examples/routing/global-routing-multi-switch-plus-router.cc b/examples/routing/global-routing-multi-switch-plus-router.cc index 882f37dd5..1b0fdbdc6 100644 --- a/examples/routing/global-routing-multi-switch-plus-router.cc +++ b/examples/routing/global-routing-multi-switch-plus-router.cc @@ -350,9 +350,7 @@ main(int argc, char* argv[]) } } - for (std::vector::const_iterator ploc = pcapLocationVec.begin(); - ploc != pcapLocationVec.end(); - ++ploc) + for (auto ploc = pcapLocationVec.begin(); ploc != pcapLocationVec.end(); ++ploc) { NS_LOG_INFO("PCAP capture at: <" + *ploc + ">"); } diff --git a/examples/tcp/tcp-pacing.cc b/examples/tcp/tcp-pacing.cc index 8ad772eee..2b061654b 100644 --- a/examples/tcp/tcp-pacing.cc +++ b/examples/tcp/tcp-pacing.cc @@ -161,7 +161,7 @@ main(int argc, char* argv[]) Time simulationEndTime = Seconds(5); DataRate bottleneckBandwidth("10Mbps"); // value of x as shown in the above network topology Time bottleneckDelay = MilliSeconds(40); - DataRate regLinkBandwidth = DataRate(4 * bottleneckBandwidth.GetBitRate()); + DataRate regLinkBandwidth(4 * bottleneckBandwidth.GetBitRate()); Time regLinkDelay = MilliSeconds(5); DataRate maxPacingRate("4Gbps"); @@ -324,9 +324,7 @@ main(int argc, char* argv[]) monitor->CheckForLostPackets(); Ptr classifier = DynamicCast(flowmon.GetClassifier()); FlowMonitor::FlowStatsContainer stats = monitor->GetFlowStats(); - for (std::map::const_iterator i = stats.begin(); - i != stats.end(); - ++i) + for (auto i = stats.begin(); i != stats.end(); ++i) { Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(i->first); diff --git a/examples/wireless/wifi-hidden-terminal.cc b/examples/wireless/wifi-hidden-terminal.cc index 6adfa9249..9c7d94180 100644 --- a/examples/wireless/wifi-hidden-terminal.cc +++ b/examples/wireless/wifi-hidden-terminal.cc @@ -163,9 +163,7 @@ experiment(bool enableCtsRts, std::string wifiManager) monitor->CheckForLostPackets(); Ptr classifier = DynamicCast(flowmon.GetClassifier()); FlowMonitor::FlowStatsContainer stats = monitor->GetFlowStats(); - for (std::map::const_iterator i = stats.begin(); - i != stats.end(); - ++i) + for (auto i = stats.begin(); i != stats.end(); ++i) { // first 2 FlowIds are for ECHO apps, we don't want to display them // diff --git a/examples/wireless/wifi-power-adaptation-distance.cc b/examples/wireless/wifi-power-adaptation-distance.cc index 08e28624f..651a1dad8 100644 --- a/examples/wireless/wifi-power-adaptation-distance.cc +++ b/examples/wireless/wifi-power-adaptation-distance.cc @@ -253,7 +253,7 @@ NodeStatistics::SetupPhy(Ptr phy) txVector.SetMode(mode); txVector.SetPreambleType(WIFI_PREAMBLE_LONG); txVector.SetChannelWidth(phy->GetChannelWidth()); - DataRate dataRate = DataRate(mode.GetDataRate(phy->GetChannelWidth())); + DataRate dataRate(mode.GetDataRate(phy->GetChannelWidth())); Time time = phy->CalculateTxDuration(packetSize, txVector, phy->GetPhyBand()); NS_LOG_DEBUG(mode.GetUniqueName() << " " << time.GetSeconds() << " " << dataRate); m_timeTable.emplace_back(time, dataRate); @@ -263,7 +263,7 @@ NodeStatistics::SetupPhy(Ptr phy) Time NodeStatistics::GetCalcTxTime(DataRate rate) { - for (TxTime::const_iterator i = m_timeTable.begin(); i != m_timeTable.end(); i++) + for (auto i = m_timeTable.begin(); i != m_timeTable.end(); i++) { if (rate == i->second) { diff --git a/examples/wireless/wifi-power-adaptation-interference.cc b/examples/wireless/wifi-power-adaptation-interference.cc index 8ea2446b3..e72ac666d 100644 --- a/examples/wireless/wifi-power-adaptation-interference.cc +++ b/examples/wireless/wifi-power-adaptation-interference.cc @@ -274,7 +274,7 @@ NodeStatistics::SetupPhy(Ptr phy) txVector.SetMode(mode); txVector.SetPreambleType(WIFI_PREAMBLE_LONG); txVector.SetChannelWidth(phy->GetChannelWidth()); - DataRate dataRate = DataRate(mode.GetDataRate(phy->GetChannelWidth())); + DataRate dataRate(mode.GetDataRate(phy->GetChannelWidth())); Time time = phy->CalculateTxDuration(packetSize, txVector, phy->GetPhyBand()); NS_LOG_DEBUG(mode.GetUniqueName() << " " << time.GetSeconds() << " " << dataRate); m_timeTable.emplace_back(time, dataRate); @@ -284,7 +284,7 @@ NodeStatistics::SetupPhy(Ptr phy) Time NodeStatistics::GetCalcTxTime(DataRate rate) { - for (TxTime::const_iterator i = m_timeTable.begin(); i != m_timeTable.end(); i++) + for (auto i = m_timeTable.begin(); i != m_timeTable.end(); i++) { if (rate == i->second) { @@ -667,9 +667,7 @@ main(int argc, char* argv[]) Ptr classifier = DynamicCast(flowmon.GetClassifier()); std::map stats = monitor->GetFlowStats(); - for (std::map::const_iterator i = stats.begin(); - i != stats.end(); - ++i) + for (auto i = stats.begin(); i != stats.end(); ++i) { Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(i->first); if ((t.sourceAddress == "10.1.1.3" && t.destinationAddress == "10.1.1.1")) diff --git a/examples/wireless/wifi-sleep.cc b/examples/wireless/wifi-sleep.cc index 857ea2039..2bc04743a 100644 --- a/examples/wireless/wifi-sleep.cc +++ b/examples/wireless/wifi-sleep.cc @@ -228,7 +228,7 @@ main(int argc, char* argv[]) DoubleValue(eta)); // install an energy source on each node - for (NodeContainer::Iterator n = c.Begin(); n != c.End(); n++) + for (auto n = c.Begin(); n != c.End(); n++) { eSources.Add(basicSourceHelper.Install(*n)); diff --git a/src/aodv/helper/aodv-helper.cc b/src/aodv/helper/aodv-helper.cc index f00401333..5fd6c2cc8 100644 --- a/src/aodv/helper/aodv-helper.cc +++ b/src/aodv/helper/aodv-helper.cc @@ -59,7 +59,7 @@ AodvHelper::AssignStreams(NodeContainer c, int64_t stream) { int64_t currentStream = stream; Ptr node; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { node = (*i); Ptr ipv4 = node->GetObject(); diff --git a/src/aodv/model/aodv-id-cache.cc b/src/aodv/model/aodv-id-cache.cc index b8b9a075b..b00cacb22 100644 --- a/src/aodv/model/aodv-id-cache.cc +++ b/src/aodv/model/aodv-id-cache.cc @@ -36,7 +36,7 @@ bool IdCache::IsDuplicate(Ipv4Address addr, uint32_t id) { Purge(); - for (std::vector::const_iterator i = m_idCache.begin(); i != m_idCache.end(); ++i) + for (auto i = m_idCache.begin(); i != m_idCache.end(); ++i) { if (i->m_context == addr && i->m_id == id) { diff --git a/src/aodv/model/aodv-neighbor.cc b/src/aodv/model/aodv-neighbor.cc index caa94d63b..3d7e6b4d7 100644 --- a/src/aodv/model/aodv-neighbor.cc +++ b/src/aodv/model/aodv-neighbor.cc @@ -51,7 +51,7 @@ bool Neighbors::IsNeighbor(Ipv4Address addr) { Purge(); - for (std::vector::const_iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { if (i->m_neighborAddress == addr) { @@ -65,7 +65,7 @@ Time Neighbors::GetExpireTime(Ipv4Address addr) { Purge(); - for (std::vector::const_iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { if (i->m_neighborAddress == addr) { @@ -78,7 +78,7 @@ Neighbors::GetExpireTime(Ipv4Address addr) void Neighbors::Update(Ipv4Address addr, Time expire) { - for (std::vector::iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { if (i->m_neighborAddress == addr) { @@ -125,7 +125,7 @@ Neighbors::Purge() CloseNeighbor pred; if (!m_handleLinkFailure.IsNull()) { - for (std::vector::iterator j = m_nb.begin(); j != m_nb.end(); ++j) + for (auto j = m_nb.begin(); j != m_nb.end(); ++j) { if (pred(*j)) { @@ -162,7 +162,7 @@ Mac48Address Neighbors::LookupMacAddress(Ipv4Address addr) { Mac48Address hwaddr; - for (std::vector>::const_iterator i = m_arp.begin(); i != m_arp.end(); ++i) + for (auto i = m_arp.begin(); i != m_arp.end(); ++i) { ArpCache::Entry* entry = (*i)->Lookup(addr); if (entry != nullptr && (entry->IsAlive() || entry->IsPermanent()) && !entry->IsExpired()) @@ -179,7 +179,7 @@ Neighbors::ProcessTxError(const WifiMacHeader& hdr) { Mac48Address addr = hdr.GetAddr1(); - for (std::vector::iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { if (i->m_hardwareAddress == addr) { diff --git a/src/aodv/model/aodv-packet.cc b/src/aodv/model/aodv-packet.cc index a6741e21c..bdf7684df 100644 --- a/src/aodv/model/aodv-packet.cc +++ b/src/aodv/model/aodv-packet.cc @@ -554,8 +554,7 @@ RerrHeader::Serialize(Buffer::Iterator i) const i.WriteU8(m_flag); i.WriteU8(m_reserved); i.WriteU8(GetDestCount()); - std::map::const_iterator j; - for (j = m_unreachableDstSeqNo.begin(); j != m_unreachableDstSeqNo.end(); ++j) + for (auto j = m_unreachableDstSeqNo.begin(); j != m_unreachableDstSeqNo.end(); ++j) { WriteTo(i, (*j).first); i.WriteHtonU32((*j).second); @@ -588,8 +587,7 @@ void RerrHeader::Print(std::ostream& os) const { os << "Unreachable destination (ipv4 address, seq. number):"; - std::map::const_iterator j; - for (j = m_unreachableDstSeqNo.begin(); j != m_unreachableDstSeqNo.end(); ++j) + for (auto j = m_unreachableDstSeqNo.begin(); j != m_unreachableDstSeqNo.end(); ++j) { os << (*j).first << ", " << (*j).second; } @@ -635,7 +633,7 @@ RerrHeader::RemoveUnDestination(std::pair& un) { return false; } - std::map::iterator i = m_unreachableDstSeqNo.begin(); + auto i = m_unreachableDstSeqNo.begin(); un = *i; m_unreachableDstSeqNo.erase(i); return true; @@ -657,8 +655,8 @@ RerrHeader::operator==(const RerrHeader& o) const return false; } - std::map::const_iterator j = m_unreachableDstSeqNo.begin(); - std::map::const_iterator k = o.m_unreachableDstSeqNo.begin(); + auto j = m_unreachableDstSeqNo.begin(); + auto k = o.m_unreachableDstSeqNo.begin(); for (uint8_t i = 0; i < GetDestCount(); ++i) { if ((j->first != k->first) || (j->second != k->second)) diff --git a/src/aodv/model/aodv-routing-protocol.cc b/src/aodv/model/aodv-routing-protocol.cc index 94cb44489..b0352e413 100644 --- a/src/aodv/model/aodv-routing-protocol.cc +++ b/src/aodv/model/aodv-routing-protocol.cc @@ -362,15 +362,12 @@ void RoutingProtocol::DoDispose() { m_ipv4 = nullptr; - for (std::map, Ipv4InterfaceAddress>::iterator iter = m_socketAddresses.begin(); - iter != m_socketAddresses.end(); - iter++) + for (auto iter = m_socketAddresses.begin(); iter != m_socketAddresses.end(); iter++) { iter->first->Close(); } m_socketAddresses.clear(); - for (std::map, Ipv4InterfaceAddress>::iterator iter = - m_socketSubnetBroadcastAddresses.begin(); + for (auto iter = m_socketSubnetBroadcastAddresses.begin(); iter != m_socketSubnetBroadcastAddresses.end(); iter++) { @@ -541,9 +538,7 @@ RoutingProtocol::RouteInput(Ptr p, } // Broadcast local delivery/forwarding - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ipv4InterfaceAddress iface = j->second; if (m_ipv4->GetInterfaceForAddress(iface.GetLocal()) == iif) @@ -984,9 +979,7 @@ bool RoutingProtocol::IsMyOwnAddress(Ipv4Address src) { NS_LOG_FUNCTION(this << src); - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ipv4InterfaceAddress iface = j->second; if (src == iface.GetLocal()) @@ -1020,7 +1013,7 @@ RoutingProtocol::LoopbackRoute(const Ipv4Header& hdr, Ptr oif) const // If RouteOutput() caller specified an outgoing interface, that // further constrains the selection of source address // - std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); + auto j = m_socketAddresses.begin(); if (oif) { // Iterate to find an address on the oif device @@ -1136,9 +1129,7 @@ RoutingProtocol::SendRequest(Ipv4Address dst) rreqHeader.SetId(m_requestId); // Send RREQ as subnet directed broadcast from each interface used by aodv - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; @@ -1505,9 +1496,7 @@ RoutingProtocol::RecvRequest(Ptr p, Ipv4Address receiver, Ipv4Address sr return; } - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; @@ -1868,9 +1857,7 @@ RoutingProtocol::RecvError(Ptr p, Ipv4Address src) std::pair un; while (rerrHeader.RemoveUnDestination(un)) { - for (std::map::const_iterator i = dstWithNextHopSrc.begin(); - i != dstWithNextHopSrc.end(); - ++i) + for (auto i = dstWithNextHopSrc.begin(); i != dstWithNextHopSrc.end(); ++i) { if (i->first == un.first) { @@ -1880,8 +1867,7 @@ RoutingProtocol::RecvError(Ptr p, Ipv4Address src) } std::vector precursors; - for (std::map::const_iterator i = unreachable.begin(); - i != unreachable.end();) + for (auto i = unreachable.begin(); i != unreachable.end();) { if (!rerrHeader.AddUnDestination(i->first, i->second)) { @@ -2013,9 +1999,7 @@ RoutingProtocol::SendHello() * Hop Count 0 * Lifetime AllowedHelloLoss * HelloInterval */ - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; @@ -2087,8 +2071,7 @@ RoutingProtocol::SendRerrWhenBreaksLinkToNextHop(Ipv4Address nextHop) toNextHop.GetPrecursors(precursors); rerrHeader.AddUnDestination(nextHop, toNextHop.GetSeqNo()); m_routingTable.GetListOfDestinationWithNextHop(nextHop, unreachable); - for (std::map::const_iterator i = unreachable.begin(); - i != unreachable.end();) + for (auto i = unreachable.begin(); i != unreachable.end();) { if (!rerrHeader.AddUnDestination(i->first, i->second)) { @@ -2161,10 +2144,7 @@ RoutingProtocol::SendRerrWhenNoRouteToForward(Ipv4Address dst, } else { - for (std::map, Ipv4InterfaceAddress>::const_iterator i = - m_socketAddresses.begin(); - i != m_socketAddresses.end(); - ++i) + for (auto i = m_socketAddresses.begin(); i != m_socketAddresses.end(); ++i) { Ptr socket = i->first; Ipv4InterfaceAddress iface = i->second; @@ -2232,8 +2212,7 @@ RoutingProtocol::SendRerrMessage(Ptr packet, std::vector pr // route std::vector ifaces; RoutingTableEntry toPrecursor; - for (std::vector::const_iterator i = precursors.begin(); i != precursors.end(); - ++i) + for (auto i = precursors.begin(); i != precursors.end(); ++i) { if (m_routingTable.LookupValidRoute(*i, toPrecursor) && std::find(ifaces.begin(), ifaces.end(), toPrecursor.GetInterface()) == ifaces.end()) @@ -2242,8 +2221,7 @@ RoutingProtocol::SendRerrMessage(Ptr packet, std::vector pr } } - for (std::vector::const_iterator i = ifaces.begin(); i != ifaces.end(); - ++i) + for (auto i = ifaces.begin(); i != ifaces.end(); ++i) { Ptr socket = FindSocketWithInterfaceAddress(*i); NS_ASSERT(socket); @@ -2273,9 +2251,7 @@ Ptr RoutingProtocol::FindSocketWithInterfaceAddress(Ipv4InterfaceAddress addr) const { NS_LOG_FUNCTION(this << addr); - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; @@ -2292,8 +2268,7 @@ Ptr RoutingProtocol::FindSubnetBroadcastSocketWithInterfaceAddress(Ipv4InterfaceAddress addr) const { NS_LOG_FUNCTION(this << addr); - for (std::map, Ipv4InterfaceAddress>::const_iterator j = - m_socketSubnetBroadcastAddresses.begin(); + for (auto j = m_socketSubnetBroadcastAddresses.begin(); j != m_socketSubnetBroadcastAddresses.end(); ++j) { diff --git a/src/aodv/model/aodv-rqueue.cc b/src/aodv/model/aodv-rqueue.cc index 4b571c5de..b45625613 100644 --- a/src/aodv/model/aodv-rqueue.cc +++ b/src/aodv/model/aodv-rqueue.cc @@ -51,7 +51,7 @@ bool RequestQueue::Enqueue(QueueEntry& entry) { Purge(); - for (std::vector::const_iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if ((i->GetPacket()->GetUid() == entry.GetPacket()->GetUid()) && (i->GetIpv4Header().GetDestination() == entry.GetIpv4Header().GetDestination())) @@ -74,7 +74,7 @@ RequestQueue::DropPacketWithDst(Ipv4Address dst) { NS_LOG_FUNCTION(this << dst); Purge(); - for (std::vector::iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (i->GetIpv4Header().GetDestination() == dst) { @@ -91,7 +91,7 @@ bool RequestQueue::Dequeue(Ipv4Address dst, QueueEntry& entry) { Purge(); - for (std::vector::iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (i->GetIpv4Header().GetDestination() == dst) { @@ -106,7 +106,7 @@ RequestQueue::Dequeue(Ipv4Address dst, QueueEntry& entry) bool RequestQueue::Find(Ipv4Address dst) { - for (std::vector::const_iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (i->GetIpv4Header().GetDestination() == dst) { @@ -138,7 +138,7 @@ void RequestQueue::Purge() { IsExpired pred; - for (std::vector::iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (pred(*i)) { diff --git a/src/aodv/model/aodv-rtable.cc b/src/aodv/model/aodv-rtable.cc index bab8b1930..7b0c1b209 100644 --- a/src/aodv/model/aodv-rtable.cc +++ b/src/aodv/model/aodv-rtable.cc @@ -94,9 +94,7 @@ bool RoutingTableEntry::LookupPrecursor(Ipv4Address id) { NS_LOG_FUNCTION(this << id); - for (std::vector::const_iterator i = m_precursorList.begin(); - i != m_precursorList.end(); - ++i) + for (auto i = m_precursorList.begin(); i != m_precursorList.end(); ++i) { if (*i == id) { @@ -112,8 +110,7 @@ bool RoutingTableEntry::DeletePrecursor(Ipv4Address id) { NS_LOG_FUNCTION(this << id); - std::vector::iterator i = - std::remove(m_precursorList.begin(), m_precursorList.end(), id); + auto i = std::remove(m_precursorList.begin(), m_precursorList.end(), id); if (i == m_precursorList.end()) { NS_LOG_LOGIC("Precursor " << id << " not found"); @@ -148,12 +145,10 @@ RoutingTableEntry::GetPrecursors(std::vector& prec) const { return; } - for (std::vector::const_iterator i = m_precursorList.begin(); - i != m_precursorList.end(); - ++i) + for (auto i = m_precursorList.begin(); i != m_precursorList.end(); ++i) { bool result = true; - for (std::vector::const_iterator j = prec.begin(); j != prec.end(); ++j) + for (auto j = prec.begin(); j != prec.end(); ++j) { if (*j == *i) { @@ -244,7 +239,7 @@ RoutingTable::LookupRoute(Ipv4Address id, RoutingTableEntry& rt) NS_LOG_LOGIC("Route to " << id << " not found; m_ipv4AddressEntry is empty"); return false; } - std::map::const_iterator i = m_ipv4AddressEntry.find(id); + auto i = m_ipv4AddressEntry.find(id); if (i == m_ipv4AddressEntry.end()) { NS_LOG_LOGIC("Route to " << id << " not found"); @@ -292,8 +287,7 @@ RoutingTable::AddRoute(RoutingTableEntry& rt) { rt.SetRreqCnt(0); } - std::pair::iterator, bool> result = - m_ipv4AddressEntry.insert(std::make_pair(rt.GetDestination(), rt)); + auto result = m_ipv4AddressEntry.insert(std::make_pair(rt.GetDestination(), rt)); return result.second; } @@ -301,8 +295,7 @@ bool RoutingTable::Update(RoutingTableEntry& rt) { NS_LOG_FUNCTION(this); - std::map::iterator i = - m_ipv4AddressEntry.find(rt.GetDestination()); + auto i = m_ipv4AddressEntry.find(rt.GetDestination()); if (i == m_ipv4AddressEntry.end()) { NS_LOG_LOGIC("Route update to " << rt.GetDestination() << " fails; not found"); @@ -321,7 +314,7 @@ bool RoutingTable::SetEntryState(Ipv4Address id, RouteFlags state) { NS_LOG_FUNCTION(this); - std::map::iterator i = m_ipv4AddressEntry.find(id); + auto i = m_ipv4AddressEntry.find(id); if (i == m_ipv4AddressEntry.end()) { NS_LOG_LOGIC("Route set entry state to " << id << " fails; not found"); @@ -340,9 +333,7 @@ RoutingTable::GetListOfDestinationWithNextHop(Ipv4Address nextHop, NS_LOG_FUNCTION(this); Purge(); unreachable.clear(); - for (std::map::const_iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end(); - ++i) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end(); ++i) { if (i->second.GetNextHop() == nextHop) { @@ -357,13 +348,9 @@ RoutingTable::InvalidateRoutesWithDst(const std::map& unr { NS_LOG_FUNCTION(this); Purge(); - for (std::map::iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end(); - ++i) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end(); ++i) { - for (std::map::const_iterator j = unreachable.begin(); - j != unreachable.end(); - ++j) + for (auto j = unreachable.begin(); j != unreachable.end(); ++j) { if ((i->first == j->first) && (i->second.GetFlag() == VALID)) { @@ -382,12 +369,11 @@ RoutingTable::DeleteAllRoutesFromInterface(Ipv4InterfaceAddress iface) { return; } - for (std::map::iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end();) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end();) { if (i->second.GetInterface() == iface) { - std::map::iterator tmp = i; + auto tmp = i; ++i; m_ipv4AddressEntry.erase(tmp); } @@ -406,14 +392,13 @@ RoutingTable::Purge() { return; } - for (std::map::iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end();) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end();) { if (i->second.GetLifeTime() < Seconds(0)) { if (i->second.GetFlag() == INVALID) { - std::map::iterator tmp = i; + auto tmp = i; ++i; m_ipv4AddressEntry.erase(tmp); } @@ -443,13 +428,13 @@ RoutingTable::Purge(std::map& table) const { return; } - for (std::map::iterator i = table.begin(); i != table.end();) + for (auto i = table.begin(); i != table.end();) { if (i->second.GetLifeTime() < Seconds(0)) { if (i->second.GetFlag() == INVALID) { - std::map::iterator tmp = i; + auto tmp = i; ++i; table.erase(tmp); } @@ -475,7 +460,7 @@ bool RoutingTable::MarkLinkAsUnidirectional(Ipv4Address neighbor, Time blacklistTimeout) { NS_LOG_FUNCTION(this << neighbor << blacklistTimeout.As(Time::S)); - std::map::iterator i = m_ipv4AddressEntry.find(neighbor); + auto i = m_ipv4AddressEntry.find(neighbor); if (i == m_ipv4AddressEntry.end()) { NS_LOG_LOGIC("Mark link unidirectional to " << neighbor << " fails; not found"); @@ -506,9 +491,7 @@ RoutingTable::Print(Ptr stream, Time::Unit unit /* = Time:: *os << std::setw(16) << "Flag"; *os << std::setw(16) << "Expire"; *os << "Hops" << std::endl; - for (std::map::const_iterator i = table.begin(); - i != table.end(); - ++i) + for (auto i = table.begin(); i != table.end(); ++i) { i->second.Print(stream, unit); } diff --git a/src/aodv/test/aodv-test-suite.cc b/src/aodv/test/aodv-test-suite.cc index 5f3f903de..35e8cc9ff 100644 --- a/src/aodv/test/aodv-test-suite.cc +++ b/src/aodv/test/aodv-test-suite.cc @@ -317,11 +317,11 @@ struct RerrHeaderTest : public TestCase RerrHeader h; h.SetNoDelete(true); NS_TEST_EXPECT_MSG_EQ(h.GetNoDelete(), true, "trivial"); - Ipv4Address dst = Ipv4Address("1.2.3.4"); + Ipv4Address dst("1.2.3.4"); NS_TEST_EXPECT_MSG_EQ(h.AddUnDestination(dst, 12), true, "trivial"); NS_TEST_EXPECT_MSG_EQ(h.GetDestCount(), 1, "trivial"); NS_TEST_EXPECT_MSG_EQ(h.AddUnDestination(dst, 13), true, "trivial"); - Ipv4Address dst2 = Ipv4Address("4.3.2.1"); + Ipv4Address dst2("4.3.2.1"); NS_TEST_EXPECT_MSG_EQ(h.AddUnDestination(dst2, 12), true, "trivial"); NS_TEST_EXPECT_MSG_EQ(h.GetDestCount(), 2, "trivial"); diff --git a/src/applications/helper/bulk-send-helper.cc b/src/applications/helper/bulk-send-helper.cc index 1d7c4b2f7..6e53e06d4 100644 --- a/src/applications/helper/bulk-send-helper.cc +++ b/src/applications/helper/bulk-send-helper.cc @@ -59,7 +59,7 @@ ApplicationContainer BulkSendHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } diff --git a/src/applications/helper/on-off-helper.cc b/src/applications/helper/on-off-helper.cc index 311fee0f4..5dfcdbc13 100644 --- a/src/applications/helper/on-off-helper.cc +++ b/src/applications/helper/on-off-helper.cc @@ -60,7 +60,7 @@ ApplicationContainer OnOffHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } @@ -82,7 +82,7 @@ OnOffHelper::AssignStreams(NodeContainer c, int64_t stream) { int64_t currentStream = stream; Ptr node; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { node = (*i); for (uint32_t j = 0; j < node->GetNApplications(); j++) diff --git a/src/applications/helper/packet-sink-helper.cc b/src/applications/helper/packet-sink-helper.cc index a1e2139f8..72f8af81a 100644 --- a/src/applications/helper/packet-sink-helper.cc +++ b/src/applications/helper/packet-sink-helper.cc @@ -56,7 +56,7 @@ ApplicationContainer PacketSinkHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } diff --git a/src/applications/helper/three-gpp-http-helper.cc b/src/applications/helper/three-gpp-http-helper.cc index 85fc270c3..4cc25643a 100644 --- a/src/applications/helper/three-gpp-http-helper.cc +++ b/src/applications/helper/three-gpp-http-helper.cc @@ -61,7 +61,7 @@ ApplicationContainer ThreeGppHttpClientHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } @@ -109,7 +109,7 @@ ApplicationContainer ThreeGppHttpServerHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } diff --git a/src/applications/helper/udp-client-server-helper.cc b/src/applications/helper/udp-client-server-helper.cc index 9307bf0ea..99fd4b710 100644 --- a/src/applications/helper/udp-client-server-helper.cc +++ b/src/applications/helper/udp-client-server-helper.cc @@ -48,7 +48,7 @@ ApplicationContainer UdpServerHelper::Install(NodeContainer c) { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; @@ -93,7 +93,7 @@ ApplicationContainer UdpClientHelper::Install(NodeContainer c) { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr client = m_factory.Create(); @@ -133,7 +133,7 @@ ApplicationContainer UdpTraceClientHelper::Install(NodeContainer c) { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr client = m_factory.Create(); diff --git a/src/applications/helper/udp-echo-helper.cc b/src/applications/helper/udp-echo-helper.cc index e8b24a8db..ce5760223 100644 --- a/src/applications/helper/udp-echo-helper.cc +++ b/src/applications/helper/udp-echo-helper.cc @@ -55,7 +55,7 @@ ApplicationContainer UdpEchoServerHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } @@ -129,7 +129,7 @@ ApplicationContainer UdpEchoClientHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } diff --git a/src/applications/model/three-gpp-http-server.cc b/src/applications/model/three-gpp-http-server.cc index 5fdff8df4..3f7caa76d 100644 --- a/src/applications/model/three-gpp-http-server.cc +++ b/src/applications/model/three-gpp-http-server.cc @@ -633,8 +633,7 @@ ThreeGppHttpServerTxBuffer::ThreeGppHttpServerTxBuffer() bool ThreeGppHttpServerTxBuffer::IsSocketAvailable(Ptr socket) const { - std::map, TxBuffer_t>::const_iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); return (it != m_txBuffer.end()); } @@ -660,8 +659,7 @@ ThreeGppHttpServerTxBuffer::RemoveSocket(Ptr socket) { NS_LOG_FUNCTION(this << socket); - std::map, TxBuffer_t>::iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); if (!Simulator::IsExpired(it->second.nextServe)) @@ -684,8 +682,7 @@ ThreeGppHttpServerTxBuffer::CloseSocket(Ptr socket) { NS_LOG_FUNCTION(this << socket); - std::map, TxBuffer_t>::iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); if (!Simulator::IsExpired(it->second.nextServe)) @@ -716,8 +713,7 @@ ThreeGppHttpServerTxBuffer::CloseAllSockets() { NS_LOG_FUNCTION(this); - std::map, TxBuffer_t>::iterator it; - for (it = m_txBuffer.begin(); it != m_txBuffer.end(); ++it) + for (auto it = m_txBuffer.begin(); it != m_txBuffer.end(); ++it) { if (!Simulator::IsExpired(it->second.nextServe)) { @@ -739,8 +735,7 @@ ThreeGppHttpServerTxBuffer::CloseAllSockets() bool ThreeGppHttpServerTxBuffer::IsBufferEmpty(Ptr socket) const { - std::map, TxBuffer_t>::const_iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); return (it->second.txBufferSize == 0); } @@ -748,8 +743,7 @@ ThreeGppHttpServerTxBuffer::IsBufferEmpty(Ptr socket) const Time ThreeGppHttpServerTxBuffer::GetClientTs(Ptr socket) const { - std::map, TxBuffer_t>::const_iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); return it->second.clientTs; } @@ -757,8 +751,7 @@ ThreeGppHttpServerTxBuffer::GetClientTs(Ptr socket) const ThreeGppHttpHeader::ContentType_t ThreeGppHttpServerTxBuffer::GetBufferContentType(Ptr socket) const { - std::map, TxBuffer_t>::const_iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); return it->second.txBufferContentType; } @@ -766,8 +759,7 @@ ThreeGppHttpServerTxBuffer::GetBufferContentType(Ptr socket) const uint32_t ThreeGppHttpServerTxBuffer::GetBufferSize(Ptr socket) const { - std::map, TxBuffer_t>::const_iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); return it->second.txBufferSize; } @@ -775,8 +767,7 @@ ThreeGppHttpServerTxBuffer::GetBufferSize(Ptr socket) const bool ThreeGppHttpServerTxBuffer::HasTxedPartOfObject(Ptr socket) const { - std::map, TxBuffer_t>::const_iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found"); return it->second.hasTxedPartOfObject; } @@ -792,8 +783,7 @@ ThreeGppHttpServerTxBuffer::WriteNewObject(Ptr socket, "Unable to write an object without a proper Content-Type."); NS_ASSERT_MSG(objectSize > 0, "Unable to write a zero-sized object."); - std::map, TxBuffer_t>::iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); NS_ASSERT_MSG(it->second.txBufferSize == 0, "Cannot write to Tx buffer of socket " @@ -810,8 +800,7 @@ ThreeGppHttpServerTxBuffer::RecordNextServe(Ptr socket, { NS_LOG_FUNCTION(this << socket << clientTs.As(Time::S)); - std::map, TxBuffer_t>::iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); it->second.nextServe = eventId; it->second.clientTs = clientTs; @@ -824,8 +813,7 @@ ThreeGppHttpServerTxBuffer::DepleteBufferSize(Ptr socket, uint32_t amoun NS_ASSERT_MSG(amount > 0, "Unable to consume zero bytes."); - std::map, TxBuffer_t>::iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); NS_ASSERT_MSG(it->second.txBufferSize >= amount, "The requested amount is larger than the current buffer size."); @@ -847,8 +835,7 @@ void ThreeGppHttpServerTxBuffer::PrepareClose(Ptr socket) { NS_LOG_FUNCTION(this << socket); - std::map, TxBuffer_t>::iterator it; - it = m_txBuffer.find(socket); + auto it = m_txBuffer.find(socket); NS_ASSERT_MSG(it != m_txBuffer.end(), "Socket " << socket << " cannot be found."); it->second.isClosing = true; } diff --git a/src/applications/model/three-gpp-http-variables.cc b/src/applications/model/three-gpp-http-variables.cc index bad12f5c3..f5f2bb328 100644 --- a/src/applications/model/three-gpp-http-variables.cc +++ b/src/applications/model/three-gpp-http-variables.cc @@ -267,7 +267,7 @@ uint32_t ThreeGppHttpVariables::GetNumOfEmbeddedObjects() { // Validate parameters. - const uint32_t upperBound = static_cast(m_numOfEmbeddedObjectsRng->GetBound()); + const auto upperBound = static_cast(m_numOfEmbeddedObjectsRng->GetBound()); if (upperBound <= m_numOfEmbeddedObjectsScale) { NS_FATAL_ERROR("`NumOfEmbeddedObjectsMax` attribute " diff --git a/src/bridge/helper/bridge-helper.cc b/src/bridge/helper/bridge-helper.cc index 3fea2f89d..d56d504c7 100644 --- a/src/bridge/helper/bridge-helper.cc +++ b/src/bridge/helper/bridge-helper.cc @@ -57,7 +57,7 @@ BridgeHelper::Install(Ptr node, NetDeviceContainer c) devs.Add(dev); node->AddDevice(dev); - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { NS_LOG_LOGIC("**** Add BridgePort " << *i); dev->AddBridgePort(*i); diff --git a/src/bridge/model/bridge-channel.cc b/src/bridge/model/bridge-channel.cc index 56dbdb30b..6d7585357 100644 --- a/src/bridge/model/bridge-channel.cc +++ b/src/bridge/model/bridge-channel.cc @@ -52,9 +52,7 @@ BridgeChannel::~BridgeChannel() { NS_LOG_FUNCTION_NOARGS(); - for (std::vector>::iterator iter = m_bridgedChannels.begin(); - iter != m_bridgedChannels.end(); - iter++) + for (auto iter = m_bridgedChannels.begin(); iter != m_bridgedChannels.end(); iter++) { *iter = nullptr; } @@ -71,9 +69,7 @@ std::size_t BridgeChannel::GetNDevices() const { uint32_t ndevices = 0; - for (std::vector>::const_iterator iter = m_bridgedChannels.begin(); - iter != m_bridgedChannels.end(); - iter++) + for (auto iter = m_bridgedChannels.begin(); iter != m_bridgedChannels.end(); iter++) { ndevices += (*iter)->GetNDevices(); } @@ -84,9 +80,7 @@ Ptr BridgeChannel::GetDevice(std::size_t i) const { std::size_t ndevices = 0; - for (std::vector>::const_iterator iter = m_bridgedChannels.begin(); - iter != m_bridgedChannels.end(); - iter++) + for (auto iter = m_bridgedChannels.begin(); iter != m_bridgedChannels.end(); iter++) { if ((i - ndevices) < (*iter)->GetNDevices()) { diff --git a/src/bridge/model/bridge-net-device.cc b/src/bridge/model/bridge-net-device.cc index 0613232f2..6b0fd1106 100644 --- a/src/bridge/model/bridge-net-device.cc +++ b/src/bridge/model/bridge-net-device.cc @@ -80,8 +80,7 @@ void BridgeNetDevice::DoDispose() { NS_LOG_FUNCTION_NOARGS(); - for (std::vector>::iterator iter = m_ports.begin(); iter != m_ports.end(); - iter++) + for (auto iter = m_ports.begin(); iter != m_ports.end(); iter++) { *iter = nullptr; } @@ -163,8 +162,7 @@ BridgeNetDevice::ForwardUnicast(Ptr incomingPort, else { NS_LOG_LOGIC("No learned state: send through all ports"); - for (std::vector>::iterator iter = m_ports.begin(); iter != m_ports.end(); - iter++) + for (auto iter = m_ports.begin(); iter != m_ports.end(); iter++) { Ptr port = *iter; if (port != incomingPort) @@ -193,8 +191,7 @@ BridgeNetDevice::ForwardBroadcast(Ptr incomingPort, << ", protocol=" << protocol << ", src=" << src << ", dst=" << dst << ")"); Learn(src, incomingPort); - for (std::vector>::iterator iter = m_ports.begin(); iter != m_ports.end(); - iter++) + for (auto iter = m_ports.begin(); iter != m_ports.end(); iter++) { Ptr port = *iter; if (port != incomingPort) @@ -227,7 +224,7 @@ BridgeNetDevice::GetLearnedState(Mac48Address source) if (m_enableLearning) { Time now = Simulator::Now(); - std::map::iterator iter = m_learnState.find(source); + auto iter = m_learnState.find(source); if (iter != m_learnState.end()) { LearnedState& state = iter->second; @@ -420,8 +417,7 @@ BridgeNetDevice::SendFrom(Ptr packet, // data was not unicast or no state has been learned for that mac // address => flood through all ports. Ptr pktCopy; - for (std::vector>::iterator iter = m_ports.begin(); iter != m_ports.end(); - iter++) + for (auto iter = m_ports.begin(); iter != m_ports.end(); iter++) { pktCopy = packet->Copy(); Ptr port = *iter; diff --git a/src/brite/helper/brite-topology-helper.cc b/src/brite/helper/brite-topology-helper.cc index f98728165..d37f60963 100644 --- a/src/brite/helper/brite-topology-helper.cc +++ b/src/brite/helper/brite-topology-helper.cc @@ -186,10 +186,9 @@ BriteTopologyHelper::BuildBriteEdgeInfoList() { NS_LOG_FUNCTION(this); brite::Graph* g = m_topology->GetGraph(); - std::list::iterator el; std::list edgeList = g->GetEdges(); - for (el = edgeList.begin(); el != edgeList.end(); el++) + for (auto el = edgeList.begin(); el != edgeList.end(); el++) { BriteEdgeInfo edgeInfo; edgeInfo.edgeId = (*el)->GetId(); @@ -418,9 +417,7 @@ BriteTopologyHelper::BuildBriteTopology(InternetStackHelper& stack, const uint32 } // create nodes - for (BriteTopologyHelper::BriteNodeInfoList::iterator it = m_briteNodeInfoList.begin(); - it != m_briteNodeInfoList.end(); - ++it) + for (auto it = m_briteNodeInfoList.begin(); it != m_briteNodeInfoList.end(); ++it) { m_nodes.Add(CreateObject(GetSystemNumberForAs((*it).asId))); m_numNodes++; @@ -468,9 +465,7 @@ BriteTopologyHelper::ConstructTopology() m_nodesByAs.push_back(new NodeContainer()); } - for (BriteTopologyHelper::BriteEdgeInfoList::iterator it = m_briteEdgeInfoList.begin(); - it != m_briteEdgeInfoList.end(); - ++it) + for (auto it = m_briteEdgeInfoList.begin(); it != m_briteEdgeInfoList.end(); ++it) { // Set the link delay // The brite value for delay is given in milliseconds @@ -492,9 +487,7 @@ BriteTopologyHelper::ConstructTopology() NS_LOG_INFO("Created " << m_numEdges << " edges in BRITE topology"); // iterate through all nodes and add leaf nodes for each AS - for (BriteTopologyHelper::BriteNodeInfoList::iterator it = m_briteNodeInfoList.begin(); - it != m_briteNodeInfoList.end(); - ++it) + for (auto it = m_briteNodeInfoList.begin(); it != m_briteNodeInfoList.end(); ++it) { m_nodesByAs[(*it).asId]->Add(m_nodes.Get((*it).nodeId)); diff --git a/src/buildings/examples/outdoor-group-mobility-example.cc b/src/buildings/examples/outdoor-group-mobility-example.cc index d9c657cbe..59515ebf8 100644 --- a/src/buildings/examples/outdoor-group-mobility-example.cc +++ b/src/buildings/examples/outdoor-group-mobility-example.cc @@ -111,7 +111,7 @@ PrintGnuplottableBuildingListToFile(std::string filename) return; } uint32_t index = 1; - for (BuildingList::Iterator it = BuildingList::Begin(); it != BuildingList::End(); ++it) + for (auto it = BuildingList::Begin(); it != BuildingList::End(); ++it) { ++index; Box box = (*it)->GetBoundaries(); diff --git a/src/buildings/examples/outdoor-random-walk-example.cc b/src/buildings/examples/outdoor-random-walk-example.cc index 7ba4a3ade..36da591a1 100644 --- a/src/buildings/examples/outdoor-random-walk-example.cc +++ b/src/buildings/examples/outdoor-random-walk-example.cc @@ -44,7 +44,7 @@ PrintGnuplottableBuildingListToFile(std::string filename) return; } uint32_t index = 0; - for (BuildingList::Iterator it = BuildingList::Begin(); it != BuildingList::End(); ++it) + for (auto it = BuildingList::Begin(); it != BuildingList::End(); ++it) { ++index; Box box = (*it)->GetBoundaries(); diff --git a/src/buildings/helper/building-container.cc b/src/buildings/helper/building-container.cc index fafba52a3..55816a4c9 100644 --- a/src/buildings/helper/building-container.cc +++ b/src/buildings/helper/building-container.cc @@ -77,7 +77,7 @@ BuildingContainer::Create(uint32_t n) void BuildingContainer::Add(BuildingContainer other) { - for (Iterator i = other.Begin(); i != other.End(); i++) + for (auto i = other.Begin(); i != other.End(); i++) { m_buildings.push_back(*i); } @@ -100,7 +100,7 @@ BuildingContainer BuildingContainer::GetGlobal() { BuildingContainer c; - for (BuildingList::Iterator i = BuildingList::Begin(); i != BuildingList::End(); ++i) + for (auto i = BuildingList::Begin(); i != BuildingList::End(); ++i) { c.Add(*i); } diff --git a/src/buildings/helper/building-position-allocator.cc b/src/buildings/helper/building-position-allocator.cc index 1895ecd32..31fb58250 100644 --- a/src/buildings/helper/building-position-allocator.cc +++ b/src/buildings/helper/building-position-allocator.cc @@ -82,8 +82,7 @@ RandomBuildingPositionAllocator::GetNext() const { if (m_buildingListWithoutReplacement.empty()) { - for (BuildingList::Iterator bit = BuildingList::Begin(); bit != BuildingList::End(); - ++bit) + for (auto bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) { m_buildingListWithoutReplacement.push_back(*bit); } @@ -189,7 +188,7 @@ OutdoorPositionAllocator::GetNext() const NS_LOG_INFO("Position " << position); bool inside = false; - for (BuildingList::Iterator bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) + for (auto bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) { if ((*bit)->IsInside(position)) { @@ -255,7 +254,7 @@ RandomRoomPositionAllocator::GetNext() const if (m_roomListWithoutReplacement.empty()) { - for (BuildingList::Iterator bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) + for (auto bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) { NS_LOG_LOGIC("building " << (*bit)->GetId()); for (uint32_t rx = 1; rx <= (*bit)->GetNRoomsX(); ++rx) @@ -327,7 +326,7 @@ SameRoomPositionAllocator::SameRoomPositionAllocator(NodeContainer c) m_rand = CreateObject(); m_nodeIt = m_nodes.Begin(); // this is needed to make sure the building models associated with c have been initialized - for (NodeContainer::Iterator it = m_nodes.Begin(); it != m_nodes.End(); ++it) + for (auto it = m_nodes.Begin(); it != m_nodes.End(); ++it) { Ptr mm = (*it)->GetObject(); NS_ASSERT_MSG(mm, "no mobility model aggregated to this node"); diff --git a/src/buildings/helper/buildings-helper.cc b/src/buildings/helper/buildings-helper.cc index 8d0f614bf..1f15a778e 100644 --- a/src/buildings/helper/buildings-helper.cc +++ b/src/buildings/helper/buildings-helper.cc @@ -35,7 +35,7 @@ NS_LOG_COMPONENT_DEFINE("BuildingsHelper"); void BuildingsHelper::Install(NodeContainer c) { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Install(*i); } diff --git a/src/buildings/model/building-list.cc b/src/buildings/model/building-list.cc index 9bf0c3826..e6c634255 100644 --- a/src/buildings/model/building-list.cc +++ b/src/buildings/model/building-list.cc @@ -158,7 +158,7 @@ void BuildingListPriv::DoDispose() { NS_LOG_FUNCTION_NOARGS(); - for (std::vector>::iterator i = m_buildings.begin(); i != m_buildings.end(); i++) + for (auto i = m_buildings.begin(); i != m_buildings.end(); i++) { Ptr building = *i; building->Dispose(); diff --git a/src/buildings/model/buildings-channel-condition-model.cc b/src/buildings/model/buildings-channel-condition-model.cc index 3f45f354e..74c2ca0b3 100644 --- a/src/buildings/model/buildings-channel-condition-model.cc +++ b/src/buildings/model/buildings-channel-condition-model.cc @@ -171,7 +171,7 @@ bool BuildingsChannelConditionModel::IsLineOfSightBlocked(const ns3::Vector& l1, const ns3::Vector& l2) const { - for (BuildingList::Iterator bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) + for (auto bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) { if ((*bit)->IsIntersect(l1, l2)) { diff --git a/src/buildings/model/buildings-propagation-loss-model.cc b/src/buildings/model/buildings-propagation-loss-model.cc index 02847236c..9c8878a7c 100644 --- a/src/buildings/model/buildings-propagation-loss-model.cc +++ b/src/buildings/model/buildings-propagation-loss-model.cc @@ -160,11 +160,10 @@ BuildingsPropagationLossModel::GetShadowing(Ptr a, Ptr b1 = b->GetObject(); NS_ASSERT_MSG(a1 && b1, "BuildingsPropagationLossModel only works with MobilityBuildingInfo"); - std::map, std::map, ShadowingLoss>>::iterator ait = - m_shadowingLossMap.find(a); + auto ait = m_shadowingLossMap.find(a); if (ait != m_shadowingLossMap.end()) { - std::map, ShadowingLoss>::iterator bit = ait->second.find(b); + auto bit = ait->second.find(b); if (bit != ait->second.end()) { return (bit->second.GetLoss()); diff --git a/src/buildings/model/mobility-building-info.cc b/src/buildings/model/mobility-building-info.cc index ab1e38a7f..c6b5f5c08 100644 --- a/src/buildings/model/mobility-building-info.cc +++ b/src/buildings/model/mobility-building-info.cc @@ -168,7 +168,7 @@ MobilityBuildingInfo::MakeConsistent(Ptr mm) { bool found = false; Vector pos = mm->GetPosition(); - for (BuildingList::Iterator bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) + for (auto bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) { NS_LOG_LOGIC("checking building " << (*bit)->GetId() << " with boundaries " << (*bit)->GetBoundaries()); diff --git a/src/buildings/model/random-walk-2d-outdoor-mobility-model.cc b/src/buildings/model/random-walk-2d-outdoor-mobility-model.cc index 9896e3c7e..6a2420653 100644 --- a/src/buildings/model/random-walk-2d-outdoor-mobility-model.cc +++ b/src/buildings/model/random-walk-2d-outdoor-mobility-model.cc @@ -271,7 +271,7 @@ RandomWalk2dOutdoorMobilityModel::IsLineClearOfBuildings(Vector currentPosition, double minIntersectionDistance = std::numeric_limits::max(); Ptr minIntersectionDistanceBuilding; - for (BuildingList::Iterator bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) + for (auto bit = BuildingList::Begin(); bit != BuildingList::End(); ++bit) { // check if this building intersects the line between the current and next positions // this checks also if the next position is inside the building diff --git a/src/buildings/test/building-position-allocator-test.cc b/src/buildings/test/building-position-allocator-test.cc index 94879a592..980a921a7 100644 --- a/src/buildings/test/building-position-allocator-test.cc +++ b/src/buildings/test/building-position-allocator-test.cc @@ -117,7 +117,7 @@ RandomRoomPositionAllocatorTestCase::DoRun() std::map roomCounter; - for (NodeContainer::Iterator it = nodes.Begin(); it != nodes.End(); ++it) + for (auto it = nodes.Begin(); it != nodes.End(); ++it) { Ptr mm = (*it)->GetObject(); NS_ASSERT_MSG(mm, "no mobility model aggregated to this node"); @@ -138,7 +138,7 @@ RandomRoomPositionAllocatorTestCase::DoRun() NS_TEST_ASSERT_MSG_LT(p.z, bmm->GetFloorNumber() + 1, "wrong z value"); } - for (std::map::iterator it = roomCounter.begin(); it != roomCounter.end(); ++it) + for (auto it = roomCounter.begin(); it != roomCounter.end(); ++it) { // random selection is done without replacement until the set of // eligible room is empty, at which point the set is filled @@ -202,7 +202,7 @@ SameRoomPositionAllocatorTestCase::DoRun() std::map roomCounter; - for (NodeContainer::Iterator it = copyNodes.Begin(); it != copyNodes.End(); ++it) + for (auto it = copyNodes.Begin(); it != copyNodes.End(); ++it) { Ptr mm = (*it)->GetObject(); NS_ASSERT_MSG(mm, "no mobility model aggregated to this node"); @@ -215,7 +215,7 @@ SameRoomPositionAllocatorTestCase::DoRun() ++(roomCounter[r]); } - for (std::map::iterator it = roomCounter.begin(); it != roomCounter.end(); ++it) + for (auto it = roomCounter.begin(); it != roomCounter.end(); ++it) { NS_TEST_ASSERT_MSG_EQ(it->second, 4, "expected 4 nodes per room"); } diff --git a/src/click/helper/click-internet-stack-helper.cc b/src/click/helper/click-internet-stack-helper.cc index c997331bd..e9b12e260 100644 --- a/src/click/helper/click-internet-stack-helper.cc +++ b/src/click/helper/click-internet-stack-helper.cc @@ -207,7 +207,7 @@ ClickInternetStackHelper::Reset() void ClickInternetStackHelper::SetClickFile(NodeContainer c, std::string clickfile) { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { SetClickFile(*i, clickfile); } @@ -222,7 +222,7 @@ ClickInternetStackHelper::SetClickFile(Ptr node, std::string clickfile) void ClickInternetStackHelper::SetDefines(NodeContainer c, std::map defines) { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { SetDefines(*i, defines); } @@ -237,7 +237,7 @@ ClickInternetStackHelper::SetDefines(Ptr node, std::map node, std::string rt) void ClickInternetStackHelper::Install(NodeContainer c) const { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Install(*i); } @@ -296,16 +296,14 @@ ClickInternetStackHelper::Install(Ptr node) const // Set routing Ptr ipv4 = node->GetObject(); Ptr ipv4Routing = CreateObject(); - std::map, std::string>::const_iterator it; - it = m_nodeToClickFileMap.find(node); + auto it = m_nodeToClickFileMap.find(node); if (it != m_nodeToClickFileMap.end()) { ipv4Routing->SetClickFile(it->second); } - std::map, std::map>::const_iterator definesIt; - definesIt = m_nodeToDefinesMap.find(node); + auto definesIt = m_nodeToDefinesMap.find(node); if (definesIt != m_nodeToDefinesMap.end()) { ipv4Routing->SetDefines(definesIt->second); @@ -331,9 +329,7 @@ ClickInternetStackHelper::Install(std::string nodeName) const bool ClickInternetStackHelper::PcapHooked(Ptr ipv4) { - for (InterfaceFileMapIpv4::const_iterator i = g_interfaceFileMapIpv4.begin(); - i != g_interfaceFileMapIpv4.end(); - ++i) + for (auto i = g_interfaceFileMapIpv4.begin(); i != g_interfaceFileMapIpv4.end(); ++i) { if ((*i).first.first == ipv4) { @@ -409,9 +405,7 @@ ClickInternetStackHelper::EnablePcapIpv4Internal(std::string prefix, bool ClickInternetStackHelper::AsciiHooked(Ptr ipv4) { - for (InterfaceStreamMapIpv4::const_iterator i = g_interfaceStreamMapIpv4.begin(); - i != g_interfaceStreamMapIpv4.end(); - ++i) + for (auto i = g_interfaceStreamMapIpv4.begin(); i != g_interfaceStreamMapIpv4.end(); ++i) { if ((*i).first.first == ipv4) { diff --git a/src/click/model/ipv4-click-routing.cc b/src/click/model/ipv4-click-routing.cc index 09cae2c3b..b38b89ea9 100644 --- a/src/click/model/ipv4-click-routing.cc +++ b/src/click/model/ipv4-click-routing.cc @@ -396,7 +396,7 @@ Ipv4ClickRouting::Send(Ptr p, Ipv4Address src, Ipv4Address dst) } int len = p->GetSize(); - uint8_t* buf = new uint8_t[len]; + auto buf = new uint8_t[len]; p->CopyData(buf, len); // ... and send the packet on the corresponding Click interface. @@ -424,7 +424,7 @@ Ipv4ClickRouting::Receive(Ptr p, Mac48Address receiverAddr, Mac48Address } int len = p->GetSize(); - uint8_t* buf = new uint8_t[len]; + auto buf = new uint8_t[len]; p->CopyData(buf, len); // ... and send the packet to the corresponding Click interface @@ -816,8 +816,8 @@ simclick_sim_command(simclick_node_t* simnode, int cmd, ...) // Append key/value pair, separated by \0. std::map defines = clickInstance->GetDefines(); - std::map::const_iterator it = defines.begin(); - while (it != defines.end()) + + for (auto it = defines.begin(); it != defines.end(); it++) { size_t available = *size - required; if (it->first.length() + it->second.length() + 2 <= available) @@ -832,7 +832,6 @@ simclick_sim_command(simclick_node_t* simnode, int cmd, ...) { required += it->first.length() + it->second.length() + 2; } - it++; } if (required > *size) { diff --git a/src/click/model/ipv4-l3-click-protocol.cc b/src/click/model/ipv4-l3-click-protocol.cc index 94c084446..7f050c1b8 100644 --- a/src/click/model/ipv4-l3-click-protocol.cc +++ b/src/click/model/ipv4-l3-click-protocol.cc @@ -79,13 +79,13 @@ void Ipv4L3ClickProtocol::DoDispose() { NS_LOG_FUNCTION(this); - for (L4List_t::iterator i = m_protocols.begin(); i != m_protocols.end(); ++i) + for (auto i = m_protocols.begin(); i != m_protocols.end(); ++i) { i->second = nullptr; } m_protocols.clear(); - for (Ipv4InterfaceList::iterator i = m_interfaces.begin(); i != m_interfaces.end(); ++i) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); ++i) { *i = nullptr; } @@ -152,8 +152,7 @@ Ipv4L3ClickProtocol::GetInterfaceForAddress(Ipv4Address address) const NS_LOG_FUNCTION(this << address); int32_t interface = 0; - for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); - i++, interface++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++, interface++) { for (uint32_t j = 0; j < (*i)->GetNAddresses(); j++) { @@ -173,8 +172,7 @@ Ipv4L3ClickProtocol::GetInterfaceForPrefix(Ipv4Address address, Ipv4Mask mask) c NS_LOG_FUNCTION(this << address << mask); int32_t interface = 0; - for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); - i++, interface++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++, interface++) { for (uint32_t j = 0; j < (*i)->GetNAddresses(); j++) { @@ -193,7 +191,7 @@ Ipv4L3ClickProtocol::GetInterfaceForDevice(Ptr device) const { NS_LOG_FUNCTION(this << device->GetIfIndex()); - Ipv4InterfaceReverseContainer::const_iterator iter = m_reverseInterfacesContainer.find(device); + auto iter = m_reverseInterfacesContainer.find(device); if (iter != m_reverseInterfacesContainer.end()) { return (*iter).second; @@ -274,7 +272,7 @@ Ipv4L3ClickProtocol::SetIpForward(bool forward) { NS_LOG_FUNCTION(this << forward); m_ipForward = forward; - for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { (*i)->SetForwarding(forward); } @@ -363,7 +361,7 @@ void Ipv4L3ClickProtocol::DeleteRawSocket(Ptr socket) { NS_LOG_FUNCTION(this << socket); - for (SocketList::iterator i = m_sockets.begin(); i != m_sockets.end(); ++i) + for (auto i = m_sockets.begin(); i != m_sockets.end(); ++i) { if ((*i) == socket) { @@ -804,7 +802,7 @@ Ipv4L3ClickProtocol::Receive(Ptr device, } packetForRawSocket->RemoveHeader(ipHeader); - for (SocketList::iterator i = m_sockets.begin(); i != m_sockets.end(); ++i) + for (auto i = m_sockets.begin(); i != m_sockets.end(); ++i) { NS_LOG_LOGIC("Forwarding to raw socket"); Ptr socket = *i; @@ -922,7 +920,7 @@ Ipv4L3ClickProtocol::Remove(Ptr protocol) NS_LOG_FUNCTION(this << protocol); L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), -1); - L4List_t::iterator iter = m_protocols.find(key); + auto iter = m_protocols.find(key); if (iter == m_protocols.end()) { NS_LOG_WARN("Trying to remove an non-existent default protocol " @@ -940,7 +938,7 @@ Ipv4L3ClickProtocol::Remove(Ptr protocol, uint32_t interfaceIndex) NS_LOG_FUNCTION(this << protocol << interfaceIndex); L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), interfaceIndex); - L4List_t::iterator iter = m_protocols.find(key); + auto iter = m_protocols.find(key); if (iter == m_protocols.end()) { NS_LOG_WARN("Trying to remove an non-existent protocol " @@ -967,12 +965,11 @@ Ipv4L3ClickProtocol::GetProtocol(int protocolNumber, int32_t interfaceIndex) con NS_LOG_FUNCTION(this << protocolNumber << interfaceIndex); L4ListKey_t key; - L4List_t::const_iterator i; if (interfaceIndex >= 0) { // try the interface-specific protocol. key = std::make_pair(protocolNumber, interfaceIndex); - i = m_protocols.find(key); + auto i = m_protocols.find(key); if (i != m_protocols.end()) { return i->second; @@ -980,7 +977,7 @@ Ipv4L3ClickProtocol::GetProtocol(int protocolNumber, int32_t interfaceIndex) con } // try the generic protocol. key = std::make_pair(protocolNumber, -1); - i = m_protocols.find(key); + auto i = m_protocols.find(key); if (i != m_protocols.end()) { return i->second; diff --git a/src/config-store/model/attribute-iterator.cc b/src/config-store/model/attribute-iterator.cc index 3165da3f5..8cb7dff03 100644 --- a/src/config-store/model/attribute-iterator.cc +++ b/src/config-store/model/attribute-iterator.cc @@ -227,8 +227,7 @@ AttributeIterator::DoIterate(Ptr object) for (uint32_t i = 0; i < tid.GetAttributeN(); ++i) { TypeId::AttributeInformation info = tid.GetAttribute(i); - const PointerChecker* ptrChecker = - dynamic_cast(PeekPointer(info.checker)); + const auto ptrChecker = dynamic_cast(PeekPointer(info.checker)); if (ptrChecker != nullptr) { NS_LOG_DEBUG("pointer attribute " << info.name); @@ -246,7 +245,7 @@ AttributeIterator::DoIterate(Ptr object) continue; } // attempt to cast to an object container - const ObjectPtrContainerChecker* vectorChecker = + const auto vectorChecker = dynamic_cast(PeekPointer(info.checker)); if (vectorChecker != nullptr) { diff --git a/src/config-store/model/model-node-creator.cc b/src/config-store/model/model-node-creator.cc index c5df8133e..a3bbfa7a5 100644 --- a/src/config-store/model/model-node-creator.cc +++ b/src/config-store/model/model-node-creator.cc @@ -41,7 +41,7 @@ void ModelCreator::Add(ModelNode* node) { GtkTreeIter* parent = m_iters.back(); - GtkTreeIter* current = g_new(GtkTreeIter, 1); + auto current = g_new(GtkTreeIter, 1); gtk_tree_store_append(m_treestore, current, parent); gtk_tree_store_set(m_treestore, current, COL_NODE, node, -1); m_iters.push_back(current); @@ -58,7 +58,7 @@ ModelCreator::Remove() void ModelCreator::DoVisitAttribute(Ptr object, std::string name) { - ModelNode* node = new ModelNode(); + auto node = new ModelNode(); node->type = ModelNode::NODE_ATTRIBUTE; node->object = object; node->name = name; @@ -69,7 +69,7 @@ ModelCreator::DoVisitAttribute(Ptr object, std::string name) void ModelCreator::DoStartVisitObject(Ptr object) { - ModelNode* node = new ModelNode(); + auto node = new ModelNode(); node->type = ModelNode::NODE_OBJECT; node->object = object; Add(node); @@ -84,7 +84,7 @@ ModelCreator::DoEndVisitObject() void ModelCreator::DoStartVisitPointerAttribute(Ptr object, std::string name, Ptr value) { - ModelNode* node = new ModelNode(); + auto node = new ModelNode(); node->type = ModelNode::NODE_POINTER; node->object = object; node->name = name; @@ -102,7 +102,7 @@ ModelCreator::DoStartVisitArrayAttribute(Ptr object, std::string name, const ObjectPtrContainerValue& vector) { - ModelNode* node = new ModelNode(); + auto node = new ModelNode(); node->type = ModelNode::NODE_VECTOR; node->object = object; node->name = name; @@ -121,8 +121,8 @@ ModelCreator::DoStartVisitArrayItem(const ObjectPtrContainerValue& vector, Ptr item) { GtkTreeIter* parent = m_iters.back(); - GtkTreeIter* current = g_new(GtkTreeIter, 1); - ModelNode* node = new ModelNode(); + auto current = g_new(GtkTreeIter, 1); + auto node = new ModelNode(); node->type = ModelNode::NODE_VECTOR_ITEM; node->object = item; node->index = index; diff --git a/src/config-store/model/model-typeid-creator.cc b/src/config-store/model/model-typeid-creator.cc index fd360eb99..a76b06c81 100644 --- a/src/config-store/model/model-typeid-creator.cc +++ b/src/config-store/model/model-typeid-creator.cc @@ -38,7 +38,7 @@ void ModelTypeidCreator::Add(ModelTypeid* node) { GtkTreeIter* parent = m_iters.back(); - GtkTreeIter* current = g_new(GtkTreeIter, 1); + auto current = g_new(GtkTreeIter, 1); gtk_tree_store_append(m_treestore, current, parent); gtk_tree_store_set(m_treestore, current, COL_TYPEID, node, -1); m_iters.push_back(current); @@ -58,7 +58,7 @@ ModelTypeidCreator::VisitAttribute(TypeId tid, std::string defaultValue, uint32_t index) { - ModelTypeid* node = new ModelTypeid(); + auto node = new ModelTypeid(); node->type = ModelTypeid::NODE_ATTRIBUTE; node->tid = tid; node->name = name; @@ -71,7 +71,7 @@ ModelTypeidCreator::VisitAttribute(TypeId tid, void ModelTypeidCreator::StartVisitTypeId(std::string name) { - ModelTypeid* node = new ModelTypeid(); + auto node = new ModelTypeid(); node->type = ModelTypeid::NODE_TYPEID; node->tid = TypeId::LookupByName(name); Add(node); diff --git a/src/config-store/model/raw-text-config.cc b/src/config-store/model/raw-text-config.cc index 188dd5ef7..7db161f4c 100644 --- a/src/config-store/model/raw-text-config.cc +++ b/src/config-store/model/raw-text-config.cc @@ -131,7 +131,7 @@ void RawTextConfigSave::Global() { NS_LOG_FUNCTION(this); - for (GlobalValue::Iterator i = GlobalValue::Begin(); i != GlobalValue::End(); ++i) + for (auto i = GlobalValue::Begin(); i != GlobalValue::End(); ++i) { StringValue value; (*i)->GetValue(value); diff --git a/src/config-store/model/xml-config.cc b/src/config-store/model/xml-config.cc index 6ea192f00..c8f377d43 100644 --- a/src/config-store/model/xml-config.cc +++ b/src/config-store/model/xml-config.cc @@ -271,7 +271,7 @@ void XmlConfigSave::Global() { int rc; - for (GlobalValue::Iterator i = GlobalValue::Begin(); i != GlobalValue::End(); ++i) + for (auto i = GlobalValue::Begin(); i != GlobalValue::End(); ++i) { StringValue value; (*i)->GetValue(value); diff --git a/src/core/examples/hash-example.cc b/src/core/examples/hash-example.cc index 68095de80..f7d0e3624 100644 --- a/src/core/examples/hash-example.cc +++ b/src/core/examples/hash-example.cc @@ -352,7 +352,7 @@ class Dictionary // // Number of buckets = k = 2^bits long double k32 = 0xFFFFFFFF; - long double k64 = static_cast(0xFFFFFFFFFFFFFFFFULL); + auto k64 = static_cast(0xFFFFFFFFFFFFFFFFULL); long double n = m_nphrases; long double Ec32 = n * (n - 1) / (2 * k32) * (1 - (n - 2) / (3 * k32)); diff --git a/src/core/examples/main-random-variable-stream.cc b/src/core/examples/main-random-variable-stream.cc index 43820d6b6..96ef3f8e5 100644 --- a/src/core/examples/main-random-variable-stream.cc +++ b/src/core/examples/main-random-variable-stream.cc @@ -99,7 +99,7 @@ Histogram(Ptr rndvar, data.SetStyle(Gnuplot2dDataset::IMPULSES); } - for (histogram_maptype::const_iterator hi = histogram.begin(); hi != histogram.end(); ++hi) + for (auto hi = histogram.begin(); hi != histogram.end(); ++hi) { data.Add(hi->first, (double)hi->second / (double)probes / precision); } diff --git a/src/core/helper/event-garbage-collector.cc b/src/core/helper/event-garbage-collector.cc index 8fa0d8100..6beed43eb 100644 --- a/src/core/helper/event-garbage-collector.cc +++ b/src/core/helper/event-garbage-collector.cc @@ -65,7 +65,7 @@ EventGarbageCollector::Shrink() void EventGarbageCollector::Cleanup() { - for (EventList::iterator iter = m_events.begin(); iter != m_events.end();) + for (auto iter = m_events.begin(); iter != m_events.end();) { if ((*iter).IsExpired()) { diff --git a/src/core/model/attribute-construction-list.cc b/src/core/model/attribute-construction-list.cc index 657db4507..42253c176 100644 --- a/src/core/model/attribute-construction-list.cc +++ b/src/core/model/attribute-construction-list.cc @@ -45,7 +45,7 @@ AttributeConstructionList::Add(std::string name, // vector of values. NS_LOG_FUNCTION(this << name << checker << value); - for (std::list::iterator k = m_list.begin(); k != m_list.end(); k++) + for (auto k = m_list.begin(); k != m_list.end(); k++) { if (k->checker == checker) { @@ -65,7 +65,7 @@ Ptr AttributeConstructionList::Find(Ptr checker) const { NS_LOG_FUNCTION(this << checker); - for (CIterator k = m_list.begin(); k != m_list.end(); k++) + for (auto k = m_list.begin(); k != m_list.end(); k++) { NS_LOG_DEBUG("Found " << k->name << " " << k->checker << " " << k->value); if (k->checker == checker) diff --git a/src/core/model/attribute.cc b/src/core/model/attribute.cc index 88f21f66d..6553a2353 100644 --- a/src/core/model/attribute.cc +++ b/src/core/model/attribute.cc @@ -69,7 +69,7 @@ AttributeChecker::CreateValidValue(const AttributeValue& value) const return value.Copy(); } // attempt to convert to string. - const StringValue* str = dynamic_cast(&value); + const auto str = dynamic_cast(&value); if (str == nullptr) { return nullptr; diff --git a/src/core/model/calendar-scheduler.cc b/src/core/model/calendar-scheduler.cc index 1807579e2..2cb9e37e9 100644 --- a/src/core/model/calendar-scheduler.cc +++ b/src/core/model/calendar-scheduler.cc @@ -137,8 +137,8 @@ CalendarScheduler::DoInsert(const Event& ev) NS_LOG_LOGIC("insert in bucket=" << bucket); // insert in bucket list. - Bucket::iterator end = m_buckets[bucket].end(); - for (Bucket::iterator i = m_buckets[bucket].begin(); i != end; ++i) + auto end = m_buckets[bucket].end(); + for (auto i = m_buckets[bucket].begin(); i != end; ++i) { if (Order(ev.key, i->key)) { @@ -267,8 +267,8 @@ CalendarScheduler::Remove(const Event& ev) // bucket index of event uint32_t bucket = Hash(ev.key.m_ts); - Bucket::iterator end = m_buckets[bucket].end(); - for (Bucket::iterator i = m_buckets[bucket].begin(); i != end; ++i) + auto end = m_buckets[bucket].end(); + for (auto i = m_buckets[bucket].begin(); i != end; ++i) { if (i->key.m_uid == ev.key.m_uid) { @@ -341,7 +341,7 @@ CalendarScheduler::CalculateNewWidth() samples.push_back(DoRemoveNext()); } // put them back - for (std::list::const_iterator i = samples.begin(); i != samples.end(); ++i) + for (auto i = samples.begin(); i != samples.end(); ++i) { DoInsert(*i); } @@ -353,9 +353,9 @@ CalendarScheduler::CalculateNewWidth() // finally calculate inter-time average over samples. uint64_t totalSeparation = 0; - std::list::const_iterator end = samples.end(); - std::list::const_iterator cur = samples.begin(); - std::list::const_iterator next = cur; + auto end = samples.end(); + auto cur = samples.begin(); + auto next = cur; next++; while (next != end) { @@ -395,8 +395,8 @@ CalendarScheduler::DoResize(uint32_t newSize, uint64_t newWidth) for (uint32_t i = 0; i < oldNBuckets; i++) { - Bucket::iterator end = oldBuckets[i].end(); - for (Bucket::iterator j = oldBuckets[i].begin(); j != end; ++j) + auto end = oldBuckets[i].end(); + for (auto j = oldBuckets[i].begin(); j != end; ++j) { DoInsert(*j); } diff --git a/src/core/model/callback.h b/src/core/model/callback.h index aff4f9fc9..573aa29e6 100644 --- a/src/core/model/callback.h +++ b/src/core/model/callback.h @@ -284,7 +284,7 @@ class CallbackImpl : public CallbackImplBase bool IsEqual(Ptr other) const override { - const CallbackImpl* otherDerived = + const auto otherDerived = dynamic_cast*>(PeekPointer(other)); if (otherDerived == nullptr) diff --git a/src/core/model/config.cc b/src/core/model/config.cc index f6cf3c741..5f6c51aa8 100644 --- a/src/core/model/config.cc +++ b/src/core/model/config.cc @@ -103,7 +103,7 @@ void MatchContainer::Set(std::string name, const AttributeValue& value) { NS_LOG_FUNCTION(this << name << &value); - for (Iterator tmp = Begin(); tmp != End(); ++tmp) + for (auto tmp = Begin(); tmp != End(); ++tmp) { Ptr object = *tmp; // Let ObjectBase::SetAttribute raise any errors @@ -116,7 +116,7 @@ MatchContainer::SetFailSafe(std::string name, const AttributeValue& value) { NS_LOG_FUNCTION(this << name << &value); bool ok = false; - for (Iterator tmp = Begin(); tmp != End(); ++tmp) + for (auto tmp = Begin(); tmp != End(); ++tmp) { Ptr object = *tmp; ok |= object->SetAttributeFailSafe(name, value); @@ -162,7 +162,7 @@ MatchContainer::ConnectWithoutContextFailSafe(std::string name, const CallbackBa { NS_LOG_FUNCTION(this << name << &cb); bool ok = false; - for (Iterator tmp = Begin(); tmp != End(); ++tmp) + for (auto tmp = Begin(); tmp != End(); ++tmp) { Ptr object = *tmp; ok |= object->TraceConnectWithoutContext(name, cb); @@ -187,7 +187,7 @@ void MatchContainer::DisconnectWithoutContext(std::string name, const CallbackBase& cb) { NS_LOG_FUNCTION(this << name << &cb); - for (Iterator tmp = Begin(); tmp != End(); ++tmp) + for (auto tmp = Begin(); tmp != End(); ++tmp) { Ptr object = *tmp; object->TraceDisconnectWithoutContext(name, cb); @@ -423,8 +423,7 @@ Resolver::GetResolvedPath() const NS_LOG_FUNCTION(this); std::string fullPath = "/"; - for (std::vector::const_iterator i = m_workStack.begin(); i != m_workStack.end(); - i++) + for (auto i = m_workStack.begin(); i != m_workStack.end(); i++) { fullPath += *i + "/"; } @@ -549,7 +548,7 @@ Resolver::DoResolve(std::string path, Ptr root) continue; } // attempt to cast to a pointer checker. - const PointerChecker* pChecker = + const auto pChecker = dynamic_cast(PeekPointer(info.checker)); if (pChecker != nullptr) { @@ -572,7 +571,7 @@ Resolver::DoResolve(std::string path, Ptr root) m_workStack.pop_back(); } // attempt to cast to an object vector. - const ObjectPtrContainerChecker* vectorChecker = + const auto vectorChecker = dynamic_cast(PeekPointer(info.checker)); if (vectorChecker != nullptr) { @@ -801,7 +800,7 @@ ConfigImpl::LookupMatches(std::string path) std::vector m_contexts; } resolver = LookupMatchesResolver(path); - for (Roots::const_iterator i = m_roots.begin(); i != m_roots.end(); i++) + for (auto i = m_roots.begin(); i != m_roots.end(); i++) { resolver.Resolve(*i); } @@ -828,7 +827,7 @@ ConfigImpl::UnregisterRootNamespaceObject(Ptr obj) { NS_LOG_FUNCTION(this << obj); - for (std::vector>::iterator i = m_roots.begin(); i != m_roots.end(); i++) + for (auto i = m_roots.begin(); i != m_roots.end(); i++) { if (*i == obj) { @@ -867,7 +866,7 @@ Reset() } } // now, let's reset the initial value of every global value. - for (GlobalValue::Iterator i = GlobalValue::Begin(); i != GlobalValue::End(); ++i) + for (auto i = GlobalValue::Begin(); i != GlobalValue::End(); ++i) { (*i)->ResetInitialValue(); } diff --git a/src/core/model/default-simulator-impl.cc b/src/core/model/default-simulator-impl.cc index b269a3ff1..80742025c 100644 --- a/src/core/model/default-simulator-impl.cc +++ b/src/core/model/default-simulator-impl.cc @@ -319,7 +319,7 @@ DefaultSimulatorImpl::Remove(const EventId& id) if (id.GetUid() == EventId::UID::DESTROY) { // destroy events. - for (DestroyEvents::iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { @@ -365,8 +365,7 @@ DefaultSimulatorImpl::IsExpired(const EventId& id) const return true; } // destroy events. - for (DestroyEvents::const_iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); - i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { diff --git a/src/core/model/double.cc b/src/core/model/double.cc index c3d329190..e3ce84c00 100644 --- a/src/core/model/double.cc +++ b/src/core/model/double.cc @@ -66,7 +66,7 @@ MakeDoubleChecker(double min, double max, std::string name) bool Check(const AttributeValue& value) const override { NS_LOG_FUNCTION(&value); - const DoubleValue* v = dynamic_cast(&value); + const auto v = dynamic_cast(&value); if (v == nullptr) { return false; @@ -103,8 +103,8 @@ MakeDoubleChecker(double min, double max, std::string name) bool Copy(const AttributeValue& source, AttributeValue& destination) const override { NS_LOG_FUNCTION(&source << &destination); - const DoubleValue* src = dynamic_cast(&source); - DoubleValue* dst = dynamic_cast(&destination); + const auto src = dynamic_cast(&source); + auto dst = dynamic_cast(&destination); if (src == nullptr || dst == nullptr) { return false; diff --git a/src/core/model/enum.cc b/src/core/model/enum.cc index 1ca6be73c..907c6fa57 100644 --- a/src/core/model/enum.cc +++ b/src/core/model/enum.cc @@ -73,7 +73,7 @@ std::string EnumValue::SerializeToString(Ptr checker) const { NS_LOG_FUNCTION(this << checker); - const EnumChecker* p = dynamic_cast(PeekPointer(checker)); + const auto p = dynamic_cast(PeekPointer(checker)); NS_ASSERT(p != nullptr); std::string name = p->GetName(m_value); return name; @@ -83,7 +83,7 @@ bool EnumValue::DeserializeFromString(std::string value, Ptr checker) { NS_LOG_FUNCTION(this << value << checker); - const EnumChecker* p = dynamic_cast(PeekPointer(checker)); + const auto p = dynamic_cast(PeekPointer(checker)); NS_ASSERT(p != nullptr); m_value = p->GetValue(value); return true; @@ -150,7 +150,7 @@ bool EnumChecker::Check(const AttributeValue& value) const { NS_LOG_FUNCTION(this << &value); - const EnumValue* p = dynamic_cast(&value); + const auto p = dynamic_cast(&value); if (p == nullptr) { return false; @@ -201,8 +201,8 @@ bool EnumChecker::Copy(const AttributeValue& source, AttributeValue& destination) const { NS_LOG_FUNCTION(this << &source << &destination); - const EnumValue* src = dynamic_cast(&source); - EnumValue* dst = dynamic_cast(&destination); + const auto src = dynamic_cast(&source); + auto dst = dynamic_cast(&destination); if (src == nullptr || dst == nullptr) { return false; diff --git a/src/core/model/global-value.cc b/src/core/model/global-value.cc index 61c70c8a8..679a808dd 100644 --- a/src/core/model/global-value.cc +++ b/src/core/model/global-value.cc @@ -103,7 +103,7 @@ GlobalValue::GetValue(AttributeValue& value) const { return; } - StringValue* str = dynamic_cast(&value); + auto str = dynamic_cast(&value); if (str == nullptr) { NS_FATAL_ERROR("GlobalValue name=" << m_name << ": input value is not a string"); @@ -138,7 +138,7 @@ GlobalValue::Bind(std::string name, const AttributeValue& value) { NS_LOG_FUNCTION(name << &value); - for (Iterator i = Begin(); i != End(); i++) + for (auto i = Begin(); i != End(); i++) { if ((*i)->GetName() == name) { @@ -157,7 +157,7 @@ GlobalValue::BindFailSafe(std::string name, const AttributeValue& value) { NS_LOG_FUNCTION(name << &value); - for (Iterator i = Begin(); i != End(); i++) + for (auto i = Begin(); i != End(); i++) { if ((*i)->GetName() == name) { @@ -193,7 +193,7 @@ bool GlobalValue::GetValueByNameFailSafe(std::string name, AttributeValue& value) { NS_LOG_FUNCTION(name << &value); - for (GlobalValue::Iterator gvit = GlobalValue::Begin(); gvit != GlobalValue::End(); ++gvit) + for (auto gvit = GlobalValue::Begin(); gvit != GlobalValue::End(); ++gvit) { if ((*gvit)->GetName() == name) { diff --git a/src/core/model/int64x64.cc b/src/core/model/int64x64.cc index 54c7dd9f2..a4155328d 100644 --- a/src/core/model/int64x64.cc +++ b/src/core/model/int64x64.cc @@ -74,7 +74,7 @@ operator<<(std::ostream& os, const int64x64_t& value) int64_t hi = absVal.GetHigh(); // Save stream format flags - std::size_t precision = static_cast(os.precision()); + auto precision = static_cast(os.precision()); std::ios_base::fmtflags ff = os.flags(); const bool floatfield = os.flags() & std::ios_base::floatfield; os << std::setw(1) << std::noshowpos; diff --git a/src/core/model/integer.cc b/src/core/model/integer.cc index 6af07bc0b..8dd248ad8 100644 --- a/src/core/model/integer.cc +++ b/src/core/model/integer.cc @@ -65,7 +65,7 @@ MakeIntegerChecker(int64_t min, int64_t max, std::string name) bool Check(const AttributeValue& value) const override { NS_LOG_FUNCTION(&value); - const IntegerValue* v = dynamic_cast(&value); + const auto v = dynamic_cast(&value); if (v == nullptr) { return false; @@ -102,8 +102,8 @@ MakeIntegerChecker(int64_t min, int64_t max, std::string name) bool Copy(const AttributeValue& src, AttributeValue& dst) const override { NS_LOG_FUNCTION(&src << &dst); - const IntegerValue* source = dynamic_cast(&src); - IntegerValue* destination = dynamic_cast(&dst); + const auto source = dynamic_cast(&src); + auto destination = dynamic_cast(&dst); if (source == nullptr || destination == nullptr) { return false; diff --git a/src/core/model/list-scheduler.cc b/src/core/model/list-scheduler.cc index 9d5020409..ea1685d13 100644 --- a/src/core/model/list-scheduler.cc +++ b/src/core/model/list-scheduler.cc @@ -62,7 +62,7 @@ void ListScheduler::Insert(const Event& ev) { NS_LOG_FUNCTION(this << &ev); - for (EventsI i = m_events.begin(); i != m_events.end(); i++) + for (auto i = m_events.begin(); i != m_events.end(); i++) { if (ev.key < i->key) { @@ -100,7 +100,7 @@ void ListScheduler::Remove(const Event& ev) { NS_LOG_FUNCTION(this << &ev); - for (EventsI i = m_events.begin(); i != m_events.end(); i++) + for (auto i = m_events.begin(); i != m_events.end(); i++) { if (i->key.m_uid == ev.key.m_uid) { diff --git a/src/core/model/log.cc b/src/core/model/log.cc index bd4d8ba06..7342615e3 100644 --- a/src/core/model/log.cc +++ b/src/core/model/log.cc @@ -320,9 +320,7 @@ void LogComponentEnableAll(LogLevel level) { LogComponent::ComponentList* components = LogComponent::GetComponentList(); - for (LogComponent::ComponentList::const_iterator i = components->begin(); - i != components->end(); - i++) + for (auto i = components->begin(); i != components->end(); i++) { i->second->Enable(level); } @@ -344,9 +342,7 @@ void LogComponentDisableAll(LogLevel level) { LogComponent::ComponentList* components = LogComponent::GetComponentList(); - for (LogComponent::ComponentList::const_iterator i = components->begin(); - i != components->end(); - i++) + for (auto i = components->begin(); i != components->end(); i++) { i->second->Disable(level); } diff --git a/src/core/model/map-scheduler.cc b/src/core/model/map-scheduler.cc index fd18503c7..aaa50fd09 100644 --- a/src/core/model/map-scheduler.cc +++ b/src/core/model/map-scheduler.cc @@ -79,7 +79,7 @@ Scheduler::Event MapScheduler::PeekNext() const { NS_LOG_FUNCTION(this); - EventMapCI i = m_list.begin(); + auto i = m_list.begin(); NS_ASSERT(i != m_list.end()); Event ev; @@ -93,7 +93,7 @@ Scheduler::Event MapScheduler::RemoveNext() { NS_LOG_FUNCTION(this); - EventMapI i = m_list.begin(); + auto i = m_list.begin(); NS_ASSERT(i != m_list.end()); Event ev; ev.impl = i->second; @@ -107,7 +107,7 @@ void MapScheduler::Remove(const Event& ev) { NS_LOG_FUNCTION(this << ev.impl << ev.key.m_ts << ev.key.m_uid); - EventMapI i = m_list.find(ev.key); + auto i = m_list.find(ev.key); NS_ASSERT(i->second == ev.impl); m_list.erase(i); } diff --git a/src/core/model/names.cc b/src/core/model/names.cc index 6a0976073..c3b40a184 100644 --- a/src/core/model/names.cc +++ b/src/core/model/names.cc @@ -303,8 +303,7 @@ NamesPriv::Clear() // Every name is associated with an object in the object map, so freeing the // NameNodes in this map will free all of the memory allocated for the NameNodes // - for (std::map, NameNode*>::iterator i = m_objectMap.begin(); i != m_objectMap.end(); - ++i) + for (auto i = m_objectMap.begin(); i != m_objectMap.end(); ++i) { delete i->second; i->second = nullptr; @@ -420,7 +419,7 @@ NamesPriv::Add(Ptr context, std::string name, Ptr object) return false; } - NameNode* newNode = new NameNode(node, name, object); + auto newNode = new NameNode(node, name, object); node->m_nameMap[name] = newNode; m_objectMap[object] = newNode; @@ -525,7 +524,7 @@ NamesPriv::Rename(Ptr context, std::string oldname, std::string newname) return false; } - std::map::iterator i = node->m_nameMap.find(oldname); + auto i = node->m_nameMap.find(oldname); if (i == node->m_nameMap.end()) { NS_LOG_LOGIC("Old name does not exist in name map"); @@ -555,7 +554,7 @@ NamesPriv::FindName(Ptr object) { NS_LOG_FUNCTION(this << object); - std::map, NameNode*>::iterator i = m_objectMap.find(object); + auto i = m_objectMap.find(object); if (i == m_objectMap.end()) { NS_LOG_LOGIC("Object does not exist in object map"); @@ -573,7 +572,7 @@ NamesPriv::FindPath(Ptr object) { NS_LOG_FUNCTION(this << object); - std::map, NameNode*>::iterator i = m_objectMap.find(object); + auto i = m_objectMap.find(object); if (i == m_objectMap.end()) { NS_LOG_LOGIC("Object does not exist in object map"); @@ -648,7 +647,7 @@ NamesPriv::Find(std::string path) // There are no remaining slashes so this is the last segment of the // specified name. We're done when we find it // - std::map::iterator i = node->m_nameMap.find(remaining); + auto i = node->m_nameMap.find(remaining); if (i == node->m_nameMap.end()) { NS_LOG_LOGIC("Name does not exist in name map"); @@ -669,7 +668,7 @@ NamesPriv::Find(std::string path) offset = remaining.find('/'); std::string segment = remaining.substr(0, offset); - std::map::iterator i = node->m_nameMap.find(segment); + auto i = node->m_nameMap.find(segment); if (i == node->m_nameMap.end()) { NS_LOG_LOGIC("Name does not exist in name map"); @@ -723,7 +722,7 @@ NamesPriv::Find(Ptr context, std::string name) } } - std::map::iterator i = node->m_nameMap.find(name); + auto i = node->m_nameMap.find(name); if (i == node->m_nameMap.end()) { NS_LOG_LOGIC("Name does not exist in name map"); @@ -741,7 +740,7 @@ NamesPriv::IsNamed(Ptr object) { NS_LOG_FUNCTION(this << object); - std::map, NameNode*>::iterator i = m_objectMap.find(object); + auto i = m_objectMap.find(object); if (i == m_objectMap.end()) { NS_LOG_LOGIC("Object does not exist in object map, returning NameNode 0"); @@ -759,7 +758,7 @@ NamesPriv::IsDuplicateName(NameNode* node, std::string name) { NS_LOG_FUNCTION(this << node << name); - std::map::iterator i = node->m_nameMap.find(name); + auto i = node->m_nameMap.find(name); if (i == node->m_nameMap.end()) { NS_LOG_LOGIC("Name does not exist in name map"); diff --git a/src/core/model/nstime.h b/src/core/model/nstime.h index 0db5feb0f..de142ccfd 100644 --- a/src/core/model/nstime.h +++ b/src/core/model/nstime.h @@ -580,7 +580,7 @@ class Time NS_ASSERT_MSG(info->isValid, "Attempted a conversion to an unavailable unit."); - int64x64_t retval = int64x64_t(m_data); + int64x64_t retval(m_data); if (info->toMul) { retval *= info->timeTo; diff --git a/src/core/model/object-base.cc b/src/core/model/object-base.cc index 14d61f81e..6a9b78df7 100644 --- a/src/core/model/object-base.cc +++ b/src/core/model/object-base.cc @@ -261,7 +261,7 @@ ObjectBase::GetAttribute(std::string name, AttributeValue& value) const { return; } - StringValue* str = dynamic_cast(&value); + auto str = dynamic_cast(&value); if (str == nullptr) { NS_FATAL_ERROR("Attribute name=" << name << " tid=" << tid.GetName() @@ -296,7 +296,7 @@ ObjectBase::GetAttributeFailSafe(std::string name, AttributeValue& value) const { return true; } - StringValue* str = dynamic_cast(&value); + auto str = dynamic_cast(&value); if (str == nullptr) { return false; diff --git a/src/core/model/object-factory.cc b/src/core/model/object-factory.cc index e6e29effa..7f13067d9 100644 --- a/src/core/model/object-factory.cc +++ b/src/core/model/object-factory.cc @@ -95,7 +95,7 @@ ObjectFactory::Create() const NS_LOG_FUNCTION(this); Callback cb = m_tid.GetConstructor(); ObjectBase* base = cb(); - Object* derived = dynamic_cast(base); + auto derived = dynamic_cast(base); NS_ASSERT(derived != nullptr); derived->SetTypeId(m_tid); derived->Construct(m_parameters); @@ -108,9 +108,7 @@ operator<<(std::ostream& os, const ObjectFactory& factory) { os << factory.m_tid.GetName() << "["; bool first = true; - for (AttributeConstructionList::CIterator i = factory.m_parameters.Begin(); - i != factory.m_parameters.End(); - ++i) + for (auto i = factory.m_parameters.Begin(); i != factory.m_parameters.End(); ++i) { os << i->name << "=" << i->value->SerializeToString(i->checker); if (first) diff --git a/src/core/model/object-map.h b/src/core/model/object-map.h index 1adf11477..0a4c17b8a 100644 --- a/src/core/model/object-map.h +++ b/src/core/model/object-map.h @@ -93,10 +93,10 @@ MakeObjectMapAccessor(U T::*memberVector) std::size_t* index) const override { const T* obj = static_cast(object); - typename U::const_iterator begin = (obj->*m_memberVector).begin(); - typename U::const_iterator end = (obj->*m_memberVector).end(); + auto begin = (obj->*m_memberVector).begin(); + auto end = (obj->*m_memberVector).end(); uint32_t k = 0; - for (typename U::const_iterator j = begin; j != end; j++, k++) + for (auto j = begin; j != end; j++, k++) { if (k == i) { diff --git a/src/core/model/object-ptr-container.cc b/src/core/model/object-ptr-container.cc index b8d5a0619..974f7ef9b 100644 --- a/src/core/model/object-ptr-container.cc +++ b/src/core/model/object-ptr-container.cc @@ -61,7 +61,7 @@ Ptr ObjectPtrContainerValue::Get(std::size_t i) const { NS_LOG_FUNCTION(this << i); - Iterator it = m_objects.find(i); + auto it = m_objects.find(i); Ptr value = nullptr; if (it != m_objects.end()) { @@ -115,7 +115,7 @@ bool ObjectPtrContainerAccessor::Get(const ObjectBase* object, AttributeValue& value) const { NS_LOG_FUNCTION(this << object << &value); - ObjectPtrContainerValue* v = dynamic_cast(&value); + auto v = dynamic_cast(&value); if (v == nullptr) { return false; diff --git a/src/core/model/object-ptr-container.h b/src/core/model/object-ptr-container.h index a924fb6ef..931ad9f32 100644 --- a/src/core/model/object-ptr-container.h +++ b/src/core/model/object-ptr-container.h @@ -208,8 +208,8 @@ class ObjectPtrContainerChecker : public ns3::ObjectPtrContainerChecker bool Copy(const AttributeValue& source, AttributeValue& destination) const override { - const ObjectPtrContainerValue* src = dynamic_cast(&source); - ObjectPtrContainerValue* dst = dynamic_cast(&destination); + const auto src = dynamic_cast(&source); + auto dst = dynamic_cast(&destination); if (src == nullptr || dst == nullptr) { return false; diff --git a/src/core/model/object-vector.h b/src/core/model/object-vector.h index 30c03a414..36194507c 100644 --- a/src/core/model/object-vector.h +++ b/src/core/model/object-vector.h @@ -93,10 +93,10 @@ MakeObjectVectorAccessor(U T::*memberVector) std::size_t* index) const override { const T* obj = static_cast(object); - typename U::const_iterator begin = (obj->*m_memberVector).begin(); - typename U::const_iterator end = (obj->*m_memberVector).end(); + auto begin = (obj->*m_memberVector).begin(); + auto end = (obj->*m_memberVector).end(); std::size_t k = 0; - for (typename U::const_iterator j = begin; j != end; j++, k++) + for (auto j = begin; j != end; j++, k++) { if (k == i) { diff --git a/src/core/model/object.cc b/src/core/model/object.cc index f4ea12aa4..176fed3a5 100644 --- a/src/core/model/object.cc +++ b/src/core/model/object.cc @@ -267,8 +267,7 @@ Object::AggregateObject(Ptr o) Object* other = PeekPointer(o); // first create the new aggregate buffer. uint32_t total = m_aggregates->n + other->m_aggregates->n; - Aggregates* aggregates = - (Aggregates*)std::malloc(sizeof(Aggregates) + (total - 1) * sizeof(Object*)); + auto aggregates = (Aggregates*)std::malloc(sizeof(Aggregates) + (total - 1) * sizeof(Object*)); aggregates->n = total; // copy our buffer to the new buffer diff --git a/src/core/model/pointer.h b/src/core/model/pointer.h index e14cbe461..228226def 100644 --- a/src/core/model/pointer.h +++ b/src/core/model/pointer.h @@ -129,7 +129,7 @@ class PointerChecker : public ns3::PointerChecker { bool Check(const AttributeValue& val) const override { - const PointerValue* value = dynamic_cast(&val); + const auto value = dynamic_cast(&val); if (value == nullptr) { return false; @@ -166,8 +166,8 @@ class PointerChecker : public ns3::PointerChecker bool Copy(const AttributeValue& source, AttributeValue& destination) const override { - const PointerValue* src = dynamic_cast(&source); - PointerValue* dst = dynamic_cast(&destination); + const auto src = dynamic_cast(&source); + auto dst = dynamic_cast(&destination); if (src == nullptr || dst == nullptr) { return false; diff --git a/src/core/model/realtime-simulator-impl.cc b/src/core/model/realtime-simulator-impl.cc index 23974dcf8..9c4152dc6 100644 --- a/src/core/model/realtime-simulator-impl.cc +++ b/src/core/model/realtime-simulator-impl.cc @@ -704,7 +704,7 @@ RealtimeSimulatorImpl::Remove(const EventId& id) if (id.GetUid() == EventId::UID::DESTROY) { // destroy events. - for (DestroyEvents::iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { @@ -754,8 +754,7 @@ RealtimeSimulatorImpl::IsExpired(const EventId& id) const return true; } // destroy events. - for (DestroyEvents::const_iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); - i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { diff --git a/src/core/model/system-path.cc b/src/core/model/system-path.cc index 9265ee501..6ab4927e9 100644 --- a/src/core/model/system-path.cc +++ b/src/core/model/system-path.cc @@ -141,7 +141,7 @@ Dirname(std::string path) { NS_LOG_FUNCTION(path); std::list elements = Split(path); - std::list::const_iterator last = elements.end(); + auto last = elements.end(); last--; return Join(elements.begin(), last); } @@ -268,7 +268,7 @@ Join(std::list::const_iterator begin, std::list::const { NS_LOG_FUNCTION(*begin << *end); std::string retval = ""; - for (std::list::const_iterator i = begin; i != end; i++) + for (auto i = begin; i != end; i++) { if ((*i).empty()) { diff --git a/src/core/model/test.cc b/src/core/model/test.cc index 85d7c5530..1b319c9d4 100644 --- a/src/core/model/test.cc +++ b/src/core/model/test.cc @@ -290,7 +290,7 @@ TestCase::~TestCase() NS_ASSERT(m_runner == nullptr); m_parent = nullptr; delete m_result; - for (std::vector::const_iterator i = m_children.begin(); i != m_children.end(); ++i) + for (auto i = m_children.begin(); i != m_children.end(); ++i) { delete *i; } @@ -353,7 +353,7 @@ TestCase::Run(TestRunnerImpl* runner) m_runner = runner; DoSetup(); m_result->clock.Start(); - for (std::vector::const_iterator i = m_children.begin(); i != m_children.end(); ++i) + for (auto i = m_children.begin(); i != m_children.end(); ++i) { TestCase* test = *i; test->Run(runner); @@ -571,7 +571,7 @@ TestRunnerImpl::IsTopLevelSourceDir(std::string path) const // std::list files = SystemPath::ReadFiles(path); - for (std::list::const_iterator i = files.begin(); i != files.end(); ++i) + for (auto i = files.begin(); i != files.end(); ++i) { if (*i == "VERSION") { @@ -629,7 +629,7 @@ TestRunnerImpl::ReplaceXmlSpecialCharacters(std::string xml) const { char character = xml[i]; - specials_map::const_iterator it = specials.find(character); + auto it = specials.find(character); if (it == specials.end()) { @@ -802,9 +802,9 @@ TestRunnerImpl::PrintTestNameList(std::list::const_iterator begin, label[TestSuite::EXAMPLE] = "example "; label[TestSuite::PERFORMANCE] = "performance "; - for (std::list::const_iterator i = begin; i != end; ++i) + for (auto i = begin; i != end; ++i) { - TestSuite* test = dynamic_cast(*i); + auto test = dynamic_cast(*i); NS_ASSERT(test != nullptr); if (printTestType) { @@ -852,8 +852,7 @@ TestRunnerImpl::FilterTests(std::string testName, } // Remove any test cases that should be skipped. - std::vector::iterator j; - for (j = test->m_children.begin(); j != test->m_children.end();) + for (auto j = test->m_children.begin(); j != test->m_children.end();) { TestCase* testCase = *j; @@ -1090,7 +1089,7 @@ TestRunnerImpl::Run(int argc, char* argv[]) return 1; } - for (std::list::const_iterator i = tests.begin(); i != tests.end(); ++i) + for (auto i = tests.begin(); i != tests.end(); ++i) { TestCase* test = *i; diff --git a/src/core/model/time.cc b/src/core/model/time.cc index f89a95621..69c1078f6 100644 --- a/src/core/model/time.cc +++ b/src/core/model/time.cc @@ -255,7 +255,7 @@ Time::SetResolution(Unit unit, Resolution* resolution, const bool convert /* = t info->isValid = false; continue; } - int64_t factor = static_cast(std::pow(10, std::fabs(shift)) * quotient); + auto factor = static_cast(std::pow(10, std::fabs(shift)) * quotient); double realFactor = std::pow(10, (double)shift) * static_cast(UNIT_COEFF[i]) / UNIT_COEFF[(int)unit]; NS_LOG_DEBUG("SetResolution factor " << factor << " real factor " << realFactor); @@ -333,9 +333,7 @@ Time::Mark(Time* const time) // since earlier test was outside and might be stale. if (g_markingTimes) { - std::pair ret; - - ret = g_markingTimes->insert(time); + auto ret = g_markingTimes->insert(time); NS_LOG_LOGIC("\t[" << g_markingTimes->size() << "] recording " << time); if (!ret.second) @@ -385,7 +383,7 @@ Time::ConvertTimes(const Unit unit) "No MarkedTimes registry. " "Time::SetResolution () called more than once?"); - for (MarkedTimes::iterator it = g_markingTimes->begin(); it != g_markingTimes->end(); it++) + for (auto it = g_markingTimes->begin(); it != g_markingTimes->end(); it++) { Time* const tp = *it; if (!(tp->m_data == std::numeric_limits::min() || @@ -434,7 +432,7 @@ operator<<(std::ostream& os, const TimeWithUnit& timeU) if (unit == Time::AUTO) { - long double value = static_cast(timeU.m_time.GetTimeStep()); + auto value = static_cast(timeU.m_time.GetTimeStep()); // convert to finest scale (fs) value *= Scale(Time::GetResolution()); // find the best unit @@ -547,7 +545,7 @@ MakeTimeChecker(const Time min, const Time max) bool Check(const AttributeValue& value) const override { NS_LOG_FUNCTION(&value); - const TimeValue* v = dynamic_cast(&value); + const auto v = dynamic_cast(&value); if (v == nullptr) { return false; @@ -585,8 +583,8 @@ MakeTimeChecker(const Time min, const Time max) bool Copy(const AttributeValue& source, AttributeValue& destination) const override { NS_LOG_FUNCTION(&source << &destination); - const TimeValue* src = dynamic_cast(&source); - TimeValue* dst = dynamic_cast(&destination); + const auto src = dynamic_cast(&source); + auto dst = dynamic_cast(&destination); if (src == nullptr || dst == nullptr) { return false; diff --git a/src/core/model/timer-impl.h b/src/core/model/timer-impl.h index 0e0b3dabc..88996f227 100644 --- a/src/core/model/timer-impl.h +++ b/src/core/model/timer-impl.h @@ -1085,7 +1085,7 @@ void TimerImpl::SetArgs(T1 a1) { typedef TimerImplOne::ParameterType> TimerImplBase; - TimerImplBase* impl = dynamic_cast(this); + auto impl = dynamic_cast(this); if (impl == nullptr) { NS_FATAL_ERROR("You tried to set Timer arguments incompatible with its function."); @@ -1101,7 +1101,7 @@ TimerImpl::SetArgs(T1 a1, T2 a2) typedef TimerImplTwo::ParameterType, typename TimerTraits::ParameterType> TimerImplBase; - TimerImplBase* impl = dynamic_cast(this); + auto impl = dynamic_cast(this); if (impl == nullptr) { NS_FATAL_ERROR("You tried to set Timer arguments incompatible with its function."); @@ -1118,7 +1118,7 @@ TimerImpl::SetArgs(T1 a1, T2 a2, T3 a3) typename TimerTraits::ParameterType, typename TimerTraits::ParameterType> TimerImplBase; - TimerImplBase* impl = dynamic_cast(this); + auto impl = dynamic_cast(this); if (impl == nullptr) { NS_FATAL_ERROR("You tried to set Timer arguments incompatible with its function."); @@ -1136,7 +1136,7 @@ TimerImpl::SetArgs(T1 a1, T2 a2, T3 a3, T4 a4) typename TimerTraits::ParameterType, typename TimerTraits::ParameterType> TimerImplBase; - TimerImplBase* impl = dynamic_cast(this); + auto impl = dynamic_cast(this); if (impl == nullptr) { NS_FATAL_ERROR("You tried to set Timer arguments incompatible with its function."); @@ -1155,7 +1155,7 @@ TimerImpl::SetArgs(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) typename TimerTraits::ParameterType, typename TimerTraits::ParameterType> TimerImplBase; - TimerImplBase* impl = dynamic_cast(this); + auto impl = dynamic_cast(this); if (impl == nullptr) { NS_FATAL_ERROR("You tried to set Timer arguments incompatible with its function."); @@ -1175,7 +1175,7 @@ TimerImpl::SetArgs(T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) typename TimerTraits::ParameterType, typename TimerTraits::ParameterType> TimerImplBase; - TimerImplBase* impl = dynamic_cast(this); + auto impl = dynamic_cast(this); if (impl == 0) { NS_FATAL_ERROR("You tried to set Timer arguments incompatible with its function."); diff --git a/src/core/model/traced-callback.h b/src/core/model/traced-callback.h index 76bf199c7..1cbc2874f 100644 --- a/src/core/model/traced-callback.h +++ b/src/core/model/traced-callback.h @@ -162,8 +162,7 @@ template void TracedCallback::DisconnectWithoutContext(const CallbackBase& callback) { - for (typename CallbackList::iterator i = m_callbackList.begin(); i != m_callbackList.end(); - /* empty */) + for (auto i = m_callbackList.begin(); i != m_callbackList.end(); /* empty */) { if ((*i).IsEqual(callback)) { @@ -193,9 +192,7 @@ template void TracedCallback::operator()(Ts... args) const { - for (typename CallbackList::const_iterator i = m_callbackList.begin(); - i != m_callbackList.end(); - i++) + for (auto i = m_callbackList.begin(); i != m_callbackList.end(); i++) { (*i)(args...); } diff --git a/src/core/model/tuple.h b/src/core/model/tuple.h index f107480d0..570c2726b 100644 --- a/src/core/model/tuple.h +++ b/src/core/model/tuple.h @@ -368,7 +368,7 @@ class TupleChecker : public ns3::TupleChecker bool Check(const AttributeValue& value) const override { - const TupleValue* v = dynamic_cast*>(&value); + const auto v = dynamic_cast*>(&value); if (v == nullptr) { return false; @@ -403,8 +403,8 @@ class TupleChecker : public ns3::TupleChecker bool Copy(const AttributeValue& source, AttributeValue& destination) const override { - const TupleValue* src = dynamic_cast*>(&source); - TupleValue* dst = dynamic_cast*>(&destination); + const auto src = dynamic_cast*>(&source); + auto dst = dynamic_cast*>(&destination); if (src == nullptr || dst == nullptr) { return false; diff --git a/src/core/model/type-id.cc b/src/core/model/type-id.cc index d847da779..f1929df06 100644 --- a/src/core/model/type-id.cc +++ b/src/core/model/type-id.cc @@ -443,7 +443,7 @@ IidManager::AllocateUid(std::string name) m_information.push_back(information); std::size_t tuid = m_information.size(); NS_ASSERT(tuid <= 0xffff); - uint16_t uid = static_cast(tuid); + auto uid = static_cast(tuid); // Add to both maps: m_namemap.insert(std::make_pair(name, uid)); @@ -512,7 +512,7 @@ IidManager::GetUid(std::string name) const { NS_LOG_FUNCTION(IID << name); uint16_t uid = 0; - namemap_t::const_iterator it = m_namemap.find(name); + auto it = m_namemap.find(name); if (it != m_namemap.end()) { uid = it->second; @@ -525,7 +525,7 @@ uint16_t IidManager::GetUid(TypeId::hash_t hash) const { NS_LOG_FUNCTION(IID << hash); - hashmap_t::const_iterator it = m_hashmap.find(hash); + auto it = m_hashmap.find(hash); uint16_t uid = 0; if (it != m_hashmap.end()) { @@ -627,10 +627,7 @@ IidManager::HasAttribute(uint16_t uid, std::string name) IidInformation* information = LookupInformation(uid); while (true) { - for (std::vector::const_iterator i = - information->attributes.begin(); - i != information->attributes.end(); - ++i) + for (auto i = information->attributes.begin(); i != information->attributes.end(); ++i) { if (i->name == name) { @@ -729,10 +726,7 @@ IidManager::HasTraceSource(uint16_t uid, std::string name) IidInformation* information = LookupInformation(uid); while (true) { - for (std::vector::const_iterator i = - information->traceSources.begin(); - i != information->traceSources.end(); - ++i) + for (auto i = information->traceSources.begin(); i != information->traceSources.end(); ++i) { if (i->name == name) { diff --git a/src/core/model/uinteger.cc b/src/core/model/uinteger.cc index 77a40e029..a320bf3bf 100644 --- a/src/core/model/uinteger.cc +++ b/src/core/model/uinteger.cc @@ -65,7 +65,7 @@ MakeUintegerChecker(uint64_t min, uint64_t max, std::string name) bool Check(const AttributeValue& value) const override { NS_LOG_FUNCTION(&value); - const UintegerValue* v = dynamic_cast(&value); + const auto v = dynamic_cast(&value); if (v == nullptr) { return false; @@ -102,8 +102,8 @@ MakeUintegerChecker(uint64_t min, uint64_t max, std::string name) bool Copy(const AttributeValue& source, AttributeValue& destination) const override { NS_LOG_FUNCTION(&source << &destination); - const UintegerValue* src = dynamic_cast(&source); - UintegerValue* dst = dynamic_cast(&destination); + const auto src = dynamic_cast(&source); + auto dst = dynamic_cast(&destination); if (src == nullptr || dst == nullptr) { return false; diff --git a/src/core/model/wall-clock-synchronizer.cc b/src/core/model/wall-clock-synchronizer.cc index ea8b87546..0f1d386f7 100644 --- a/src/core/model/wall-clock-synchronizer.cc +++ b/src/core/model/wall-clock-synchronizer.cc @@ -363,7 +363,7 @@ WallClockSynchronizer::DriftCorrect(uint64_t nsNow, uint64_t nsDelay) // have more drift than delay, then we just play catch up as fast as possible // by not delaying at all. // - uint64_t correction = (uint64_t)drift; + auto correction = (uint64_t)drift; if (correction <= nsDelay) { return nsDelay - correction; diff --git a/src/core/test/global-value-test-suite.cc b/src/core/test/global-value-test-suite.cc index d22fbb61c..aabacd289 100644 --- a/src/core/test/global-value-test-suite.cc +++ b/src/core/test/global-value-test-suite.cc @@ -84,7 +84,7 @@ GlobalValueTestCase::DoRun() // Remove the global value for a valgrind clean run // GlobalValue::Vector* vector = GlobalValue::GetVector(); - for (GlobalValue::Vector::iterator i = vector->begin(); i != vector->end(); ++i) + for (auto i = vector->begin(); i != vector->end(); ++i) { if ((*i) == &uint) { diff --git a/src/core/test/int64x64-test-suite.cc b/src/core/test/int64x64-test-suite.cc index b3374563e..cf9933bb8 100644 --- a/src/core/test/int64x64-test-suite.cc +++ b/src/core/test/int64x64-test-suite.cc @@ -620,7 +620,7 @@ Int64x64Bug455TestCase::DoRun() std::cout << std::endl; std::cout << GetParent()->GetName() << " Bug 455: " << GetName() << std::endl; - int64x64_t a = int64x64_t(0.1); + int64x64_t a(0.1); a /= int64x64_t(1.25); Check(a.GetDouble(), 0.08, "The original testcase"); @@ -684,7 +684,7 @@ Int64x64Bug863TestCase::DoRun() std::cout << std::endl; std::cout << GetParent()->GetName() << " Bug 863: " << GetName() << std::endl; - int64x64_t a = int64x64_t(0.9); + int64x64_t a(0.9); a /= int64x64_t(1); Check(a.GetDouble(), 0.9, "The original testcase"); @@ -1033,7 +1033,7 @@ Int64x64InvertTestCase::Check(const int64_t factor) const int64x64_t factorI = one / int64x64_t(factor); const int64x64_t a = int64x64_t::Invert(factor); - int64x64_t b = int64x64_t(factor); + int64x64_t b(factor); double tolerance = 0; if (int64x64_t::implementation == int64x64_t::ld_impl) @@ -1045,15 +1045,15 @@ Int64x64InvertTestCase::Check(const int64_t factor) b.MulByInvert(a); CheckCase(factor, b, one, "x * x^-1 == 1", tolerance); - int64x64_t c = int64x64_t(1); + int64x64_t c(1); c.MulByInvert(a); CheckCase(factor, c, factorI, "1 * x^-1 == 1 / x"); - int64x64_t d = int64x64_t(1); + int64x64_t d(1); d /= (int64x64_t(factor)); CheckCase(factor, d, c, "1/x == x^-1"); - int64x64_t e = int64x64_t(-factor); + int64x64_t e(-factor); e.MulByInvert(a); CheckCase(factor, e, -one, "-x * x^-1 == -1", tolerance); } diff --git a/src/csma/examples/csma-ping.cc b/src/csma/examples/csma-ping.cc index 14389631a..ca663a0f8 100644 --- a/src/csma/examples/csma-ping.cc +++ b/src/csma/examples/csma-ping.cc @@ -100,7 +100,7 @@ main(int argc, char* argv[]) NS_LOG_INFO("Create Source"); Config::SetDefault("ns3::Ipv4RawSocketImpl::Protocol", StringValue("2")); - InetSocketAddress dst = InetSocketAddress(addresses.GetAddress(3)); + InetSocketAddress dst(addresses.GetAddress(3)); OnOffHelper onoff = OnOffHelper("ns3::Ipv4RawSocketFactory", dst); onoff.SetConstantRate(DataRate(15000)); onoff.SetAttribute("PacketSize", UintegerValue(1200)); diff --git a/src/csma/examples/csma-raw-ip-socket.cc b/src/csma/examples/csma-raw-ip-socket.cc index 698baa4a7..2be6a2ac0 100644 --- a/src/csma/examples/csma-raw-ip-socket.cc +++ b/src/csma/examples/csma-raw-ip-socket.cc @@ -93,7 +93,7 @@ main(int argc, char* argv[]) NS_LOG_INFO("Create Source"); // IP protocol configuration Config::SetDefault("ns3::Ipv4RawSocketImpl::Protocol", StringValue("2")); - InetSocketAddress dst = InetSocketAddress(addresses.GetAddress(3)); + InetSocketAddress dst(addresses.GetAddress(3)); OnOffHelper onoff = OnOffHelper("ns3::Ipv4RawSocketFactory", dst); onoff.SetConstantRate(DataRate(dataRate * 1000)); onoff.SetAttribute("PacketSize", UintegerValue(1250)); diff --git a/src/csma/helper/csma-helper.cc b/src/csma/helper/csma-helper.cc index 58549237e..2057b6b37 100644 --- a/src/csma/helper/csma-helper.cc +++ b/src/csma/helper/csma-helper.cc @@ -277,7 +277,7 @@ CsmaHelper::Install(const NodeContainer& c, Ptr channel) const { NetDeviceContainer devs; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { devs.Add(InstallPriv(*i, channel)); } @@ -297,7 +297,7 @@ CsmaHelper::AssignStreams(NetDeviceContainer c, int64_t stream) { int64_t currentStream = stream; Ptr netDevice; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { netDevice = (*i); Ptr csma = DynamicCast(netDevice); diff --git a/src/csma/model/backoff.cc b/src/csma/model/backoff.cc index 656156076..ae40bb717 100644 --- a/src/csma/model/backoff.cc +++ b/src/csma/model/backoff.cc @@ -75,7 +75,7 @@ Backoff::GetBackoffTime() maxSlot = m_maxSlots; } - uint32_t backoffSlots = (uint32_t)m_rng->GetValue(minSlot, maxSlot); + auto backoffSlots = (uint32_t)m_rng->GetValue(minSlot, maxSlot); Time backoff = Time(backoffSlots * m_slotTime); return backoff; diff --git a/src/csma/model/csma-channel.cc b/src/csma/model/csma-channel.cc index 9c9f253a6..2a0defc8c 100644 --- a/src/csma/model/csma-channel.cc +++ b/src/csma/model/csma-channel.cc @@ -86,8 +86,7 @@ CsmaChannel::Reattach(Ptr device) NS_LOG_FUNCTION(this << device); NS_ASSERT(device); - std::vector::iterator it; - for (it = m_deviceList.begin(); it < m_deviceList.end(); it++) + for (auto it = m_deviceList.begin(); it < m_deviceList.end(); it++) { if (it->devicePtr == device) { @@ -161,8 +160,7 @@ CsmaChannel::Detach(Ptr device) NS_LOG_FUNCTION(this << device); NS_ASSERT(device); - std::vector::iterator it; - for (it = m_deviceList.begin(); it < m_deviceList.end(); it++) + for (auto it = m_deviceList.begin(); it < m_deviceList.end(); it++) { if ((it->devicePtr == device) && (it->active)) { @@ -227,8 +225,7 @@ CsmaChannel::TransmitEnd() NS_LOG_LOGIC("Receive"); - std::vector::iterator it; - for (it = m_deviceList.begin(); it < m_deviceList.end(); it++) + for (auto it = m_deviceList.begin(); it < m_deviceList.end(); it++) { if (it->IsActive() && it->devicePtr != m_deviceList[m_currentSrc].devicePtr) { @@ -261,8 +258,7 @@ uint32_t CsmaChannel::GetNumActDevices() { int numActDevices = 0; - std::vector::iterator it; - for (it = m_deviceList.begin(); it < m_deviceList.end(); it++) + for (auto it = m_deviceList.begin(); it < m_deviceList.end(); it++) { if (it->active) { @@ -287,9 +283,8 @@ CsmaChannel::GetCsmaDevice(std::size_t i) const int32_t CsmaChannel::GetDeviceNum(Ptr device) { - std::vector::iterator it; int i = 0; - for (it = m_deviceList.begin(); it < m_deviceList.end(); it++) + for (auto it = m_deviceList.begin(); it < m_deviceList.end(); it++) { if (it->devicePtr == device) { diff --git a/src/dsdv/model/dsdv-packet-queue.cc b/src/dsdv/model/dsdv-packet-queue.cc index 40c447a14..57ea72f54 100644 --- a/src/dsdv/model/dsdv-packet-queue.cc +++ b/src/dsdv/model/dsdv-packet-queue.cc @@ -56,7 +56,7 @@ PacketQueue::Enqueue(QueueEntry& entry) NS_LOG_FUNCTION("Enqueuing packet destined for" << entry.GetIpv4Header().GetDestination()); Purge(); uint32_t numPacketswithdst; - for (std::vector::const_iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if ((i->GetPacket()->GetUid() == entry.GetPacket()->GetUid()) && (i->GetIpv4Header().GetDestination() == entry.GetIpv4Header().GetDestination())) @@ -86,7 +86,7 @@ PacketQueue::DropPacketWithDst(Ipv4Address dst) { NS_LOG_FUNCTION("Dropping packet to " << dst); Purge(); - for (std::vector::iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (i->GetIpv4Header().GetDestination() == dst) { @@ -104,7 +104,7 @@ PacketQueue::Dequeue(Ipv4Address dst, QueueEntry& entry) { NS_LOG_FUNCTION("Dequeueing packet destined for" << dst); Purge(); - for (std::vector::iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (i->GetIpv4Header().GetDestination() == dst) { @@ -119,7 +119,7 @@ PacketQueue::Dequeue(Ipv4Address dst, QueueEntry& entry) bool PacketQueue::Find(Ipv4Address dst) { - for (std::vector::const_iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (i->GetIpv4Header().GetDestination() == dst) { @@ -134,7 +134,7 @@ uint32_t PacketQueue::GetCountForPacketsWithDst(Ipv4Address dst) { uint32_t count = 0; - for (std::vector::const_iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (i->GetIpv4Header().GetDestination() == dst) { @@ -166,7 +166,7 @@ PacketQueue::Purge() { // NS_LOG_DEBUG("Purging Queue"); IsExpired pred; - for (std::vector::iterator i = m_queue.begin(); i != m_queue.end(); ++i) + for (auto i = m_queue.begin(); i != m_queue.end(); ++i) { if (pred(*i)) { diff --git a/src/dsdv/model/dsdv-routing-protocol.cc b/src/dsdv/model/dsdv-routing-protocol.cc index fe169ece5..c5681653b 100644 --- a/src/dsdv/model/dsdv-routing-protocol.cc +++ b/src/dsdv/model/dsdv-routing-protocol.cc @@ -241,9 +241,7 @@ void RoutingProtocol::DoDispose() { m_ipv4 = nullptr; - for (std::map, Ipv4InterfaceAddress>::iterator iter = m_socketAddresses.begin(); - iter != m_socketAddresses.end(); - iter++) + for (auto iter = m_socketAddresses.begin(); iter != m_socketAddresses.end(); iter++) { iter->first->Close(); } @@ -304,9 +302,7 @@ RoutingProtocol::RouteOutput(Ptr p, << ", Destination address in Packet: " << dst); RoutingTableEntry rt; m_routingTable.Purge(removedAddresses); - for (std::map::iterator rmItr = removedAddresses.begin(); - rmItr != removedAddresses.end(); - ++rmItr) + for (auto rmItr = removedAddresses.begin(); rmItr != removedAddresses.end(); ++rmItr) { rmItr->second.SetEntriesChanged(true); rmItr->second.SetSeqNo(rmItr->second.GetSeqNo() + 1); @@ -428,9 +424,7 @@ RoutingProtocol::RouteInput(Ptr p, return true; } } - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ipv4InterfaceAddress iface = j->second; if (origin == iface.GetLocal()) @@ -439,9 +433,7 @@ RoutingProtocol::RouteInput(Ptr p, } } // LOCAL DELIVARY TO DSDV INTERFACES - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ipv4InterfaceAddress iface = j->second; if (m_ipv4->GetInterfaceForAddress(iface.GetLocal()) == iif) @@ -545,7 +537,7 @@ RoutingProtocol::LoopbackRoute(const Ipv4Header& hdr, Ptr oif) const // If RouteOutput() caller specified an outgoing interface, that // further constrains the selection of source address // - std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); + auto j = m_socketAddresses.begin(); if (oif) { // Iterate to find an address on the oif device @@ -592,10 +584,7 @@ RoutingProtocol::RecvDsdv(Ptr socket) packet->RemoveHeader(dsdvHeader); NS_LOG_DEBUG("Processing new update for " << dsdvHeader.GetDst()); /*Verifying if the packets sent by me were returned back to me. If yes, discarding them!*/ - for (std::map, Ipv4InterfaceAddress>::const_iterator j = - m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ipv4InterfaceAddress interface = j->second; if (dsdvHeader.GetDst() == interface.GetLocal()) @@ -661,9 +650,7 @@ RoutingProtocol::RecvDsdv(Ptr socket) RoutingTableEntry tr; std::map allRoutes; m_advRoutingTable.GetListOfAllRoutes(allRoutes); - for (std::map::const_iterator i = allRoutes.begin(); - i != allRoutes.end(); - ++i) + for (auto i = allRoutes.begin(); i != allRoutes.end(); ++i) { NS_LOG_DEBUG("ADV table routes are:" << i->second.GetDestination()); } @@ -800,10 +787,7 @@ RoutingProtocol::RecvDsdv(Ptr socket) advTableEntry.SetSeqNo(dsdvHeader.GetDstSeqno()); advTableEntry.SetEntriesChanged(true); m_advRoutingTable.Update(advTableEntry); - for (std::map::iterator i = - dstsWithNextHopSrc.begin(); - i != dstsWithNextHopSrc.end(); - ++i) + for (auto i = dstsWithNextHopSrc.begin(); i != dstsWithNextHopSrc.end(); ++i) { i->second.SetSeqNo(i->second.GetSeqNo() + 1); i->second.SetEntriesChanged(true); @@ -844,17 +828,13 @@ RoutingProtocol::SendTriggeredUpdate() NS_LOG_FUNCTION(m_mainAddress << " is sending a triggered update"); std::map allRoutes; m_advRoutingTable.GetListOfAllRoutes(allRoutes); - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { DsdvHeader dsdvHeader; Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; Ptr packet = Create(); - for (std::map::const_iterator i = allRoutes.begin(); - i != allRoutes.end(); - ++i) + for (auto i = allRoutes.begin(); i != allRoutes.end(); ++i) { NS_LOG_LOGIC("Destination: " << i->second.GetDestination() << " SeqNo:" << i->second.GetSeqNo() @@ -930,16 +910,12 @@ RoutingProtocol::SendPeriodicUpdate() return; } NS_LOG_FUNCTION(m_mainAddress << " is sending out its periodic update"); - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; Ptr packet = Create(); - for (std::map::const_iterator i = allRoutes.begin(); - i != allRoutes.end(); - ++i) + for (auto i = allRoutes.begin(); i != allRoutes.end(); ++i) { DsdvHeader dsdvHeader; if (i->second.GetHop() == 0) @@ -966,10 +942,7 @@ RoutingProtocol::SendPeriodicUpdate() << ", HopCount:" << dsdvHeader.GetHopCount() << ", LifeTime: " << i->second.GetLifeTime().As(Time::S)); } - for (std::map::const_iterator rmItr = - removedAddresses.begin(); - rmItr != removedAddresses.end(); - ++rmItr) + for (auto rmItr = removedAddresses.begin(); rmItr != removedAddresses.end(); ++rmItr) { DsdvHeader removedHeader; removedHeader.SetDst(rmItr->second.GetDestination()); @@ -1143,9 +1116,7 @@ RoutingProtocol::NotifyRemoveAddress(uint32_t i, Ipv4InterfaceAddress address) Ptr RoutingProtocol::FindSocketWithInterfaceAddress(Ipv4InterfaceAddress addr) const { - for (std::map, Ipv4InterfaceAddress>::const_iterator j = m_socketAddresses.begin(); - j != m_socketAddresses.end(); - ++j) + for (auto j = m_socketAddresses.begin(); j != m_socketAddresses.end(); ++j) { Ptr socket = j->first; Ipv4InterfaceAddress iface = j->second; @@ -1181,9 +1152,7 @@ RoutingProtocol::LookForQueuedPackets() Ptr route; std::map allRoutes; m_routingTable.GetListOfAllRoutes(allRoutes); - for (std::map::const_iterator i = allRoutes.begin(); - i != allRoutes.end(); - ++i) + for (auto i = allRoutes.begin(); i != allRoutes.end(); ++i) { RoutingTableEntry rt; rt = i->second; @@ -1282,9 +1251,7 @@ RoutingProtocol::MergeTriggerPeriodicUpdates() m_advRoutingTable.GetListOfAllRoutes(allRoutes); if (!allRoutes.empty()) { - for (std::map::const_iterator i = allRoutes.begin(); - i != allRoutes.end(); - ++i) + for (auto i = allRoutes.begin(); i != allRoutes.end(); ++i) { RoutingTableEntry advEntry = i->second; if (advEntry.GetEntriesChanged() && diff --git a/src/dsdv/model/dsdv-rtable.cc b/src/dsdv/model/dsdv-rtable.cc index 18dc1af0b..7f1f392a7 100644 --- a/src/dsdv/model/dsdv-rtable.cc +++ b/src/dsdv/model/dsdv-rtable.cc @@ -80,7 +80,7 @@ RoutingTable::LookupRoute(Ipv4Address id, RoutingTableEntry& rt) { return false; } - std::map::const_iterator i = m_ipv4AddressEntry.find(id); + auto i = m_ipv4AddressEntry.find(id); if (i == m_ipv4AddressEntry.end()) { return false; @@ -96,7 +96,7 @@ RoutingTable::LookupRoute(Ipv4Address id, RoutingTableEntry& rt, bool forRouteIn { return false; } - std::map::const_iterator i = m_ipv4AddressEntry.find(id); + auto i = m_ipv4AddressEntry.find(id); if (i == m_ipv4AddressEntry.end()) { return false; @@ -124,16 +124,14 @@ RoutingTable::RoutingTableSize() bool RoutingTable::AddRoute(RoutingTableEntry& rt) { - std::pair::iterator, bool> result = - m_ipv4AddressEntry.insert(std::make_pair(rt.GetDestination(), rt)); + auto result = m_ipv4AddressEntry.insert(std::make_pair(rt.GetDestination(), rt)); return result.second; } bool RoutingTable::Update(RoutingTableEntry& rt) { - std::map::iterator i = - m_ipv4AddressEntry.find(rt.GetDestination()); + auto i = m_ipv4AddressEntry.find(rt.GetDestination()); if (i == m_ipv4AddressEntry.end()) { return false; @@ -149,12 +147,11 @@ RoutingTable::DeleteAllRoutesFromInterface(Ipv4InterfaceAddress iface) { return; } - for (std::map::iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end();) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end();) { if (i->second.GetInterface() == iface) { - std::map::iterator tmp = i; + auto tmp = i; ++i; m_ipv4AddressEntry.erase(tmp); } @@ -168,9 +165,7 @@ RoutingTable::DeleteAllRoutesFromInterface(Ipv4InterfaceAddress iface) void RoutingTable::GetListOfAllRoutes(std::map& allRoutes) { - for (std::map::iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end(); - ++i) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end(); ++i) { if (i->second.GetDestination() != Ipv4Address("127.0.0.1") && i->second.GetFlag() == VALID) { @@ -184,9 +179,7 @@ RoutingTable::GetListOfDestinationWithNextHop(Ipv4Address nextHop, std::map& unreachable) { unreachable.clear(); - for (std::map::const_iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end(); - ++i) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end(); ++i) { if (i->second.GetNextHop() == nextHop) { @@ -234,19 +227,17 @@ RoutingTable::Purge(std::map& removedAddresses) { return; } - for (std::map::iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end();) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end();) { - std::map::iterator itmp = i; + auto itmp = i; if (i->second.GetLifeTime() > m_holddownTime && (i->second.GetHop() > 0)) { - for (std::map::iterator j = m_ipv4AddressEntry.begin(); - j != m_ipv4AddressEntry.end();) + for (auto j = m_ipv4AddressEntry.begin(); j != m_ipv4AddressEntry.end();) { if ((j->second.GetNextHop() == i->second.GetDestination()) && (i->second.GetHop() != j->second.GetHop())) { - std::map::iterator jtmp = j; + auto jtmp = j; removedAddresses.insert(std::make_pair(j->first, j->second)); ++j; m_ipv4AddressEntry.erase(jtmp); @@ -291,9 +282,7 @@ RoutingTable::Print(Ptr stream, Time::Unit unit /*= Time::S *os << std::setw(16) << "SeqNum"; *os << std::setw(16) << "LifeTime"; *os << "SettlingTime" << std::endl; - for (std::map::const_iterator i = m_ipv4AddressEntry.begin(); - i != m_ipv4AddressEntry.end(); - ++i) + for (auto i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end(); ++i) { i->second.Print(stream, unit); } @@ -305,8 +294,7 @@ RoutingTable::Print(Ptr stream, Time::Unit unit /*= Time::S bool RoutingTable::AddIpv4Event(Ipv4Address address, EventId id) { - std::pair::iterator, bool> result = - m_ipv4Events.insert(std::make_pair(address, id)); + auto result = m_ipv4Events.insert(std::make_pair(address, id)); return result.second; } @@ -314,7 +302,7 @@ bool RoutingTable::AnyRunningEvent(Ipv4Address address) { EventId event; - std::map::const_iterator i = m_ipv4Events.find(address); + auto i = m_ipv4Events.find(address); if (m_ipv4Events.empty()) { return false; @@ -331,7 +319,7 @@ bool RoutingTable::ForceDeleteIpv4Event(Ipv4Address address) { EventId event; - std::map::const_iterator i = m_ipv4Events.find(address); + auto i = m_ipv4Events.find(address); if (m_ipv4Events.empty() || i == m_ipv4Events.end()) { return false; @@ -346,7 +334,7 @@ bool RoutingTable::DeleteIpv4Event(Ipv4Address address) { EventId event; - std::map::const_iterator i = m_ipv4Events.find(address); + auto i = m_ipv4Events.find(address); if (m_ipv4Events.empty() || i == m_ipv4Events.end()) { return false; @@ -372,7 +360,7 @@ RoutingTable::DeleteIpv4Event(Ipv4Address address) EventId RoutingTable::GetEventId(Ipv4Address address) { - std::map::const_iterator i = m_ipv4Events.find(address); + auto i = m_ipv4Events.find(address); if (m_ipv4Events.empty() || i == m_ipv4Events.end()) { return EventId(); diff --git a/src/dsr/helper/dsr-main-helper.cc b/src/dsr/helper/dsr-main-helper.cc index 447c0379e..abca309e1 100644 --- a/src/dsr/helper/dsr-main-helper.cc +++ b/src/dsr/helper/dsr-main-helper.cc @@ -81,7 +81,7 @@ DsrMainHelper::Install(DsrHelper& dsrHelper, NodeContainer nodes) NS_LOG_DEBUG("Passed node container"); delete m_dsrHelper; m_dsrHelper = dsrHelper.Copy(); - for (NodeContainer::Iterator i = nodes.Begin(); i != nodes.End(); ++i) + for (auto i = nodes.Begin(); i != nodes.End(); ++i) { Install(*i); } diff --git a/src/dsr/model/dsr-errorbuff.cc b/src/dsr/model/dsr-errorbuff.cc index f52426f77..d5c3440bd 100644 --- a/src/dsr/model/dsr-errorbuff.cc +++ b/src/dsr/model/dsr-errorbuff.cc @@ -56,9 +56,7 @@ bool DsrErrorBuffer::Enqueue(DsrErrorBuffEntry& entry) { Purge(); - for (std::vector::const_iterator i = m_errorBuffer.begin(); - i != m_errorBuffer.end(); - ++i) + for (auto i = m_errorBuffer.begin(); i != m_errorBuffer.end(); ++i) { NS_LOG_INFO("packet id " << i->GetPacket()->GetUid() << " " << entry.GetPacket()->GetUid() << " source " << i->GetSource() << " " << entry.GetSource() @@ -101,9 +99,7 @@ DsrErrorBuffer::DropPacketForErrLink(Ipv4Address source, Ipv4Address nextHop) /* * Drop the packet with the error link source----------nextHop */ - for (std::vector::iterator i = m_errorBuffer.begin(); - i != m_errorBuffer.end(); - ++i) + for (auto i = m_errorBuffer.begin(); i != m_errorBuffer.end(); ++i) { if ((i->GetSource() == link[0]) && (i->GetNextHop() == link[1])) { @@ -127,9 +123,7 @@ DsrErrorBuffer::Dequeue(Ipv4Address dst, DsrErrorBuffEntry& entry) /* * Dequeue the entry with destination address dst */ - for (std::vector::iterator i = m_errorBuffer.begin(); - i != m_errorBuffer.end(); - ++i) + for (auto i = m_errorBuffer.begin(); i != m_errorBuffer.end(); ++i) { if (i->GetDestination() == dst) { @@ -148,9 +142,7 @@ DsrErrorBuffer::Find(Ipv4Address dst) /* * Make sure if the send buffer contains entry with certain dst */ - for (std::vector::const_iterator i = m_errorBuffer.begin(); - i != m_errorBuffer.end(); - ++i) + for (auto i = m_errorBuffer.begin(); i != m_errorBuffer.end(); ++i) { if (i->GetDestination() == dst) { @@ -184,9 +176,7 @@ DsrErrorBuffer::Purge() */ NS_LOG_DEBUG("The error buffer size " << m_errorBuffer.size()); IsExpired pred; - for (std::vector::iterator i = m_errorBuffer.begin(); - i != m_errorBuffer.end(); - ++i) + for (auto i = m_errorBuffer.begin(); i != m_errorBuffer.end(); ++i) { if (pred(*i)) { diff --git a/src/dsr/model/dsr-gratuitous-reply-table.cc b/src/dsr/model/dsr-gratuitous-reply-table.cc index 3b92751fd..a8ac5f504 100644 --- a/src/dsr/model/dsr-gratuitous-reply-table.cc +++ b/src/dsr/model/dsr-gratuitous-reply-table.cc @@ -67,7 +67,7 @@ bool DsrGraReply::FindAndUpdate(Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff) { Purge(); // purge the gratuitous reply table - for (std::vector::iterator i = m_graReply.begin(); i != m_graReply.end(); ++i) + for (auto i = m_graReply.begin(); i != m_graReply.end(); ++i) { if ((i->m_replyTo == replyTo) && (i->m_hearFrom == replyFrom)) { diff --git a/src/dsr/model/dsr-maintain-buff.cc b/src/dsr/model/dsr-maintain-buff.cc index e32ddfa0c..f420c80d4 100644 --- a/src/dsr/model/dsr-maintain-buff.cc +++ b/src/dsr/model/dsr-maintain-buff.cc @@ -56,9 +56,7 @@ bool DsrMaintainBuffer::Enqueue(DsrMaintainBuffEntry& entry) { Purge(); - for (std::vector::const_iterator i = m_maintainBuffer.begin(); - i != m_maintainBuffer.end(); - ++i) + for (auto i = m_maintainBuffer.begin(); i != m_maintainBuffer.end(); ++i) { // NS_LOG_INFO ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our // add " << i->GetOurAdd () << " " << entry.GetOurAdd () @@ -106,9 +104,7 @@ bool DsrMaintainBuffer::Dequeue(Ipv4Address nextHop, DsrMaintainBuffEntry& entry) { Purge(); - for (std::vector::iterator i = m_maintainBuffer.begin(); - i != m_maintainBuffer.end(); - ++i) + for (auto i = m_maintainBuffer.begin(); i != m_maintainBuffer.end(); ++i) { if (i->GetNextHop() == nextHop) { @@ -124,9 +120,7 @@ DsrMaintainBuffer::Dequeue(Ipv4Address nextHop, DsrMaintainBuffEntry& entry) bool DsrMaintainBuffer::Find(Ipv4Address nextHop) { - for (std::vector::const_iterator i = m_maintainBuffer.begin(); - i != m_maintainBuffer.end(); - ++i) + for (auto i = m_maintainBuffer.begin(); i != m_maintainBuffer.end(); ++i) { if (i->GetNextHop() == nextHop) { @@ -140,9 +134,7 @@ DsrMaintainBuffer::Find(Ipv4Address nextHop) bool DsrMaintainBuffer::AllEqual(DsrMaintainBuffEntry& entry) { - for (std::vector::iterator i = m_maintainBuffer.begin(); - i != m_maintainBuffer.end(); - ++i) + for (auto i = m_maintainBuffer.begin(); i != m_maintainBuffer.end(); ++i) { // NS_LOG_DEBUG ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our // address " << i->GetOurAdd () << " " << entry.GetOurAdd () @@ -166,9 +158,7 @@ DsrMaintainBuffer::AllEqual(DsrMaintainBuffEntry& entry) bool DsrMaintainBuffer::NetworkEqual(DsrMaintainBuffEntry& entry) { - for (std::vector::iterator i = m_maintainBuffer.begin(); - i != m_maintainBuffer.end(); - ++i) + for (auto i = m_maintainBuffer.begin(); i != m_maintainBuffer.end(); ++i) { // NS_LOG_DEBUG ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our // address " << i->GetOurAdd () << " " << entry.GetOurAdd () @@ -193,9 +183,7 @@ bool DsrMaintainBuffer::PromiscEqual(DsrMaintainBuffEntry& entry) { NS_LOG_DEBUG("The maintenance buffer size " << m_maintainBuffer.size()); - for (std::vector::iterator i = m_maintainBuffer.begin(); - i != m_maintainBuffer.end(); - ++i) + for (auto i = m_maintainBuffer.begin(); i != m_maintainBuffer.end(); ++i) { // NS_LOG_DEBUG ("src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << // i->GetDst () << " " << entry.GetDst () @@ -220,9 +208,7 @@ bool DsrMaintainBuffer::LinkEqual(DsrMaintainBuffEntry& entry) { NS_LOG_DEBUG("The maintenance buffer size " << m_maintainBuffer.size()); - for (std::vector::iterator i = m_maintainBuffer.begin(); - i != m_maintainBuffer.end(); - ++i) + for (auto i = m_maintainBuffer.begin(); i != m_maintainBuffer.end(); ++i) { // NS_LOG_DEBUG ("src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << // i->GetDst () << " " << entry.GetDst () diff --git a/src/dsr/model/dsr-network-queue.cc b/src/dsr/model/dsr-network-queue.cc index f2f53d1d9..f68d2f794 100644 --- a/src/dsr/model/dsr-network-queue.cc +++ b/src/dsr/model/dsr-network-queue.cc @@ -107,9 +107,7 @@ bool DsrNetworkQueue::FindPacketWithNexthop(Ipv4Address nextHop, DsrNetworkQueueEntry& entry) { Cleanup(); - for (std::vector::iterator i = m_dsrNetworkQueue.begin(); - i != m_dsrNetworkQueue.end(); - ++i) + for (auto i = m_dsrNetworkQueue.begin(); i != m_dsrNetworkQueue.end(); ++i) { if (i->GetNextHopAddress() == nextHop) { @@ -125,9 +123,7 @@ bool DsrNetworkQueue::Find(Ipv4Address nextHop) { Cleanup(); - for (std::vector::iterator i = m_dsrNetworkQueue.begin(); - i != m_dsrNetworkQueue.end(); - ++i) + for (auto i = m_dsrNetworkQueue.begin(); i != m_dsrNetworkQueue.end(); ++i) { if (i->GetNextHopAddress() == nextHop) { @@ -158,7 +154,7 @@ DsrNetworkQueue::Dequeue(DsrNetworkQueueEntry& entry) { NS_LOG_FUNCTION(this); Cleanup(); - std::vector::iterator i = m_dsrNetworkQueue.begin(); + auto i = m_dsrNetworkQueue.begin(); if (i == m_dsrNetworkQueue.end()) { // no elements in array @@ -182,8 +178,7 @@ DsrNetworkQueue::Cleanup() Time now = Simulator::Now(); uint32_t n = 0; - for (std::vector::iterator i = m_dsrNetworkQueue.begin(); - i != m_dsrNetworkQueue.end();) + for (auto i = m_dsrNetworkQueue.begin(); i != m_dsrNetworkQueue.end();) { if (i->GetInsertedTimeStamp() + m_maxDelay > now) { diff --git a/src/dsr/model/dsr-option-header.cc b/src/dsr/model/dsr-option-header.cc index 3d2619f0d..fbfb85826 100644 --- a/src/dsr/model/dsr-option-header.cc +++ b/src/dsr/model/dsr-option-header.cc @@ -371,9 +371,7 @@ DsrOptionRreqHeader::Print(std::ostream& os) const { os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << ""; - for (std::vector::const_iterator it = m_ipv4Address.begin(); - it != m_ipv4Address.end(); - it++) + for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++) { os << *it << " "; } @@ -398,8 +396,7 @@ DsrOptionRreqHeader::Serialize(Buffer::Iterator start) const i.WriteHtonU16(m_identification); WriteTo(i, m_target); - for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end(); - it++) + for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++) { it->Serialize(buff); i.Write(buff, 4); @@ -506,9 +503,7 @@ DsrOptionRrepHeader::Print(std::ostream& os) const { os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << ""; - for (std::vector::const_iterator it = m_ipv4Address.begin(); - it != m_ipv4Address.end(); - it++) + for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++) { os << *it << " "; } @@ -533,8 +528,7 @@ DsrOptionRrepHeader::Serialize(Buffer::Iterator start) const i.WriteU8(0); i.WriteU8(0); - for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end(); - it++) + for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++) { it->Serialize(buff); i.Write(buff, 4); @@ -666,9 +660,7 @@ DsrOptionSRHeader::Print(std::ostream& os) const { os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << ""; - for (std::vector::const_iterator it = m_ipv4Address.begin(); - it != m_ipv4Address.end(); - it++) + for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++) { os << *it << " "; } @@ -693,8 +685,7 @@ DsrOptionSRHeader::Serialize(Buffer::Iterator start) const i.WriteU8(m_salvage); i.WriteU8(m_segmentsLeft); - for (VectorIpv4Address_t::const_iterator it = m_ipv4Address.begin(); it != m_ipv4Address.end(); - it++) + for (auto it = m_ipv4Address.begin(); it != m_ipv4Address.end(); it++) { it->Serialize(buff); i.Write(buff, 4); diff --git a/src/dsr/model/dsr-options.cc b/src/dsr/model/dsr-options.cc index e5b248a15..8dd292c80 100644 --- a/src/dsr/model/dsr-options.cc +++ b/src/dsr/model/dsr-options.cc @@ -125,9 +125,9 @@ DsrOptions::ContainAddressAfter(Ipv4Address ipv4Address, std::vector& nodeList) { NS_LOG_FUNCTION(this << ipv4Address << destAddress); - std::vector::iterator it = find(nodeList.begin(), nodeList.end(), destAddress); + auto it = find(nodeList.begin(), nodeList.end(), destAddress); - for (std::vector::iterator i = it; i != nodeList.end(); ++i) + for (auto i = it; i != nodeList.end(); ++i) { if ((ipv4Address == (*i)) && ((*i) != nodeList.back())) { @@ -141,9 +141,9 @@ std::vector DsrOptions::CutRoute(Ipv4Address ipv4Address, std::vector& nodeList) { NS_LOG_FUNCTION(this << ipv4Address); - std::vector::iterator it = find(nodeList.begin(), nodeList.end(), ipv4Address); + auto it = find(nodeList.begin(), nodeList.end(), ipv4Address); std::vector cutRoute; - for (std::vector::iterator i = it; i != nodeList.end(); ++i) + for (auto i = it; i != nodeList.end(); ++i) { cutRoute.push_back(*i); } @@ -190,7 +190,7 @@ DsrOptions::SearchNextHop(Ipv4Address ipv4Address, std::vector& vec << vec.back()); return ipv4Address; } - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + for (auto i = vec.begin(); i != vec.end(); ++i) { if (ipv4Address == (*i)) { @@ -216,7 +216,7 @@ DsrOptions::ReverseSearchNextHop(Ipv4Address ipv4Address, std::vector::reverse_iterator ri = vec.rbegin(); ri != vec.rend(); ++ri) + for (auto ri = vec.rbegin(); ri != vec.rend(); ++ri) { if (ipv4Address == (*ri)) { @@ -237,7 +237,7 @@ DsrOptions::ReverseSearchNextTwoHop(Ipv4Address ipv4Address, std::vector 2); - for (std::vector::reverse_iterator ri = vec.rbegin(); ri != vec.rend(); ++ri) + for (auto ri = vec.rbegin(); ri != vec.rend(); ++ri) { if (ipv4Address == (*ri)) { @@ -264,7 +264,7 @@ DsrOptions::PrintVector(std::vector& vec) else { NS_LOG_DEBUG("Print all the elements in a vector"); - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + for (auto i = vec.begin(); i != vec.end(); ++i) { NS_LOG_DEBUG("The ip address " << *i); } @@ -275,9 +275,9 @@ bool DsrOptions::IfDuplicates(std::vector& vec, std::vector& vec2) { NS_LOG_FUNCTION(this); - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + for (auto i = vec.begin(); i != vec.end(); ++i) { - for (std::vector::const_iterator j = vec2.begin(); j != vec2.end(); ++j) + for (auto j = vec2.begin(); j != vec2.end(); ++j) { if ((*i) == (*j)) { @@ -292,7 +292,7 @@ bool DsrOptions::CheckDuplicates(Ipv4Address ipv4Address, std::vector& vec) { NS_LOG_FUNCTION(this << ipv4Address); - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + for (auto i = vec.begin(); i != vec.end(); ++i) { if ((*i) == ipv4Address) { @@ -311,7 +311,7 @@ DsrOptions::RemoveDuplicates(std::vector& vec) std::vector vec2(vec); // declare vec2 as a copy of the vec PrintVector(vec2); // Print all the ip address in the route vec.clear(); // clear vec - for (std::vector::const_iterator i = vec2.begin(); i != vec2.end(); ++i) + for (auto i = vec2.begin(); i != vec2.end(); ++i) { if (vec.empty()) { @@ -319,7 +319,7 @@ DsrOptions::RemoveDuplicates(std::vector& vec) continue; } - for (std::vector::iterator j = vec.begin(); j != vec.end(); ++j) + for (auto j = vec.begin(); j != vec.end(); ++j) { if ((*i) == (*j)) { @@ -679,9 +679,7 @@ DsrOptionRreq::Process(Ptr packet, std::vector changeRoute(nodeList); changeRoute.push_back(ipv4Address); // push back our own address m_finalRoute.clear(); // get a clear route vector - for (std::vector::iterator i = changeRoute.begin(); - i != changeRoute.end(); - ++i) + for (auto i = changeRoute.begin(); i != changeRoute.end(); ++i) { m_finalRoute.push_back(*i); // Get the full route from source to destination } @@ -805,8 +803,7 @@ DsrOptionRreq::Process(Ptr packet, /** * push back the intermediate node address from the source to this node */ - for (std::vector::iterator i = saveRoute.begin(); i != saveRoute.end(); - ++i) + for (auto i = saveRoute.begin(); i != saveRoute.end(); ++i) { m_finalRoute.push_back(*i); } @@ -814,7 +811,7 @@ DsrOptionRreq::Process(Ptr packet, * push back the route vector we found in our route cache to destination, including this * node's address */ - for (std::vector::iterator j = ip.begin(); j != ip.end(); ++j) + for (auto j = ip.begin(); j != ip.end(); ++j) { m_finalRoute.push_back(*j); } @@ -1389,7 +1386,7 @@ DsrOptionSR::Process(Ptr packet, // Get the option type value uint32_t size = p->GetSize(); - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; p->CopyData(data, size); uint8_t optionType = 0; optionType = *(data); @@ -1560,7 +1557,7 @@ DsrOptionRerr::Process(Ptr packet, << (uint32_t)protocol << isPromisc); Ptr p = packet->Copy(); uint32_t size = p->GetSize(); - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; p->CopyData(data, size); uint8_t errorType = *(data + 2); /* diff --git a/src/dsr/model/dsr-passive-buff.cc b/src/dsr/model/dsr-passive-buff.cc index ffd650255..781c8d279 100644 --- a/src/dsr/model/dsr-passive-buff.cc +++ b/src/dsr/model/dsr-passive-buff.cc @@ -76,9 +76,7 @@ bool DsrPassiveBuffer::Enqueue(DsrPassiveBuffEntry& entry) { Purge(); - for (std::vector::const_iterator i = m_passiveBuffer.begin(); - i != m_passiveBuffer.end(); - ++i) + for (auto i = m_passiveBuffer.begin(); i != m_passiveBuffer.end(); ++i) { // NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket // ()->GetUid () << " source " << i->GetSource () << " " << entry.GetSource () @@ -119,9 +117,7 @@ DsrPassiveBuffer::Enqueue(DsrPassiveBuffEntry& entry) bool DsrPassiveBuffer::AllEqual(DsrPassiveBuffEntry& entry) { - for (std::vector::iterator i = m_passiveBuffer.begin(); - i != m_passiveBuffer.end(); - ++i) + for (auto i = m_passiveBuffer.begin(); i != m_passiveBuffer.end(); ++i) { // NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket // ()->GetUid () << " source " << i->GetSource () << " " << entry.GetSource () @@ -156,9 +152,7 @@ DsrPassiveBuffer::Dequeue(Ipv4Address dst, DsrPassiveBuffEntry& entry) /* * Dequeue the entry with destination address dst */ - for (std::vector::iterator i = m_passiveBuffer.begin(); - i != m_passiveBuffer.end(); - ++i) + for (auto i = m_passiveBuffer.begin(); i != m_passiveBuffer.end(); ++i) { if (i->GetDestination() == dst) { @@ -177,9 +171,7 @@ DsrPassiveBuffer::Find(Ipv4Address dst) /* * Make sure if the send buffer contains entry with certain dst */ - for (std::vector::const_iterator i = m_passiveBuffer.begin(); - i != m_passiveBuffer.end(); - ++i) + for (auto i = m_passiveBuffer.begin(); i != m_passiveBuffer.end(); ++i) { if (i->GetDestination() == dst) { @@ -213,9 +205,7 @@ DsrPassiveBuffer::Purge() */ NS_LOG_DEBUG("The passive buffer size " << m_passiveBuffer.size()); IsExpired pred; - for (std::vector::iterator i = m_passiveBuffer.begin(); - i != m_passiveBuffer.end(); - ++i) + for (auto i = m_passiveBuffer.begin(); i != m_passiveBuffer.end(); ++i) { if (pred(*i)) { diff --git a/src/dsr/model/dsr-rcache.cc b/src/dsr/model/dsr-rcache.cc index 240385ae5..b4971be60 100644 --- a/src/dsr/model/dsr-rcache.cc +++ b/src/dsr/model/dsr-rcache.cc @@ -185,8 +185,7 @@ bool DsrRouteCache::UpdateRouteEntry(Ipv4Address dst) { NS_LOG_FUNCTION(this << dst); - std::map>::const_iterator i = - m_sortedRoutes.find(dst); + auto i = m_sortedRoutes.find(dst); if (i == m_sortedRoutes.end()) { NS_LOG_LOGIC("Failed to find the route entry for the destination " << dst); @@ -204,8 +203,7 @@ DsrRouteCache::UpdateRouteEntry(Ipv4Address dst) /* * Save the new route cache along with the destination address in map */ - std::pair>::iterator, bool> result = - m_sortedRoutes.insert(std::make_pair(dst, rtVector)); + auto result = m_sortedRoutes.insert(std::make_pair(dst, rtVector)); return result.second; } return false; @@ -226,32 +224,24 @@ DsrRouteCache::LookupRoute(Ipv4Address id, DsrRouteCacheEntry& rt) NS_LOG_LOGIC("Route to " << id << " not found; m_sortedRoutes is empty"); return false; } - std::map>::const_iterator i = - m_sortedRoutes.find(id); + auto i = m_sortedRoutes.find(id); if (i == m_sortedRoutes.end()) { NS_LOG_LOGIC("No Direct Route to " << id << " found"); - for (std::map>::const_iterator j = - m_sortedRoutes.begin(); - j != m_sortedRoutes.end(); - ++j) + for (auto j = m_sortedRoutes.begin(); j != m_sortedRoutes.end(); ++j) { std::list rtVector = j->second; // The route cache vector linked with destination address /* * Loop through the possibly multiple routes within the route vector */ - for (std::list::const_iterator k = rtVector.begin(); - k != rtVector.end(); - ++k) + for (auto k = rtVector.begin(); k != rtVector.end(); ++k) { // return the first route in the route vector DsrRouteCacheEntry::IP_VECTOR routeVector = k->GetVector(); DsrRouteCacheEntry::IP_VECTOR changeVector; - for (DsrRouteCacheEntry::IP_VECTOR::iterator l = routeVector.begin(); - l != routeVector.end(); - ++l) + for (auto l = routeVector.begin(); l != routeVector.end(); ++l) { changeVector.push_back(*l); @@ -283,8 +273,7 @@ DsrRouteCache::LookupRoute(Ipv4Address id, DsrRouteCacheEntry& rt) } } NS_LOG_INFO("Here we check the route cache again after updated the sub routes"); - std::map>::const_iterator m = - m_sortedRoutes.find(id); + auto m = m_sortedRoutes.find(id); if (m == m_sortedRoutes.end()) { NS_LOG_LOGIC("No updated route till last time"); @@ -336,9 +325,7 @@ DsrRouteCache::RebuildBestRouteTable(Ipv4Address source) std::map d; // @pre preceding node std::map pre; - for (std::map>::iterator i = m_netGraph.begin(); - i != m_netGraph.end(); - ++i) + for (auto i = m_netGraph.begin(); i != m_netGraph.end(); ++i) { if (i->second.find(source) != i->second.end()) { @@ -358,11 +345,11 @@ DsrRouteCache::RebuildBestRouteTable(Ipv4Address source) // the node set which shortest distance has been calculated, if true calculated std::map s; double temp = MAXWEIGHT; - Ipv4Address tempip = Ipv4Address("255.255.255.255"); + Ipv4Address tempip("255.255.255.255"); for (uint32_t i = 0; i < m_netGraph.size(); i++) { temp = MAXWEIGHT; - for (std::map::const_iterator j = d.begin(); j != d.end(); ++j) + for (auto j = d.begin(); j != d.end(); ++j) { Ipv4Address ip = j->first; if (s.find(ip) == s.end()) @@ -380,9 +367,7 @@ DsrRouteCache::RebuildBestRouteTable(Ipv4Address source) if (!tempip.IsBroadcast()) { s[tempip] = true; - for (std::map::const_iterator k = m_netGraph[tempip].begin(); - k != m_netGraph[tempip].end(); - ++k) + for (auto k = m_netGraph[tempip].begin(); k != m_netGraph[tempip].end(); ++k) { if (s.find(k->first) == s.end() && d[k->first] > d[tempip] + k->second) { @@ -398,10 +383,8 @@ DsrRouteCache::RebuildBestRouteTable(Ipv4Address source) */ else if (d[k->first] == d[tempip] + k->second) { - std::map::iterator oldlink = - m_linkCache.find(Link(k->first, pre[k->first])); - std::map::iterator newlink = - m_linkCache.find(Link(k->first, tempip)); + auto oldlink = m_linkCache.find(Link(k->first, pre[k->first])); + auto newlink = m_linkCache.find(Link(k->first, tempip)); if (oldlink != m_linkCache.end() && newlink != m_linkCache.end()) { if (oldlink->second.GetLinkStability() < newlink->second.GetLinkStability()) @@ -421,7 +404,7 @@ DsrRouteCache::RebuildBestRouteTable(Ipv4Address source) } // clean the best route table m_bestRoutesTable_link.clear(); - for (std::map::iterator i = pre.begin(); i != pre.end(); ++i) + for (auto i = pre.begin(); i != pre.end(); ++i) { // loop for all vertices DsrRouteCacheEntry::IP_VECTOR route; @@ -450,8 +433,7 @@ DsrRouteCache::LookupRoute_Link(Ipv4Address id, DsrRouteCacheEntry& rt) NS_LOG_FUNCTION(this << id); /// We need to purge the link node cache PurgeLinkNode(); - std::map::const_iterator i = - m_bestRoutesTable_link.find(id); + auto i = m_bestRoutesTable_link.find(id); if (i == m_bestRoutesTable_link.end()) { NS_LOG_INFO("No route find to " << id); @@ -479,10 +461,10 @@ void DsrRouteCache::PurgeLinkNode() { NS_LOG_FUNCTION(this); - for (std::map::iterator i = m_linkCache.begin(); i != m_linkCache.end();) + for (auto i = m_linkCache.begin(); i != m_linkCache.end();) { NS_LOG_DEBUG("The link stability " << i->second.GetLinkStability().As(Time::S)); - std::map::iterator itmp = i; + auto itmp = i; if (i->second.GetLinkStability() <= Seconds(0)) { ++i; @@ -494,11 +476,10 @@ DsrRouteCache::PurgeLinkNode() } } /// may need to remove them after verify - for (std::map::iterator i = m_nodeCache.begin(); - i != m_nodeCache.end();) + for (auto i = m_nodeCache.begin(); i != m_nodeCache.end();) { NS_LOG_DEBUG("The node stability " << i->second.GetNodeStability().As(Time::S)); - std::map::iterator itmp = i; + auto itmp = i; if (i->second.GetNodeStability() <= Seconds(0)) { ++i; @@ -516,7 +497,7 @@ DsrRouteCache::UpdateNetGraph() { NS_LOG_FUNCTION(this); m_netGraph.clear(); - for (std::map::iterator i = m_linkCache.begin(); i != m_linkCache.end(); ++i) + for (auto i = m_linkCache.begin(); i != m_linkCache.end(); ++i) { // Here the weight is set as 1 /// \todo May need to set different weight for different link here later @@ -530,7 +511,7 @@ bool DsrRouteCache::IncStability(Ipv4Address node) { NS_LOG_FUNCTION(this << node); - std::map::const_iterator i = m_nodeCache.find(node); + auto i = m_nodeCache.find(node); if (i == m_nodeCache.end()) { NS_LOG_INFO("The initial stability " << m_initStability.As(Time::S)); @@ -555,7 +536,7 @@ bool DsrRouteCache::DecStability(Ipv4Address node) { NS_LOG_FUNCTION(this << node); - std::map::const_iterator i = m_nodeCache.find(node); + auto i = m_nodeCache.find(node); if (i == m_nodeCache.end()) { DsrNodeStab ns(m_initStability); @@ -636,7 +617,7 @@ DsrRouteCache::UseExtends(DsrRouteCacheEntry::IP_VECTOR rt) NS_LOG_INFO("The route is too short"); return; } - for (DsrRouteCacheEntry::IP_VECTOR::iterator i = rt.begin(); i != rt.end() - 1; ++i) + for (auto i = rt.begin(); i != rt.end() - 1; ++i) { Link link(*i, *(i + 1)); if (m_linkCache.find(link) != m_linkCache.end()) @@ -655,7 +636,7 @@ DsrRouteCache::UseExtends(DsrRouteCacheEntry::IP_VECTOR rt) } } /// Increase the stability of the node cache - for (DsrRouteCacheEntry::IP_VECTOR::iterator i = rt.begin(); i != rt.end(); ++i) + for (auto i = rt.begin(); i != rt.end(); ++i) { if (m_nodeCache.find(*i) != m_nodeCache.end()) { @@ -682,8 +663,7 @@ DsrRouteCache::AddRoute(DsrRouteCacheEntry& rt) std::vector route = rt.GetVector(); NS_LOG_DEBUG("The route destination we have " << dst); - std::map>::const_iterator i = - m_sortedRoutes.find(dst); + auto i = m_sortedRoutes.find(dst); if (i == m_sortedRoutes.end()) { @@ -692,8 +672,7 @@ DsrRouteCache::AddRoute(DsrRouteCacheEntry& rt) /** * Save the new route cache along with the destination address in map */ - std::pair>::iterator, bool> result = - m_sortedRoutes.insert(std::make_pair(dst, rtVector)); + auto result = m_sortedRoutes.insert(std::make_pair(dst, rtVector)); return result.second; } @@ -734,8 +713,7 @@ DsrRouteCache::AddRoute(DsrRouteCacheEntry& rt) /** * Save the new route cache along with the destination address in map */ - std::pair>::iterator, bool> result = - m_sortedRoutes.insert(std::make_pair(dst, rtVector)); + auto result = m_sortedRoutes.insert(std::make_pair(dst, rtVector)); return result.second; } else @@ -751,7 +729,7 @@ bool DsrRouteCache::FindSameRoute(DsrRouteCacheEntry& rt, std::list& rtVector) { NS_LOG_FUNCTION(this); - for (std::list::iterator i = rtVector.begin(); i != rtVector.end(); ++i) + for (auto i = rtVector.begin(); i != rtVector.end(); ++i) { // return the first route in the route vector DsrRouteCacheEntry::IP_VECTOR routeVector = i->GetVector(); @@ -773,8 +751,7 @@ DsrRouteCache::FindSameRoute(DsrRouteCacheEntry& rt, std::list>::iterator, bool> result = - m_sortedRoutes.insert(std::make_pair(rt.GetDestination(), rtVector)); + auto result = m_sortedRoutes.insert(std::make_pair(rt.GetDestination(), rtVector)); return result.second; } } @@ -819,7 +796,7 @@ DsrRouteCache::DeleteAllRoutesIncludeLink(Ipv4Address errorSrc, m_linkCache.erase(link2); NS_LOG_DEBUG("The link cache size " << m_linkCache.size()); - std::map::iterator i = m_nodeCache.find(errorSrc); + auto i = m_nodeCache.find(errorSrc); if (i == m_nodeCache.end()) { NS_LOG_LOGIC("Update the node stability unsuccessfuly"); @@ -854,17 +831,15 @@ DsrRouteCache::DeleteAllRoutesIncludeLink(Ipv4Address errorSrc, /* * Loop all the routes saved in the route cache */ - for (std::map>::iterator j = - m_sortedRoutes.begin(); - j != m_sortedRoutes.end();) + for (auto j = m_sortedRoutes.begin(); j != m_sortedRoutes.end();) { - std::map>::iterator jtmp = j; + auto jtmp = j; Ipv4Address address = j->first; std::list rtVector = j->second; /* * Loop all the routes for a single destination */ - for (std::list::iterator k = rtVector.begin(); k != rtVector.end();) + for (auto k = rtVector.begin(); k != rtVector.end();) { // return the first route in the route vector DsrRouteCacheEntry::IP_VECTOR routeVector = k->GetVector(); @@ -872,9 +847,7 @@ DsrRouteCache::DeleteAllRoutesIncludeLink(Ipv4Address errorSrc, /* * Loop the ip addresses within a single route entry */ - for (DsrRouteCacheEntry::IP_VECTOR::iterator i = routeVector.begin(); - i != routeVector.end(); - ++i) + for (auto i = routeVector.begin(); i != routeVector.end(); ++i) { if (*i != errorSrc) { @@ -972,7 +945,7 @@ DsrRouteCache::PrintVector(std::vector& vec) else { NS_LOG_DEBUG("Print all the elements in a vector"); - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + for (auto i = vec.begin(); i != vec.end(); ++i) { NS_LOG_DEBUG("The ip address " << *i); } @@ -983,7 +956,7 @@ void DsrRouteCache::PrintRouteVector(std::list route) { NS_LOG_FUNCTION(this); - for (std::list::iterator i = route.begin(); i != route.end(); i++) + for (auto i = route.begin(); i != route.end(); i++) { std::vector path = i->GetVector(); NS_LOG_INFO("Route NO. "); @@ -1001,11 +974,10 @@ DsrRouteCache::Purge() NS_LOG_DEBUG("The route cache is empty"); return; } - for (std::map>::iterator i = m_sortedRoutes.begin(); - i != m_sortedRoutes.end();) + for (auto i = m_sortedRoutes.begin(); i != m_sortedRoutes.end();) { // Loop of route cache entry with the route size - std::map>::iterator itmp = i; + auto itmp = i; /* * The route cache entry vector */ @@ -1014,7 +986,7 @@ DsrRouteCache::Purge() NS_LOG_DEBUG("The route vector size of 1 " << dst << " " << rtVector.size()); if (!rtVector.empty()) { - for (std::list::iterator j = rtVector.begin(); j != rtVector.end();) + for (auto j = rtVector.begin(); j != rtVector.end();) { NS_LOG_DEBUG("The expire time of every entry with expire time " << j->GetExpireTime()); @@ -1066,9 +1038,7 @@ DsrRouteCache::Print(std::ostream& os) Purge(); os << "\nDSR Route Cache\n" << "Destination\tGateway\t\tInterface\tFlag\tExpire\tHops\n"; - for (std::list::const_iterator i = m_routeEntryVector.begin(); - i != m_routeEntryVector.end(); - ++i) + for (auto i = m_routeEntryVector.begin(); i != m_routeEntryVector.end(); ++i) { i->Print(os); } @@ -1083,7 +1053,7 @@ uint16_t DsrRouteCache::CheckUniqueAckId(Ipv4Address nextHop) { NS_LOG_FUNCTION(this); - std::map::const_iterator i = m_ackIdCache.find(nextHop); + auto i = m_ackIdCache.find(nextHop); if (i == m_ackIdCache.end()) { NS_LOG_LOGIC("No Ack id for " << nextHop @@ -1114,7 +1084,7 @@ DsrRouteCache::IsNeighbor(Ipv4Address addr) { NS_LOG_FUNCTION(this); PurgeMac(); // purge the mac cache - for (std::vector::const_iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { if (i->m_neighborAddress == addr) { @@ -1129,7 +1099,7 @@ DsrRouteCache::GetExpireTime(Ipv4Address addr) { NS_LOG_FUNCTION(this); PurgeMac(); - for (std::vector::const_iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { if (i->m_neighborAddress == addr) { @@ -1143,9 +1113,9 @@ void DsrRouteCache::UpdateNeighbor(std::vector nodeList, Time expire) { NS_LOG_FUNCTION(this); - for (std::vector::iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { - for (std::vector::iterator j = nodeList.begin(); j != nodeList.end(); ++j) + for (auto j = nodeList.begin(); j != nodeList.end(); ++j) { if (i->m_neighborAddress == (*j)) { @@ -1170,7 +1140,7 @@ void DsrRouteCache::AddNeighbor(std::vector nodeList, Ipv4Address ownAddress, Time expire) { NS_LOG_LOGIC("Add neighbor number " << nodeList.size()); - for (std::vector::iterator j = nodeList.begin(); j != nodeList.end();) + for (auto j = nodeList.begin(); j != nodeList.end();) { Ipv4Address addr = *j; if (addr == ownAddress) @@ -1214,7 +1184,7 @@ DsrRouteCache::PurgeMac() CloseNeighbor pred; if (!m_handleLinkFailure.IsNull()) { - for (std::vector::iterator j = m_nb.begin(); j != m_nb.end(); ++j) + for (auto j = m_nb.begin(); j != m_nb.end(); ++j) { if (pred(*j)) { @@ -1252,7 +1222,7 @@ Mac48Address DsrRouteCache::LookupMacAddress(Ipv4Address addr) { Mac48Address hwaddr; - for (std::vector>::const_iterator i = m_arp.begin(); i != m_arp.end(); ++i) + for (auto i = m_arp.begin(); i != m_arp.end(); ++i) { ArpCache::Entry* entry = (*i)->Lookup(addr); if (entry != nullptr && (entry->IsAlive() || entry->IsPermanent()) && !entry->IsExpired()) @@ -1269,7 +1239,7 @@ DsrRouteCache::ProcessTxError(const WifiMacHeader& hdr) { Mac48Address addr = hdr.GetAddr1(); - for (std::vector::iterator i = m_nb.begin(); i != m_nb.end(); ++i) + for (auto i = m_nb.begin(); i != m_nb.end(); ++i) { if (i->m_hardwareAddress == addr) { diff --git a/src/dsr/model/dsr-rcache.h b/src/dsr/model/dsr-rcache.h index 43572343f..0d6ea3be2 100644 --- a/src/dsr/model/dsr-rcache.h +++ b/src/dsr/model/dsr-rcache.h @@ -356,8 +356,8 @@ class DsrRouteCacheEntry NS_ASSERT(false); return false; } - IP_VECTOR::const_iterator j = o.m_path.begin(); - for (IP_VECTOR::const_iterator i = m_path.begin(); i != m_path.end(); i++, j++) + auto j = o.m_path.begin(); + for (auto i = m_path.begin(); i != m_path.end(); i++, j++) { /* * Verify if neither the entry are not 0 and they equal to each other diff --git a/src/dsr/model/dsr-routing.cc b/src/dsr/model/dsr-routing.cc index 11d1b7847..ddfd8602e 100644 --- a/src/dsr/model/dsr-routing.cc +++ b/src/dsr/model/dsr-routing.cc @@ -443,8 +443,7 @@ DsrRouting::Start() << m_maxNetworkDelay.As(Time::S)); Ptr queue_i = CreateObject(m_maxNetworkSize, m_maxNetworkDelay); - std::pair>::iterator, bool> result_i = - m_priorityQueue.insert(std::make_pair(i, queue_i)); + auto result_i = m_priorityQueue.insert(std::make_pair(i, queue_i)); NS_ASSERT_MSG(result_i.second, "Error in creating queues"); } Ptr rreqTable = CreateObject(); @@ -748,7 +747,7 @@ DsrRouting::PrintVector(std::vector& vec) else { NS_LOG_DEBUG("Print all the elements in a vector"); - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + for (auto i = vec.begin(); i != vec.end(); ++i) { NS_LOG_DEBUG("The ip address " << *i); } @@ -774,7 +773,7 @@ DsrRouting::SearchNextHop(Ipv4Address ipv4Address, std::vector& vec << vec.back()); return ipv4Address; } - for (std::vector::const_iterator i = vec.begin(); i != vec.end(); ++i) + for (auto i = vec.begin(); i != vec.end(); ++i) { if (ipv4Address == (*i)) { @@ -866,8 +865,7 @@ DsrRouting::CheckSendBuffer() NS_LOG_INFO(Simulator::Now().As(Time::S) << " Checking send buffer at " << m_mainAddress << " with size " << m_sendBuffer.GetSize()); - for (std::vector::iterator i = m_sendBuffer.GetBuffer().begin(); - i != m_sendBuffer.GetBuffer().end();) + for (auto i = m_sendBuffer.GetBuffer().begin(); i != m_sendBuffer.GetBuffer().end();) { NS_LOG_DEBUG("Here we try to find the data packet in the send buffer"); Ipv4Address destination = i->GetDestination(); @@ -895,7 +893,7 @@ DsrRouting::CheckSendBuffer() * Peek data to get the option type as well as length and segmentsLeft field */ uint32_t size = copyP->GetSize(); - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; copyP->CopyData(data, size); uint8_t optionType = 0; @@ -959,8 +957,7 @@ DsrRouting::CheckSendBuffer() m_ipv4Route->SetOutputDevice(dev); uint32_t priority = GetPriority(DSR_CONTROL_PACKET); /// This will be priority 0 - std::map>::iterator i = - m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_LOGIC("Will be inserting into priority queue number: " << priority); @@ -1175,7 +1172,7 @@ DsrRouting::PromiscReceive(Ptr device, * Peek data to get the option type as well as length and segmentsLeft field */ uint32_t size = pktMinusIpHdr->GetSize(); - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; pktMinusIpHdr->CopyData(data, size); uint8_t optionType = 0; optionType = *(data); @@ -1451,7 +1448,7 @@ DsrRouting::SendUnreachError(Ipv4Address unreachNode, << newPacket->GetSize()); uint32_t priority = GetPriority(DSR_CONTROL_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_DEBUG("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority); @@ -1501,7 +1498,7 @@ DsrRouting::ForwardErrPacket(DsrOptionRerrUnreachHeader& rerr, route->SetOutputDevice(dev); uint32_t priority = GetPriority(DSR_CONTROL_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_DEBUG("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority); @@ -1740,7 +1737,7 @@ DsrRouting::SendPacket(Ptr packet, m_ipv4Route->SetOutputDevice(dev); uint32_t priority = GetPriority(DSR_DATA_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_INFO("Will be inserting into priority queue number: " << priority); @@ -1782,7 +1779,7 @@ DsrRouting::PriorityScheduler(uint32_t priority, bool continueWithFirst) // priorities ranging from 0 to m_numPriorityQueues, with 0 as the highest priority for (uint32_t i = priority; numPriorities < m_numPriorityQueues; numPriorities++) { - std::map>::iterator q = m_priorityQueue.find(i); + auto q = m_priorityQueue.find(i); Ptr dsrNetworkQueue = q->second; uint32_t queueSize = dsrNetworkQueue->GetSize(); if (queueSize == 0) @@ -1799,10 +1796,7 @@ DsrRouting::PriorityScheduler(uint32_t priority, bool continueWithFirst) else { uint32_t totalQueueSize = 0; - for (std::map>::iterator j = - m_priorityQueue.begin(); - j != m_priorityQueue.end(); - j++) + for (auto j = m_priorityQueue.begin(); j != m_priorityQueue.end(); j++) { NS_LOG_INFO("The size of the network queue for " << j->first << " is " << j->second->GetSize()); @@ -1854,18 +1848,14 @@ DsrRouting::IncreaseRetransTimer() // We may want to get the queue first and then we need to save a vector of the entries here and // then find uint32_t priority = GetPriority(DSR_DATA_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; std::vector newNetworkQueue = dsrNetworkQueue->GetQueue(); - for (std::vector::iterator i = newNetworkQueue.begin(); - i != newNetworkQueue.end(); - i++) + for (auto i = newNetworkQueue.begin(); i != newNetworkQueue.end(); i++) { Ipv4Address nextHop = i->GetNextHopAddress(); - for (std::map::iterator j = m_addressForwardTimer.begin(); - j != m_addressForwardTimer.end(); - j++) + for (auto j = m_addressForwardTimer.begin(); j != m_addressForwardTimer.end(); j++) { if (nextHop == j->first.m_nextHop) { @@ -2031,7 +2021,7 @@ DsrRouting::SendPacketFromBuffer(const DsrOptionSRHeader& sourceRoute, * Peek data to get the option type as well as length and segmentsLeft field */ uint32_t size = copyP->GetSize(); - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; copyP->CopyData(data, size); uint8_t optionType = 0; @@ -2085,8 +2075,7 @@ DsrRouting::SendPacketFromBuffer(const DsrOptionSRHeader& sourceRoute, m_ipv4Route->SetOutputDevice(dev); uint32_t priority = GetPriority(DSR_CONTROL_PACKET); - std::map>::iterator i = - m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_DEBUG("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority); @@ -2259,7 +2248,7 @@ DsrRouting::CancelLinkPacketTimer(DsrMaintainBuffEntry& mb) // TODO if find the linkkey, we need to remove it // Find the network acknowledgment timer - std::map::const_iterator i = m_linkAckTimer.find(linkKey); + auto i = m_linkAckTimer.find(linkKey); if (i == m_linkAckTimer.end()) { NS_LOG_INFO("did not find the link timer"); @@ -2308,7 +2297,7 @@ DsrRouting::CancelNetworkPacketTimer(DsrMaintainBuffEntry& mb) << mb.GetNextHop() << " source " << mb.GetSrc() << " destination " << mb.GetDst() << " segsLeft " << (uint32_t)mb.GetSegsLeft()); // Find the network acknowledgment timer - std::map::const_iterator i = m_addressForwardTimer.find(networkKey); + auto i = m_addressForwardTimer.find(networkKey); if (i == m_addressForwardTimer.end()) { NS_LOG_INFO("did not find the packet timer"); @@ -2349,7 +2338,7 @@ DsrRouting::CancelPassivePacketTimer(DsrMaintainBuffEntry& mb) m_passiveCnt.erase(passiveKey); // Find the passive acknowledgment timer - std::map::const_iterator j = m_passiveAckTimer.find(passiveKey); + auto j = m_passiveAckTimer.find(passiveKey); if (j == m_passiveAckTimer.end()) { NS_LOG_INFO("did not find the passive timer"); @@ -2523,7 +2512,7 @@ DsrRouting::SalvagePacket(Ptr packet, // Send out the data packet uint32_t priority = GetPriority(DSR_DATA_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_DEBUG("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority); @@ -3309,7 +3298,7 @@ DsrRouting::SendRequest(Ptr packet, Ipv4Address source) * The destination address here is directed broadcast address */ uint32_t priority = GetPriority(DSR_CONTROL_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_LOGIC("Inserting into priority queue number: " << priority); @@ -3363,16 +3352,14 @@ DsrRouting::SendGratuitousReply(Ipv4Address source, /** * Push back the node addresses other than those between srcAddress and our own ip address */ - std::vector::iterator before = - find(nodeList.begin(), nodeList.end(), srcAddress); - for (std::vector::iterator i = nodeList.begin(); i != before; ++i) + auto before = find(nodeList.begin(), nodeList.end(), srcAddress); + for (auto i = nodeList.begin(); i != before; ++i) { m_finalRoute.push_back(*i); } m_finalRoute.push_back(srcAddress); - std::vector::iterator after = - find(nodeList.begin(), nodeList.end(), m_mainAddress); - for (std::vector::iterator j = after; j != nodeList.end(); ++j) + auto after = find(nodeList.begin(), nodeList.end(), m_mainAddress); + for (auto j = after; j != nodeList.end(); ++j) { m_finalRoute.push_back(*j); } @@ -3426,7 +3413,7 @@ DsrRouting::SendReply(Ptr packet, NS_LOG_INFO("The output device " << dev << " packet is: " << *packet); uint32_t priority = GetPriority(DSR_CONTROL_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_INFO("Inserting into priority queue number: " << priority); @@ -3509,7 +3496,7 @@ DsrRouting::SendAck(uint16_t ackId, route->SetOutputDevice(dev); uint32_t priority = GetPriority(DSR_CONTROL_PACKET); - std::map>::iterator i = m_priorityQueue.find(priority); + auto i = m_priorityQueue.find(priority); Ptr dsrNetworkQueue = i->second; NS_LOG_LOGIC("Will be inserting into priority queue " << dsrNetworkQueue @@ -3568,7 +3555,7 @@ DsrRouting::Receive(Ptr p, const Ipv4Header& ip, Ptr inco * Peek data to get the option type as well as length and segmentsLeft field */ uint32_t size = p->GetSize(); - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; p->CopyData(data, size); uint8_t optionType = 0; @@ -3770,7 +3757,7 @@ DsrRouting::Insert(Ptr option) Ptr DsrRouting::GetOption(int optionNumber) { - for (DsrOptionList_t::iterator i = m_options.begin(); i != m_options.end(); ++i) + for (auto i = m_options.begin(); i != m_options.end(); ++i) { if ((*i)->GetOptionNumber() == optionNumber) { diff --git a/src/dsr/model/dsr-rreq-table.cc b/src/dsr/model/dsr-rreq-table.cc index dfb4dc0c1..e3568b211 100644 --- a/src/dsr/model/dsr-rreq-table.cc +++ b/src/dsr/model/dsr-rreq-table.cc @@ -71,9 +71,7 @@ DsrRreqTable::RemoveLeastExpire() NS_LOG_FUNCTION(this); Ipv4Address firstExpire; Time max = Seconds(0.0); - for (std::map::const_iterator i = m_rreqDstMap.begin(); - i != m_rreqDstMap.end(); - ++i) + for (auto i = m_rreqDstMap.begin(); i != m_rreqDstMap.end(); ++i) { Ipv4Address dst = i->first; RreqTableEntry rreqTableEntry = i->second; @@ -90,7 +88,7 @@ void DsrRreqTable::FindAndUpdate(Ipv4Address dst) { NS_LOG_FUNCTION(this << dst); - std::map::const_iterator i = m_rreqDstMap.find(dst); + auto i = m_rreqDstMap.find(dst); if (i == m_rreqDstMap.end()) { NS_LOG_LOGIC("The request table entry for " << dst << " not found"); @@ -123,7 +121,7 @@ void DsrRreqTable::RemoveRreqEntry(Ipv4Address dst) { NS_LOG_FUNCTION(this << dst); - std::map::const_iterator i = m_rreqDstMap.find(dst); + auto i = m_rreqDstMap.find(dst); if (i == m_rreqDstMap.end()) { NS_LOG_LOGIC("The request table entry not found"); @@ -139,7 +137,7 @@ uint32_t DsrRreqTable::GetRreqCnt(Ipv4Address dst) { NS_LOG_FUNCTION(this << dst); - std::map::const_iterator i = m_rreqDstMap.find(dst); + auto i = m_rreqDstMap.find(dst); if (i == m_rreqDstMap.end()) { NS_LOG_LOGIC("Request table entry not found"); @@ -159,7 +157,7 @@ uint32_t DsrRreqTable::CheckUniqueRreqId(Ipv4Address dst) { NS_LOG_LOGIC("The size of id cache " << m_rreqIdCache.size()); - std::map::const_iterator i = m_rreqIdCache.find(dst); + auto i = m_rreqIdCache.find(dst); if (i == m_rreqIdCache.end()) { NS_LOG_LOGIC("No Request id for " << dst << " found, initialize it to 0"); @@ -210,7 +208,7 @@ BlackList* DsrRreqTable::FindUnidirectional(Ipv4Address neighbor) { PurgeNeighbor(); // purge the neighbor cache - for (std::vector::iterator i = m_blackList.begin(); i != m_blackList.end(); ++i) + for (auto i = m_blackList.begin(); i != m_blackList.end(); ++i) { if (i->m_neighborAddress == neighbor) { @@ -224,7 +222,7 @@ bool DsrRreqTable::MarkLinkAsUnidirectional(Ipv4Address neighbor, Time blacklistTimeout) { NS_LOG_LOGIC("Add neighbor address in blacklist " << m_blackList.size()); - for (std::vector::iterator i = m_blackList.begin(); i != m_blackList.end(); i++) + for (auto i = m_blackList.begin(); i != m_blackList.end(); i++) { if (i->m_neighborAddress == neighbor) { @@ -260,8 +258,7 @@ DsrRreqTable::FindSourceEntry(Ipv4Address src, Ipv4Address dst, uint16_t id) /* * this function will return false if the entry is not found, true if duplicate entry find */ - std::map>::const_iterator i = - m_sourceRreqMap.find(src); + auto i = m_sourceRreqMap.find(src); if (i == m_sourceRreqMap.end()) { NS_LOG_LOGIC("The source request table entry for " << src << " not found"); @@ -284,9 +281,7 @@ DsrRreqTable::FindSourceEntry(Ipv4Address src, Ipv4Address dst, uint16_t id) } // We loop the receive rreq entry to find duplicate - for (std::list::const_iterator j = receivedRreqEntryList.begin(); - j != receivedRreqEntryList.end(); - ++j) + for (auto j = receivedRreqEntryList.begin(); j != receivedRreqEntryList.end(); ++j) { if (*j == rreqEntry) /// Check if we have found one duplication entry or not { diff --git a/src/dsr/model/dsr-rsendbuff.cc b/src/dsr/model/dsr-rsendbuff.cc index 0e256f30f..109624458 100644 --- a/src/dsr/model/dsr-rsendbuff.cc +++ b/src/dsr/model/dsr-rsendbuff.cc @@ -56,9 +56,7 @@ bool DsrSendBuffer::Enqueue(DsrSendBuffEntry& entry) { Purge(); - for (std::vector::const_iterator i = m_sendBuffer.begin(); - i != m_sendBuffer.end(); - ++i) + for (auto i = m_sendBuffer.begin(); i != m_sendBuffer.end(); ++i) { // NS_LOG_DEBUG ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket // ()->GetUid () @@ -94,8 +92,7 @@ DsrSendBuffer::DropPacketWithDst(Ipv4Address dst) /* * Drop the packet with destination address dst */ - for (std::vector::iterator i = m_sendBuffer.begin(); i != m_sendBuffer.end(); - ++i) + for (auto i = m_sendBuffer.begin(); i != m_sendBuffer.end(); ++i) { if (i->GetDestination() == dst) { @@ -116,8 +113,7 @@ DsrSendBuffer::Dequeue(Ipv4Address dst, DsrSendBuffEntry& entry) /* * Dequeue the entry with destination address dst */ - for (std::vector::iterator i = m_sendBuffer.begin(); i != m_sendBuffer.end(); - ++i) + for (auto i = m_sendBuffer.begin(); i != m_sendBuffer.end(); ++i) { if (i->GetDestination() == dst) { @@ -136,9 +132,7 @@ DsrSendBuffer::Find(Ipv4Address dst) /* * Make sure if the send buffer contains entry with certain dst */ - for (std::vector::const_iterator i = m_sendBuffer.begin(); - i != m_sendBuffer.end(); - ++i) + for (auto i = m_sendBuffer.begin(); i != m_sendBuffer.end(); ++i) { if (i->GetDestination() == dst) { @@ -171,8 +165,7 @@ DsrSendBuffer::Purge() */ NS_LOG_INFO("The send buffer size " << m_sendBuffer.size()); IsExpired pred; - for (std::vector::iterator i = m_sendBuffer.begin(); i != m_sendBuffer.end(); - ++i) + for (auto i = m_sendBuffer.begin(); i != m_sendBuffer.end(); ++i) { if (pred(*i)) { diff --git a/src/dsr/test/dsr-test-suite.cc b/src/dsr/test/dsr-test-suite.cc index 260a0aeb3..c77877f47 100644 --- a/src/dsr/test/dsr-test-suite.cc +++ b/src/dsr/test/dsr-test-suite.cc @@ -443,7 +443,7 @@ DsrCacheEntryTest::DoRun() Ipv4Address("0.0.0.1"), }; - Ipv4Address dst = Ipv4Address("0.0.0.1"); + Ipv4Address dst("0.0.0.1"); dsr::DsrRouteCacheEntry entry(ip, dst, Seconds(1)); NS_TEST_EXPECT_MSG_EQ(entry.GetVector().size(), 2, "trivial"); NS_TEST_EXPECT_MSG_EQ(entry.GetDestination(), Ipv4Address("0.0.0.1"), "trivial"); @@ -464,7 +464,7 @@ DsrCacheEntryTest::DoRun() Ipv4Address("1.1.1.1"), }; - Ipv4Address dst2 = Ipv4Address("1.1.1.1"); + Ipv4Address dst2("1.1.1.1"); dsr::DsrRouteCacheEntry entry2(ip2, dst2, Seconds(2)); dsr::DsrRouteCacheEntry newEntry; NS_TEST_EXPECT_MSG_EQ(rcache->AddRoute(entry2), true, "trivial"); @@ -516,7 +516,7 @@ DsrSendBuffTest::DoRun() NS_TEST_EXPECT_MSG_EQ(q.GetSendBufferTimeout(), Seconds(10), "trivial"); Ptr packet = Create(); - Ipv4Address dst1 = Ipv4Address("0.0.0.1"); + Ipv4Address dst1("0.0.0.1"); dsr::DsrSendBuffEntry e1(packet, dst1, Seconds(1)); q.Enqueue(e1); q.Enqueue(e1); @@ -528,7 +528,7 @@ DsrSendBuffTest::DoRun() NS_TEST_EXPECT_MSG_EQ(q.Find(Ipv4Address("0.0.0.1")), false, "trivial"); NS_TEST_EXPECT_MSG_EQ(q.GetSize(), 0, "trivial"); - Ipv4Address dst2 = Ipv4Address("0.0.0.2"); + Ipv4Address dst2("0.0.0.2"); dsr::DsrSendBuffEntry e2(packet, dst2, Seconds(1)); q.Enqueue(e1); q.Enqueue(e2); @@ -541,7 +541,7 @@ DsrSendBuffTest::DoRun() q.Enqueue(e3); NS_TEST_EXPECT_MSG_EQ(q.GetSize(), 2, "trivial"); Ptr packet4 = Create(); - Ipv4Address dst4 = Ipv4Address("0.0.0.4"); + Ipv4Address dst4("0.0.0.4"); dsr::DsrSendBuffEntry e4(packet4, dst4, Seconds(20)); q.Enqueue(e4); NS_TEST_EXPECT_MSG_EQ(q.GetSize(), 3, "trivial"); diff --git a/src/energy/helper/energy-harvester-container.cc b/src/energy/helper/energy-harvester-container.cc index 35d2d3b3e..b7bce1ae9 100644 --- a/src/energy/helper/energy-harvester-container.cc +++ b/src/energy/helper/energy-harvester-container.cc @@ -105,7 +105,7 @@ void EnergyHarvesterContainer::Add(EnergyHarvesterContainer container) { NS_LOG_FUNCTION(this << &container); - for (Iterator i = container.Begin(); i != container.End(); i++) + for (auto i = container.Begin(); i != container.End(); i++) { m_harvesters.push_back(*i); } @@ -143,9 +143,7 @@ void EnergyHarvesterContainer::DoDispose() { // call Object::Dispose for all EnergyHarvester objects - for (std::vector>::iterator i = m_harvesters.begin(); - i != m_harvesters.end(); - i++) + for (auto i = m_harvesters.begin(); i != m_harvesters.end(); i++) { (*i)->Dispose(); } @@ -156,9 +154,7 @@ void EnergyHarvesterContainer::DoInitialize() { // call Object::Initialize for all EnergyHarvester objects - for (std::vector>::iterator i = m_harvesters.begin(); - i != m_harvesters.end(); - i++) + for (auto i = m_harvesters.begin(); i != m_harvesters.end(); i++) { (*i)->Initialize(); } diff --git a/src/energy/helper/energy-harvester-helper.cc b/src/energy/helper/energy-harvester-helper.cc index afec5ffdf..35c269e16 100644 --- a/src/energy/helper/energy-harvester-helper.cc +++ b/src/energy/helper/energy-harvester-helper.cc @@ -43,8 +43,7 @@ EnergyHarvesterContainer EnergyHarvesterHelper::Install(EnergySourceContainer sourceContainer) const { EnergyHarvesterContainer container; - for (EnergySourceContainer::Iterator i = sourceContainer.Begin(); i != sourceContainer.End(); - ++i) + for (auto i = sourceContainer.Begin(); i != sourceContainer.End(); ++i) { Ptr harvester = DoInstall(*i); container.Add(harvester); diff --git a/src/energy/helper/energy-model-helper.cc b/src/energy/helper/energy-model-helper.cc index 8325c03f7..3803db71b 100644 --- a/src/energy/helper/energy-model-helper.cc +++ b/src/energy/helper/energy-model-helper.cc @@ -42,7 +42,7 @@ EnergySourceContainer EnergySourceHelper::Install(NodeContainer c) const { EnergySourceContainer container; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr src = DoInstall(*i); container.Add(src); @@ -105,8 +105,8 @@ DeviceEnergyModelHelper::Install(NetDeviceContainer deviceContainer, { NS_ASSERT(deviceContainer.GetN() <= sourceContainer.GetN()); DeviceEnergyModelContainer container; - NetDeviceContainer::Iterator dev = deviceContainer.Begin(); - EnergySourceContainer::Iterator src = sourceContainer.Begin(); + auto dev = deviceContainer.Begin(); + auto src = sourceContainer.Begin(); while (dev != deviceContainer.End()) { // check to make sure source and net device are on the same node diff --git a/src/energy/helper/energy-source-container.cc b/src/energy/helper/energy-source-container.cc index b41f66d26..9794b146e 100644 --- a/src/energy/helper/energy-source-container.cc +++ b/src/energy/helper/energy-source-container.cc @@ -93,7 +93,7 @@ EnergySourceContainer::Get(uint32_t i) const void EnergySourceContainer::Add(EnergySourceContainer container) { - for (Iterator i = container.Begin(); i != container.End(); i++) + for (auto i = container.Begin(); i != container.End(); i++) { m_sources.push_back(*i); } @@ -122,7 +122,7 @@ void EnergySourceContainer::DoDispose() { // call Object::Dispose for all EnergySource objects - for (std::vector>::iterator i = m_sources.begin(); i != m_sources.end(); i++) + for (auto i = m_sources.begin(); i != m_sources.end(); i++) { (*i)->DisposeDeviceModels(); (*i)->Dispose(); @@ -134,7 +134,7 @@ void EnergySourceContainer::DoInitialize() { // call Object::Start for all EnergySource objects - for (std::vector>::iterator i = m_sources.begin(); i != m_sources.end(); i++) + for (auto i = m_sources.begin(); i != m_sources.end(); i++) { (*i)->Initialize(); (*i)->InitializeDeviceModels(); diff --git a/src/energy/helper/generic-battery-model-helper.cc b/src/energy/helper/generic-battery-model-helper.cc index 93dc63321..285b66d2f 100644 --- a/src/energy/helper/generic-battery-model-helper.cc +++ b/src/energy/helper/generic-battery-model-helper.cc @@ -51,7 +51,7 @@ Ptr GenericBatteryModelHelper::Install(NodeContainer c) const { Ptr batteryContainer = CreateObject(); - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { batteryContainer->Add(DoInstall(*i)); } @@ -90,7 +90,7 @@ EnergySourceContainer GenericBatteryModelHelper::Install(NodeContainer c, BatteryModel bm) const { EnergySourceContainer batteryContainer; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { Ptr energySource = Install(*i, bm); batteryContainer.Add(energySource); @@ -147,9 +147,7 @@ GenericBatteryModelHelper::SetCellPack(EnergySourceContainer energySourceContain { NS_ASSERT_MSG(energySourceContainer.GetN() > 0, "This energy container is empty"); - for (EnergySourceContainer::Iterator i = energySourceContainer.Begin(); - i != energySourceContainer.End(); - i++) + for (auto i = energySourceContainer.Begin(); i != energySourceContainer.End(); i++) { SetCellPack(*i, series, parallel); } diff --git a/src/energy/model/device-energy-model-container.cc b/src/energy/model/device-energy-model-container.cc index 05208f7d0..a1a5579b6 100644 --- a/src/energy/model/device-energy-model-container.cc +++ b/src/energy/model/device-energy-model-container.cc @@ -89,7 +89,7 @@ void DeviceEnergyModelContainer::Add(DeviceEnergyModelContainer container) { NS_LOG_FUNCTION(this << &container); - for (Iterator i = container.Begin(); i != container.End(); i++) + for (auto i = container.Begin(); i != container.End(); i++) { m_models.push_back(*i); } diff --git a/src/energy/model/energy-source.cc b/src/energy/model/energy-source.cc index 3f483f715..ba517a9e3 100644 --- a/src/energy/model/energy-source.cc +++ b/src/energy/model/energy-source.cc @@ -172,8 +172,7 @@ EnergySource::CalculateTotalCurrent() { double totalHarvestedPower = 0.0; - std::vector>::const_iterator harvester; - for (harvester = m_harvesters.begin(); harvester != m_harvesters.end(); harvester++) + for (auto harvester = m_harvesters.begin(); harvester != m_harvesters.end(); harvester++) { totalHarvestedPower += (*harvester)->GetPower(); } diff --git a/src/fd-net-device/examples/fd-emu-onoff.cc b/src/fd-net-device/examples/fd-emu-onoff.cc index 4145263f8..e28abcf19 100644 --- a/src/fd-net-device/examples/fd-emu-onoff.cc +++ b/src/fd-net-device/examples/fd-emu-onoff.cc @@ -200,7 +200,7 @@ main(int argc, char* argv[]) #ifdef HAVE_PACKET_H if (emuMode == "raw") { - EmuFdNetDeviceHelper* raw = new EmuFdNetDeviceHelper; + auto raw = new EmuFdNetDeviceHelper; raw->SetDeviceName(deviceName); helper = raw; } diff --git a/src/fd-net-device/examples/fd-emu-ping.cc b/src/fd-net-device/examples/fd-emu-ping.cc index 5693248c9..f41b2a149 100644 --- a/src/fd-net-device/examples/fd-emu-ping.cc +++ b/src/fd-net-device/examples/fd-emu-ping.cc @@ -184,7 +184,7 @@ main(int argc, char* argv[]) #ifdef HAVE_PACKET_H if (emuMode == "raw") { - EmuFdNetDeviceHelper* raw = new EmuFdNetDeviceHelper; + auto raw = new EmuFdNetDeviceHelper; raw->SetDeviceName(deviceName); helper = raw; } diff --git a/src/fd-net-device/examples/fd-emu-send.cc b/src/fd-net-device/examples/fd-emu-send.cc index be6e0cc2a..cea8aa620 100644 --- a/src/fd-net-device/examples/fd-emu-send.cc +++ b/src/fd-net-device/examples/fd-emu-send.cc @@ -57,15 +57,15 @@ Send(Ptr dev, int level, std::string emuMode) int packets = 10000000; - Mac48Address sender = Mac48Address("00:00:00:aa:00:01"); - Mac48Address receiver = Mac48Address("ff:ff:ff:ff:ff:ff"); + Mac48Address sender("00:00:00:aa:00:01"); + Mac48Address receiver("ff:ff:ff:ff:ff:ff"); int packetsSize = 64; Ptr packet = Create(packetsSize); EthernetHeader header; ssize_t len = (size_t)packet->GetSize(); - uint8_t* buffer = (uint8_t*)malloc(len); + auto buffer = (uint8_t*)malloc(len); packet->CopyData(buffer, len); int sent = 0; @@ -166,7 +166,7 @@ main(int argc, char* argv[]) #ifdef HAVE_PACKET_H if (emuMode == "raw") { - EmuFdNetDeviceHelper* raw = new EmuFdNetDeviceHelper; + auto raw = new EmuFdNetDeviceHelper; raw->SetDeviceName(deviceName); helper = raw; } diff --git a/src/fd-net-device/examples/fd-emu-tc.cc b/src/fd-net-device/examples/fd-emu-tc.cc index 2e5cb304d..cab3aa7b3 100644 --- a/src/fd-net-device/examples/fd-emu-tc.cc +++ b/src/fd-net-device/examples/fd-emu-tc.cc @@ -168,11 +168,11 @@ main(int argc, char* argv[]) #ifdef HAVE_PACKET_H if (emuMode == "raw") { - EmuFdNetDeviceHelper* raw0 = new EmuFdNetDeviceHelper; + auto raw0 = new EmuFdNetDeviceHelper; raw0->SetDeviceName(deviceName0); helper0 = raw0; - EmuFdNetDeviceHelper* raw1 = new EmuFdNetDeviceHelper; + auto raw1 = new EmuFdNetDeviceHelper; raw1->SetDeviceName(deviceName1); helper1 = raw1; } diff --git a/src/fd-net-device/helper/fd-net-device-helper.cc b/src/fd-net-device/helper/fd-net-device-helper.cc index a4d892a9c..8ea4b7093 100644 --- a/src/fd-net-device/helper/fd-net-device-helper.cc +++ b/src/fd-net-device/helper/fd-net-device-helper.cc @@ -199,7 +199,7 @@ FdNetDeviceHelper::Install(const NodeContainer& c) const { NetDeviceContainer devs; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { devs.Add(InstallPriv(*i)); } diff --git a/src/fd-net-device/model/fd-net-device.cc b/src/fd-net-device/model/fd-net-device.cc index 127441f44..70185637a 100644 --- a/src/fd-net-device/model/fd-net-device.cc +++ b/src/fd-net-device/model/fd-net-device.cc @@ -61,7 +61,7 @@ FdNetDeviceFdReader::DoRead() { NS_LOG_FUNCTION(this); - uint8_t* buf = (uint8_t*)malloc(m_bufferSize); + auto buf = (uint8_t*)malloc(m_bufferSize); NS_ABORT_MSG_IF(buf == nullptr, "malloc() failed"); NS_LOG_LOGIC("Calling read on fd " << m_fd); @@ -350,7 +350,7 @@ static void AddPIHeader(uint8_t*& buf, size_t& len) { // Synthesize PI header for our friend the kernel - uint8_t* buf2 = (uint8_t*)malloc(len + 4); + auto buf2 = (uint8_t*)malloc(len + 4); memcpy(buf2 + 4, buf, len); len += 4; @@ -617,7 +617,7 @@ FdNetDevice::SendFrom(Ptr packet, NS_LOG_LOGIC("calling write"); - size_t len = (size_t)packet->GetSize(); + auto len = (size_t)packet->GetSize(); uint8_t* buffer = AllocateBuffer(len); if (!buffer) { diff --git a/src/flow-monitor/helper/flow-monitor-helper.cc b/src/flow-monitor/helper/flow-monitor-helper.cc index c991f5ea0..44b9e5c01 100644 --- a/src/flow-monitor/helper/flow-monitor-helper.cc +++ b/src/flow-monitor/helper/flow-monitor-helper.cc @@ -112,7 +112,7 @@ FlowMonitorHelper::Install(Ptr node) Ptr FlowMonitorHelper::Install(NodeContainer nodes) { - for (NodeContainer::Iterator i = nodes.Begin(); i != nodes.End(); ++i) + for (auto i = nodes.Begin(); i != nodes.End(); ++i) { Ptr node = *i; if (node->GetObject() || node->GetObject()) @@ -126,7 +126,7 @@ FlowMonitorHelper::Install(NodeContainer nodes) Ptr FlowMonitorHelper::InstallAll() { - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr node = *i; if (node->GetObject() || node->GetObject()) diff --git a/src/flow-monitor/model/flow-monitor.cc b/src/flow-monitor/model/flow-monitor.cc index 9369004dc..ecb03138c 100644 --- a/src/flow-monitor/model/flow-monitor.cc +++ b/src/flow-monitor/model/flow-monitor.cc @@ -102,9 +102,7 @@ FlowMonitor::DoDispose() NS_LOG_FUNCTION(this); Simulator::Cancel(m_startEvent); Simulator::Cancel(m_stopEvent); - for (std::list>::iterator iter = m_classifiers.begin(); - iter != m_classifiers.end(); - iter++) + for (auto iter = m_classifiers.begin(); iter != m_classifiers.end(); iter++) { *iter = nullptr; } @@ -120,8 +118,7 @@ inline FlowMonitor::FlowStats& FlowMonitor::GetStatsForFlow(FlowId flowId) { NS_LOG_FUNCTION(this); - FlowStatsContainerI iter; - iter = m_flowStats.find(flowId); + auto iter = m_flowStats.find(flowId); if (iter == m_flowStats.end()) { FlowMonitor::FlowStats& ref = m_flowStats[flowId]; @@ -191,7 +188,7 @@ FlowMonitor::ReportForwarding(Ptr probe, return; } std::pair key(flowId, packetId); - TrackedPacketMap::iterator tracked = m_trackedPackets.find(key); + auto tracked = m_trackedPackets.find(key); if (tracked == m_trackedPackets.end()) { NS_LOG_WARN("Received packet forward report (flowId=" @@ -218,7 +215,7 @@ FlowMonitor::ReportLastRx(Ptr probe, NS_LOG_DEBUG("FlowMonitor not enabled; returning"); return; } - TrackedPacketMap::iterator tracked = m_trackedPackets.find(std::make_pair(flowId, packetId)); + auto tracked = m_trackedPackets.find(std::make_pair(flowId, packetId)); if (tracked == m_trackedPackets.end()) { NS_LOG_WARN("Received packet last-tx report (flowId=" @@ -302,7 +299,7 @@ FlowMonitor::ReportDrop(Ptr probe, NS_LOG_DEBUG("++stats.packetsDropped[" << reasonCode << "]; // becomes: " << stats.packetsDropped[reasonCode]); - TrackedPacketMap::iterator tracked = m_trackedPackets.find(std::make_pair(flowId, packetId)); + auto tracked = m_trackedPackets.find(std::make_pair(flowId, packetId)); if (tracked != m_trackedPackets.end()) { // we don't need to track this packet anymore @@ -325,13 +322,12 @@ FlowMonitor::CheckForLostPackets(Time maxDelay) NS_LOG_FUNCTION(this << maxDelay.As(Time::S)); Time now = Simulator::Now(); - for (TrackedPacketMap::iterator iter = m_trackedPackets.begin(); - iter != m_trackedPackets.end();) + for (auto iter = m_trackedPackets.begin(); iter != m_trackedPackets.end();) { if (now - iter->second.lastSeenTime >= maxDelay) { // packet is considered lost, add it to the loss statistics - FlowStatsContainerI flow = m_flowStats.find(iter->first.first); + auto flow = m_flowStats.find(iter->first.first); NS_ASSERT(flow != m_flowStats.end()); flow->second.lostPackets++; @@ -444,7 +440,7 @@ FlowMonitor::SerializeToXmlStream(std::ostream& os, indent += 2; os << std::string(indent, ' ') << "\n"; indent += 2; - for (FlowStatsContainerCI flowI = m_flowStats.begin(); flowI != m_flowStats.end(); flowI++) + for (auto flowI = m_flowStats.begin(); flowI != m_flowStats.end(); flowI++) { os << std::string(indent, ' '); #define ATTRIB(name) << " " #name "=\"" << flowI->second.name << "\"" @@ -492,9 +488,7 @@ FlowMonitor::SerializeToXmlStream(std::ostream& os, indent -= 2; os << std::string(indent, ' ') << "\n"; - for (std::list>::iterator iter = m_classifiers.begin(); - iter != m_classifiers.end(); - iter++) + for (auto iter = m_classifiers.begin(); iter != m_classifiers.end(); iter++) { (*iter)->SerializeToXmlStream(os, indent); } diff --git a/src/flow-monitor/model/flow-probe.cc b/src/flow-monitor/model/flow-probe.cc index 4c5f4f48b..827fe7f68 100644 --- a/src/flow-monitor/model/flow-probe.cc +++ b/src/flow-monitor/model/flow-probe.cc @@ -88,7 +88,7 @@ FlowProbe::SerializeToXmlStream(std::ostream& os, uint16_t indent, uint32_t inde indent += 2; - for (Stats::const_iterator iter = m_stats.begin(); iter != m_stats.end(); iter++) + for (auto iter = m_stats.begin(); iter != m_stats.end(); iter++) { os << std::string(indent, ' '); os << "::iterator, bool> insert = - m_flowMap.insert(std::pair(tuple, 0)); + auto insert = m_flowMap.insert(std::pair(tuple, 0)); // if the insertion succeeded, we need to assign this tuple a new flow identifier if (insert.second) @@ -163,9 +162,8 @@ Ipv4FlowClassifier::Classify(const Ipv4Header& ipHeader, // increment the counter of packets with the same DSCP value Ipv4Header::DscpType dscp = ipHeader.GetDscp(); - std::pair::iterator, bool> dscpInserter = - m_flowDscpMap[insert.first->second].insert( - std::pair(dscp, 1)); + auto dscpInserter = m_flowDscpMap[insert.first->second].insert( + std::pair(dscp, 1)); // if the insertion did not succeed, we need to increment the counter if (!dscpInserter.second) @@ -182,9 +180,7 @@ Ipv4FlowClassifier::Classify(const Ipv4Header& ipHeader, Ipv4FlowClassifier::FiveTuple Ipv4FlowClassifier::FindFlow(FlowId flowId) const { - for (std::map::const_iterator iter = m_flowMap.begin(); - iter != m_flowMap.end(); - iter++) + for (auto iter = m_flowMap.begin(); iter != m_flowMap.end(); iter++) { if (iter->second == flowId) { @@ -206,8 +202,7 @@ Ipv4FlowClassifier::SortByCount::operator()(std::pair> Ipv4FlowClassifier::GetDscpCounts(FlowId flowId) const { - std::map>::const_iterator flow = - m_flowDscpMap.find(flowId); + auto flow = m_flowDscpMap.find(flowId); if (flow == m_flowDscpMap.end()) { @@ -227,9 +222,7 @@ Ipv4FlowClassifier::SerializeToXmlStream(std::ostream& os, uint16_t indent) cons os << "\n"; indent += 2; - for (std::map::const_iterator iter = m_flowMap.begin(); - iter != m_flowMap.end(); - iter++) + for (auto iter = m_flowMap.begin(); iter != m_flowMap.end(); iter++) { Indent(os, indent); os << "second << "\"" @@ -240,14 +233,11 @@ Ipv4FlowClassifier::SerializeToXmlStream(std::ostream& os, uint16_t indent) cons << " destinationPort=\"" << iter->first.destinationPort << "\">\n"; indent += 2; - std::map>::const_iterator flow = - m_flowDscpMap.find(iter->second); + auto flow = m_flowDscpMap.find(iter->second); if (flow != m_flowDscpMap.end()) { - for (std::map::const_iterator i = flow->second.begin(); - i != flow->second.end(); - i++) + for (auto i = flow->second.begin(); i != flow->second.end(); i++) { Indent(os, indent); os << "(i->first) << "\"" diff --git a/src/flow-monitor/model/ipv6-flow-classifier.cc b/src/flow-monitor/model/ipv6-flow-classifier.cc index 3e61c5ff2..7f9b69cc1 100644 --- a/src/flow-monitor/model/ipv6-flow-classifier.cc +++ b/src/flow-monitor/model/ipv6-flow-classifier.cc @@ -146,8 +146,7 @@ Ipv6FlowClassifier::Classify(const Ipv6Header& ipHeader, tuple.destinationPort = dstPort; // try to insert the tuple, but check if it already exists - std::pair::iterator, bool> insert = - m_flowMap.insert(std::pair(tuple, 0)); + auto insert = m_flowMap.insert(std::pair(tuple, 0)); // if the insertion succeeded, we need to assign this tuple a new flow identifier if (insert.second) @@ -164,9 +163,8 @@ Ipv6FlowClassifier::Classify(const Ipv6Header& ipHeader, // increment the counter of packets with the same DSCP value Ipv6Header::DscpType dscp = ipHeader.GetDscp(); - std::pair::iterator, bool> dscpInserter = - m_flowDscpMap[insert.first->second].insert( - std::pair(dscp, 1)); + auto dscpInserter = m_flowDscpMap[insert.first->second].insert( + std::pair(dscp, 1)); // if the insertion did not succeed, we need to increment the counter if (!dscpInserter.second) @@ -183,9 +181,7 @@ Ipv6FlowClassifier::Classify(const Ipv6Header& ipHeader, Ipv6FlowClassifier::FiveTuple Ipv6FlowClassifier::FindFlow(FlowId flowId) const { - for (std::map::const_iterator iter = m_flowMap.begin(); - iter != m_flowMap.end(); - iter++) + for (auto iter = m_flowMap.begin(); iter != m_flowMap.end(); iter++) { if (iter->second == flowId) { @@ -207,8 +203,7 @@ Ipv6FlowClassifier::SortByCount::operator()(std::pair> Ipv6FlowClassifier::GetDscpCounts(FlowId flowId) const { - std::map>::const_iterator flow = - m_flowDscpMap.find(flowId); + auto flow = m_flowDscpMap.find(flowId); if (flow == m_flowDscpMap.end()) { @@ -228,9 +223,7 @@ Ipv6FlowClassifier::SerializeToXmlStream(std::ostream& os, uint16_t indent) cons os << "\n"; indent += 2; - for (std::map::const_iterator iter = m_flowMap.begin(); - iter != m_flowMap.end(); - iter++) + for (auto iter = m_flowMap.begin(); iter != m_flowMap.end(); iter++) { Indent(os, indent); os << "second << "\"" @@ -241,14 +234,11 @@ Ipv6FlowClassifier::SerializeToXmlStream(std::ostream& os, uint16_t indent) cons << " destinationPort=\"" << iter->first.destinationPort << "\">\n"; indent += 2; - std::map>::const_iterator flow = - m_flowDscpMap.find(iter->second); + auto flow = m_flowDscpMap.find(iter->second); if (flow != m_flowDscpMap.end()) { - for (std::map::const_iterator i = flow->second.begin(); - i != flow->second.end(); - i++) + for (auto i = flow->second.begin(); i != flow->second.end(); i++) { Indent(os, indent); os << "(i->first) << "\"" diff --git a/src/internet-apps/examples/ping-example.cc b/src/internet-apps/examples/ping-example.cc index 80700017e..ca0e4e955 100644 --- a/src/internet-apps/examples/ping-example.cc +++ b/src/internet-apps/examples/ping-example.cc @@ -115,8 +115,8 @@ main(int argc, char* argv[]) if (!destinationStr.empty()) { - Ipv4Address v4Dst = Ipv4Address(destinationStr.c_str()); - Ipv6Address v6Dst = Ipv6Address(destinationStr.c_str()); + Ipv4Address v4Dst(destinationStr.c_str()); + Ipv6Address v6Dst(destinationStr.c_str()); if (v4Dst.IsInitialized()) { useIpv6 = false; @@ -131,8 +131,8 @@ main(int argc, char* argv[]) if (!sourceStr.empty()) { - Ipv4Address v4Src = Ipv4Address(sourceStr.c_str()); - Ipv6Address v6Src = Ipv6Address(sourceStr.c_str()); + Ipv4Address v4Src(sourceStr.c_str()); + Ipv6Address v6Src(sourceStr.c_str()); if (v4Src.IsInitialized()) { source = v4Src; @@ -157,7 +157,7 @@ main(int argc, char* argv[]) } else { - Ipv4Address v4Dst = Ipv4Address(destinationStr.c_str()); + Ipv4Address v4Dst(destinationStr.c_str()); if (v4Dst.IsInitialized() && (v4Dst.IsBroadcast() || v4Dst.IsMulticast())) { std::cout << "Specify a source address to use when pinging broadcast or multicast " diff --git a/src/internet-apps/helper/dhcp-helper.cc b/src/internet-apps/helper/dhcp-helper.cc index 97d4dfdae..fd31acd13 100644 --- a/src/internet-apps/helper/dhcp-helper.cc +++ b/src/internet-apps/helper/dhcp-helper.cc @@ -67,7 +67,7 @@ ApplicationContainer DhcpHelper::InstallDhcpClient(NetDeviceContainer netDevices) const { ApplicationContainer apps; - for (NetDeviceContainer::Iterator i = netDevices.Begin(); i != netDevices.End(); ++i) + for (auto i = netDevices.Begin(); i != netDevices.End(); ++i) { apps.Add(InstallDhcpClientPriv(*i)); } @@ -184,8 +184,7 @@ DhcpHelper::InstallDhcpServer(Ptr netDevice, } // check that the already fixed addresses are not in conflict with the pool - std::list::iterator iter; - for (iter = m_fixedAddresses.begin(); iter != m_fixedAddresses.end(); iter++) + for (auto iter = m_fixedAddresses.begin(); iter != m_fixedAddresses.end(); iter++) { if (iter->Get() >= minAddr.Get() && iter->Get() <= maxAddr.Get()) { @@ -250,8 +249,7 @@ DhcpHelper::InstallFixedAddress(Ptr netDevice, Ipv4Address addr, Ipv4 } // check that the already fixed addresses are not in conflict with the pool - std::list>::iterator iter; - for (iter = m_addressPools.begin(); iter != m_addressPools.end(); iter++) + for (auto iter = m_addressPools.begin(); iter != m_addressPools.end(); iter++) { if (addr.Get() >= iter->first.Get() && addr.Get() <= iter->second.Get()) { diff --git a/src/internet-apps/helper/ping-helper.cc b/src/internet-apps/helper/ping-helper.cc index 2e601fd00..7807831b5 100644 --- a/src/internet-apps/helper/ping-helper.cc +++ b/src/internet-apps/helper/ping-helper.cc @@ -65,7 +65,7 @@ ApplicationContainer PingHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } diff --git a/src/internet-apps/helper/ping6-helper.cc b/src/internet-apps/helper/ping6-helper.cc index 62c3bd04f..5efccc71c 100644 --- a/src/internet-apps/helper/ping6-helper.cc +++ b/src/internet-apps/helper/ping6-helper.cc @@ -59,7 +59,7 @@ Ping6Helper::Install(NodeContainer c) #pragma GCC diagnostic ignored "-Wdeprecated-declarations" ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr client = m_factory.Create(); diff --git a/src/internet-apps/helper/radvd-helper.cc b/src/internet-apps/helper/radvd-helper.cc index 61b431c5d..0891d51af 100644 --- a/src/internet-apps/helper/radvd-helper.cc +++ b/src/internet-apps/helper/radvd-helper.cc @@ -120,8 +120,7 @@ RadvdHelper::Install(Ptr node) { ApplicationContainer apps; Ptr radvd = m_factory.Create(); - for (RadvdInterfaceMapI iter = m_radvdInterfaces.begin(); iter != m_radvdInterfaces.end(); - iter++) + for (auto iter = m_radvdInterfaces.begin(); iter != m_radvdInterfaces.end(); iter++) { if (!iter->second->GetPrefixes().empty()) { diff --git a/src/internet-apps/helper/v4ping-helper.cc b/src/internet-apps/helper/v4ping-helper.cc index 9428184c4..d018fd8b9 100644 --- a/src/internet-apps/helper/v4ping-helper.cc +++ b/src/internet-apps/helper/v4ping-helper.cc @@ -57,7 +57,7 @@ ApplicationContainer V4PingHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } diff --git a/src/internet-apps/helper/v4traceroute-helper.cc b/src/internet-apps/helper/v4traceroute-helper.cc index cf968388c..99f249fc3 100644 --- a/src/internet-apps/helper/v4traceroute-helper.cc +++ b/src/internet-apps/helper/v4traceroute-helper.cc @@ -56,7 +56,7 @@ ApplicationContainer V4TraceRouteHelper::Install(NodeContainer c) const { ApplicationContainer apps; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { apps.Add(InstallPriv(*i)); } diff --git a/src/internet-apps/model/dhcp-header.cc b/src/internet-apps/model/dhcp-header.cc index 6022c9c15..df9d5a603 100644 --- a/src/internet-apps/model/dhcp-header.cc +++ b/src/internet-apps/model/dhcp-header.cc @@ -42,7 +42,7 @@ DhcpHeader::DhcpHeader() m_secs = 0; m_hops = 0; m_flags = 0; - Ipv4Address addr = Ipv4Address("0.0.0.0"); + Ipv4Address addr("0.0.0.0"); m_yiAddr = addr; m_ciAddr = addr; m_siAddr = addr; diff --git a/src/internet-apps/model/dhcp-server.cc b/src/internet-apps/model/dhcp-server.cc index 26dba3a87..43ff27dc6 100644 --- a/src/internet-apps/model/dhcp-server.cc +++ b/src/internet-apps/model/dhcp-server.cc @@ -160,7 +160,7 @@ DhcpServer::StartApplication() uint32_t range = m_maxAddress.Get() - m_minAddress.Get() + 1; for (uint32_t searchSeq = 0; searchSeq < range; searchSeq++) { - Ipv4Address poolAddress = Ipv4Address(m_minAddress.Get() + searchSeq); + Ipv4Address poolAddress(m_minAddress.Get() + searchSeq); if (poolAddress != myOwnAddress) { NS_LOG_LOGIC("Adding " << poolAddress << " to the pool"); @@ -259,7 +259,7 @@ DhcpServer::SendOffer(Ptr iDev, DhcpHeader header, InetSocketAddress NS_LOG_INFO("DHCP DISCOVER from: " << from.GetIpv4() << " source port: " << from.GetPort()); - LeasedAddressIter iter = m_leasedAddresses.find(sourceChaddr); + auto iter = m_leasedAddresses.find(sourceChaddr); if (iter != m_leasedAddresses.end()) { // We know this client from some time ago @@ -425,8 +425,7 @@ DhcpServer::AddStaticDhcpEntry(Address chaddr, Ipv4Address addr) NS_ASSERT_MSG(m_leasedAddresses.find(cleanedCaddr) == m_leasedAddresses.end(), "Client has already an active lease: " << m_leasedAddresses[cleanedCaddr].first); - AvailableAddress::iterator it = - find(m_availableAddresses.begin(), m_availableAddresses.end(), addr); + auto it = find(m_availableAddresses.begin(), m_availableAddresses.end(), addr); NS_ASSERT_MSG( it == m_availableAddresses.end(), "Required address is not available (perhaps it has been already assigned): " << addr); diff --git a/src/internet-apps/model/ping.cc b/src/internet-apps/model/ping.cc index a241babbb..96af7c094 100644 --- a/src/internet-apps/model/ping.cc +++ b/src/internet-apps/model/ping.cc @@ -206,7 +206,7 @@ Ping::Receive(Ptr socket) NS_LOG_INFO("Packet too short, discarding"); return; } - uint8_t* buf = new uint8_t[dataSize]; + auto buf = new uint8_t[dataSize]; echo.GetData(buf); uint64_t appSignature = Read64(buf); delete[] buf; @@ -305,7 +305,7 @@ Ping::Receive(Ptr socket) NS_LOG_INFO("Packet too short, discarding"); return; } - uint8_t* buf = new uint8_t[dataSize]; + auto buf = new uint8_t[dataSize]; packet->CopyData(buf, dataSize); uint64_t appSignature = Read64(buf); delete[] buf; @@ -426,7 +426,7 @@ Ping::Send() // (where any difference would show up anyway) and borrow that code. Don't // be too surprised when you see that this is a little endian convention. // - uint8_t* data = new uint8_t[m_size]; + auto data = new uint8_t[m_size]; memset(data, 0, m_size); NS_ASSERT_MSG(m_size >= 16, "ECHO Payload size must be at least 16 bytes"); @@ -583,8 +583,7 @@ Ping::StartApplication() { if (Ipv4Address::IsMatchingType(m_interfaceAddress)) { - InetSocketAddress senderInet = - InetSocketAddress(Ipv4Address::ConvertFrom(m_interfaceAddress)); + InetSocketAddress senderInet(Ipv4Address::ConvertFrom(m_interfaceAddress)); int status = m_socket->Bind(senderInet); NS_ASSERT_MSG(status == 0, "Failed to bind IPv4 socket"); } diff --git a/src/internet-apps/model/ping6.cc b/src/internet-apps/model/ping6.cc index d6757c419..a08ec697c 100644 --- a/src/internet-apps/model/ping6.cc +++ b/src/internet-apps/model/ping6.cc @@ -210,7 +210,7 @@ Ping6::Send() size = 4; } - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; memset(data, 0, size); data[0] = 0xDE; data[1] = 0xAD; diff --git a/src/internet-apps/model/radvd-interface.cc b/src/internet-apps/model/radvd-interface.cc index 83d67b019..03a079cf3 100644 --- a/src/internet-apps/model/radvd-interface.cc +++ b/src/internet-apps/model/radvd-interface.cc @@ -86,7 +86,7 @@ RadvdInterface::~RadvdInterface() { NS_LOG_FUNCTION(this); /* clear prefixes */ - for (RadvdPrefixListI it = m_prefixes.begin(); it != m_prefixes.end(); ++it) + for (auto it = m_prefixes.begin(); it != m_prefixes.end(); ++it) { (*it) = nullptr; } diff --git a/src/internet-apps/model/radvd.cc b/src/internet-apps/model/radvd.cc index bb9f92d09..b450ad8ab 100644 --- a/src/internet-apps/model/radvd.cc +++ b/src/internet-apps/model/radvd.cc @@ -75,7 +75,7 @@ Radvd::Radvd() Radvd::~Radvd() { NS_LOG_FUNCTION(this); - for (RadvdInterfaceListI it = m_configurations.begin(); it != m_configurations.end(); ++it) + for (auto it = m_configurations.begin(); it != m_configurations.end(); ++it) { *it = nullptr; } @@ -91,7 +91,7 @@ Radvd::DoDispose() m_recvSocket->Close(); m_recvSocket = nullptr; - for (SocketMapI it = m_sendSockets.begin(); it != m_sendSockets.end(); ++it) + for (auto it = m_sendSockets.begin(); it != m_sendSockets.end(); ++it) { it->second->Close(); it->second = nullptr; @@ -120,7 +120,7 @@ Radvd::StartApplication() m_recvSocket->SetRecvPktInfo(true); } - for (RadvdInterfaceListCI it = m_configurations.begin(); it != m_configurations.end(); it++) + for (auto it = m_configurations.begin(); it != m_configurations.end(); it++) { if ((*it)->IsSendAdvert()) { @@ -159,13 +159,13 @@ Radvd::StopApplication() m_recvSocket->SetRecvCallback(MakeNullCallback>()); } - for (EventIdMapI it = m_unsolicitedEventIds.begin(); it != m_unsolicitedEventIds.end(); ++it) + for (auto it = m_unsolicitedEventIds.begin(); it != m_unsolicitedEventIds.end(); ++it) { Simulator::Cancel((*it).second); } m_unsolicitedEventIds.clear(); - for (EventIdMapI it = m_solicitedEventIds.begin(); it != m_solicitedEventIds.end(); ++it) + for (auto it = m_solicitedEventIds.begin(); it != m_solicitedEventIds.end(); ++it) { Simulator::Cancel((*it).second); } @@ -231,8 +231,7 @@ Radvd::Send(Ptr config, Ipv6Address dst, bool reschedule) } /* add list of prefixes */ - for (std::list>::const_iterator jt = prefixes.begin(); jt != prefixes.end(); - jt++) + for (auto jt = prefixes.begin(); jt != prefixes.end(); jt++) { uint8_t flags = 0; prefixHdr = Icmpv6OptionPrefixInformation(); @@ -288,7 +287,7 @@ Radvd::Send(Ptr config, Ipv6Address dst, bool reschedule) if (reschedule) { - uint64_t delay = static_cast( + auto delay = static_cast( m_jitter->GetValue(config->GetMinRtrAdvInterval(), config->GetMaxRtrAdvInterval()) + 0.5); if (config->IsInitialRtrAdv()) @@ -348,9 +347,7 @@ Radvd::HandleRead(Ptr socket) NS_LOG_INFO("Received ICMPv6 Router Solicitation from " << hdr.GetSource() << " code = " << (uint32_t)rsHdr.GetCode()); - for (RadvdInterfaceListCI it = m_configurations.begin(); - it != m_configurations.end(); - it++) + for (auto it = m_configurations.begin(); it != m_configurations.end(); it++) { if (ipInterfaceIndex == (*it)->GetInterface()) { diff --git a/src/internet-apps/model/v4ping.cc b/src/internet-apps/model/v4ping.cc index d18ba208a..9a817a6d0 100644 --- a/src/internet-apps/model/v4ping.cc +++ b/src/internet-apps/model/v4ping.cc @@ -137,11 +137,11 @@ V4Ping::Receive(Ptr socket) { Icmpv4Echo echo; p->RemoveHeader(echo); - std::map::iterator i = m_sent.find(echo.GetSequenceNumber()); + auto i = m_sent.find(echo.GetSequenceNumber()); if (i != m_sent.end() && echo.GetIdentifier() == 0) { - uint32_t* buf = new uint32_t[m_size]; + auto buf = new uint32_t[m_size]; uint32_t dataSize = echo.GetDataSize(); uint32_t nodeId; uint32_t appId; @@ -215,7 +215,7 @@ V4Ping::Send() // (where any difference would show up anyway) and borrow that code. Don't // be too surprised when you see that this is a little endian convention. // - uint8_t* data = new uint8_t[m_size]; + auto data = new uint8_t[m_size]; for (uint32_t i = 0; i < m_size; ++i) { data[i] = 0; diff --git a/src/internet-apps/model/v4traceroute.cc b/src/internet-apps/model/v4traceroute.cc index 1bff07cbd..b63919379 100644 --- a/src/internet-apps/model/v4traceroute.cc +++ b/src/internet-apps/model/v4traceroute.cc @@ -243,7 +243,7 @@ V4TraceRoute::Receive(Ptr socket) recvSeq = (uint16_t)data[7] << 0; recvSeq |= (uint16_t)data[6] << 8; - std::map::iterator i = m_sent.find(recvSeq); + auto i = m_sent.find(recvSeq); if (i != m_sent.end()) { Time sendTime = i->second; @@ -296,7 +296,7 @@ V4TraceRoute::Receive(Ptr socket) Icmpv4Echo echo; p->RemoveHeader(echo); - std::map::iterator i = m_sent.find(echo.GetSequenceNumber()); + auto i = m_sent.find(echo.GetSequenceNumber()); if (i != m_sent.end() && echo.GetIdentifier() == 0) { diff --git a/src/internet-apps/test/ping-test.cc b/src/internet-apps/test/ping-test.cc index 2114d9000..a09327b15 100644 --- a/src/internet-apps/test/ping-test.cc +++ b/src/internet-apps/test/ping-test.cc @@ -576,7 +576,7 @@ PingTestSuite::PingTestSuite() // number sent equals number received, which equals 5. // How validated: PingReport trace is checked for number of packets // transmitted and received (5), and number of drops (0). - PingTestCase* testcase1v4 = new PingTestCase( + auto testcase1v4 = new PingTestCase( "1. Unlimited pings, no losses, StopApplication () with no packets in flight IPv4", USEIPV6_FALSE); testcase1v4->SetStartTime(Seconds(1)); @@ -588,7 +588,7 @@ PingTestSuite::PingTestSuite() testcase1v4->SetDestinationAddress(Ipv4Address("10.0.0.2")); AddTestCase(testcase1v4, TestCase::QUICK); - PingTestCase* testcase1v6 = new PingTestCase( + auto testcase1v6 = new PingTestCase( "1. Unlimited pings, no losses, StopApplication () with no packets in flight IPv6", USEIPV6_TRUE); testcase1v6->SetStartTime(Seconds(1)); @@ -608,7 +608,7 @@ PingTestSuite::PingTestSuite() // to be lost // How validated: PingReport trace is checked for number of packets // transmitted (1) and received (0), and number of drops (0) - PingTestCase* testcase2v4 = new PingTestCase( + auto testcase2v4 = new PingTestCase( "2. Unlimited pings, no losses, StopApplication () with 1 packet in flight IPv4", USEIPV6_FALSE); testcase2v4->SetStartTime(Seconds(1)); @@ -619,7 +619,7 @@ PingTestSuite::PingTestSuite() testcase1v4->SetDestinationAddress(Ipv4Address("10.0.0.2")); AddTestCase(testcase2v4, TestCase::QUICK); - PingTestCase* testcase2v6 = new PingTestCase( + auto testcase2v6 = new PingTestCase( "2. Unlimited pings, no losses, StopApplication () with 1 packet in flight IPv6", USEIPV6_TRUE); testcase2v6->SetStartTime(Seconds(1)); @@ -645,10 +645,9 @@ PingTestSuite::PingTestSuite() // Report time will be MicroSeconds (2020001). uint32_t count = 2; uint32_t expectedTx = 2; - PingTestCase* testcase3v4 = - new PingTestCase("3. Test for operation of count attribute and exit " - "time after all pings were received, IPv4", - USEIPV6_FALSE); + auto testcase3v4 = new PingTestCase("3. Test for operation of count attribute and exit " + "time after all pings were received, IPv4", + USEIPV6_FALSE); testcase3v4->SetStartTime(Seconds(1)); testcase3v4->SetStopTime(Seconds(5)); testcase3v4->SetCount(count); @@ -660,10 +659,9 @@ PingTestSuite::PingTestSuite() testcase3v4->SetDestinationAddress(Ipv4Address("10.0.0.2")); AddTestCase(testcase3v4, TestCase::QUICK); - PingTestCase* testcase3v6 = - new PingTestCase("3. Test for operation of count attribute and exit " - "time after all pings were received, IPv6", - USEIPV6_TRUE); + auto testcase3v6 = new PingTestCase("3. Test for operation of count attribute and exit " + "time after all pings were received, IPv6", + USEIPV6_TRUE); testcase3v6->SetStartTime(Seconds(1)); testcase3v6->SetStopTime(Seconds(5)); testcase3v6->SetCount(count); @@ -685,7 +683,7 @@ PingTestSuite::PingTestSuite() // How validated: PingReport trace is checked for number of packets // transmitted (2) and received (2), and number of drops (0) Time interval = Seconds(3.0); - PingTestCase* testcase4v4 = + auto testcase4v4 = new PingTestCase("4. Test for the operation of interval attribute for IPv4", USEIPV6_FALSE); testcase4v4->SetStartTime(Seconds(1)); testcase4v4->SetStopTime(Seconds(5)); @@ -696,7 +694,7 @@ PingTestSuite::PingTestSuite() testcase4v4->SetDestinationAddress(Ipv4Address("10.0.0.2")); AddTestCase(testcase4v4, TestCase::QUICK); - PingTestCase* testcase4v6 = + auto testcase4v6 = new PingTestCase("4. Test for the operation of interval attribute for IPv6", USEIPV6_TRUE); testcase4v6->SetStartTime(Seconds(1)); testcase4v6->SetStopTime(Seconds(5)); @@ -724,7 +722,7 @@ PingTestSuite::PingTestSuite() // How validated: PingReport trace is checked for number of packets // transmitted (5) and received (0). // The packet loss rate should be checked to be 100 percent - PingTestCase* testcase5v4 = + auto testcase5v4 = new PingTestCase("5. Test for behavior of ping to unreachable IPv4 address", USEIPV6_FALSE); testcase5v4->SetStartTime(Seconds(1)); testcase5v4->SetStopTime(Seconds(5.5)); @@ -734,7 +732,7 @@ PingTestSuite::PingTestSuite() testcase5v4->CheckReportLoss(100); AddTestCase(testcase5v4, TestCase::QUICK); - PingTestCase* testcase5v6 = + auto testcase5v6 = new PingTestCase("5. Test for behavior of ping to unreachable IPv6 address", USEIPV6_TRUE); testcase5v6->SetStartTime(Seconds(1)); testcase5v6->SetStopTime(Seconds(5.5)); @@ -757,7 +755,7 @@ PingTestSuite::PingTestSuite() // How validated: PingReport trace is checked for number of packets // transmitted (2) and received (2),number of drops (0), // Report time will be MicroSeconds (2020001). - PingTestCase* testcase6v4 = + auto testcase6v4 = new PingTestCase("6. Test for behavior of ping to broadcast IPv4 address", USEIPV6_FALSE); testcase6v4->SetStartTime(Seconds(1)); testcase6v4->SetStopTime(Seconds(5.5)); @@ -767,7 +765,7 @@ PingTestSuite::PingTestSuite() testcase6v4->CheckReportLoss(0); AddTestCase(testcase6v4, TestCase::QUICK); - PingTestCase* testcase6v6 = + auto testcase6v6 = new PingTestCase("6. Test for behavior of ping to all-nodes multicast IPv6 address", USEIPV6_TRUE); testcase6v6->SetStartTime(Seconds(1)); @@ -791,7 +789,7 @@ PingTestSuite::PingTestSuite() // transmitted (3) and received (2), loss percentage (33). // Ping Tx trace (3) and Rtt trace (2) are also checked. // Report time will be MicroSeconds (3040000). - PingTestCase* testcase7v4 = new PingTestCase( + auto testcase7v4 = new PingTestCase( "7. Test behavior of first reply lost in a count-limited configuration, IPv4", USEIPV6_FALSE); std::list dropList{0}; @@ -807,7 +805,7 @@ PingTestSuite::PingTestSuite() testcase7v4->CheckReportTime(MicroSeconds(3040000)); AddTestCase(testcase7v4, TestCase::QUICK); - PingTestCase* testcase7v6 = new PingTestCase( + auto testcase7v6 = new PingTestCase( "7. Test behavior of first reply lost in a count-limited configuration, IPv6", USEIPV6_TRUE); testcase7v6->SetDropList(dropList); @@ -836,7 +834,7 @@ PingTestSuite::PingTestSuite() // transmitted (3) and received (2), loss percentage (33). // Ping Tx trace (3) and Rtt trace (2) are also checked. // Report time will be MicroSeconds (3040000). - PingTestCase* testcase8v4 = new PingTestCase( + auto testcase8v4 = new PingTestCase( "8. Test behavior of second reply lost in a count-limited configuration, IPv4", USEIPV6_FALSE); std::list dropList2{1}; @@ -852,7 +850,7 @@ PingTestSuite::PingTestSuite() testcase8v4->CheckReportTime(MicroSeconds(3040000)); AddTestCase(testcase8v4, TestCase::QUICK); - PingTestCase* testcase8v6 = new PingTestCase( + auto testcase8v6 = new PingTestCase( "8. Test behavior of second reply lost in a count-limited configuration, IPv6", USEIPV6_TRUE); testcase8v6->SetDropList(dropList2); @@ -881,7 +879,7 @@ PingTestSuite::PingTestSuite() // transmitted (3) and received (2), loss percentage (33). // Ping Tx trace (3) and Rtt trace (2) are also checked. // Report time will be MicroSeconds (3040000). - PingTestCase* testcase9v4 = new PingTestCase( + auto testcase9v4 = new PingTestCase( "9. Test behavior of last reply lost in a count-limited configuration, IPv4", USEIPV6_FALSE); std::list dropList3{2}; @@ -897,7 +895,7 @@ PingTestSuite::PingTestSuite() testcase9v4->CheckReportTime(MicroSeconds(3040000)); AddTestCase(testcase9v4, TestCase::QUICK); - PingTestCase* testcase9v6 = new PingTestCase( + auto testcase9v6 = new PingTestCase( "9. Test behavior of last reply lost in a count-limited configuration, IPv6", USEIPV6_TRUE); testcase9v6->SetDropList(dropList3); diff --git a/src/internet/helper/internet-stack-helper.cc b/src/internet/helper/internet-stack-helper.cc index cc84eb4e6..0760a4d57 100644 --- a/src/internet/helper/internet-stack-helper.cc +++ b/src/internet/helper/internet-stack-helper.cc @@ -223,7 +223,7 @@ int64_t InternetStackHelper::AssignStreams(NodeContainer c, int64_t stream) { int64_t currentStream = stream; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr router = node->GetObject(); @@ -267,7 +267,7 @@ InternetStackHelper::AssignStreams(NodeContainer c, int64_t stream) void InternetStackHelper::Install(NodeContainer c) const { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Install(*i); } @@ -406,9 +406,7 @@ InternetStackHelper::PcapHooked(Ptr ipv4) { auto id = ipv4->GetObject()->GetId(); - for (InterfaceFileMapIpv4::const_iterator i = g_interfaceFileMapIpv4.begin(); - i != g_interfaceFileMapIpv4.end(); - ++i) + for (auto i = g_interfaceFileMapIpv4.begin(); i != g_interfaceFileMapIpv4.end(); ++i) { if ((*i).first.first == id) { @@ -514,9 +512,7 @@ InternetStackHelper::PcapHooked(Ptr ipv6) { auto id = ipv6->GetObject()->GetId(); - for (InterfaceFileMapIpv6::const_iterator i = g_interfaceFileMapIpv6.begin(); - i != g_interfaceFileMapIpv6.end(); - ++i) + for (auto i = g_interfaceFileMapIpv6.begin(); i != g_interfaceFileMapIpv6.end(); ++i) { if ((*i).first.first == id) { @@ -780,9 +776,7 @@ InternetStackHelper::AsciiHooked(Ptr ipv4) { auto id = ipv4->GetObject()->GetId(); - for (InterfaceStreamMapIpv4::const_iterator i = g_interfaceStreamMapIpv4.begin(); - i != g_interfaceStreamMapIpv4.end(); - ++i) + for (auto i = g_interfaceStreamMapIpv4.begin(); i != g_interfaceStreamMapIpv4.end(); ++i) { if ((*i).first.first == id) { @@ -1126,9 +1120,7 @@ InternetStackHelper::AsciiHooked(Ptr ipv6) { auto id = ipv6->GetObject()->GetId(); - for (InterfaceStreamMapIpv6::const_iterator i = g_interfaceStreamMapIpv6.begin(); - i != g_interfaceStreamMapIpv6.end(); - ++i) + for (auto i = g_interfaceStreamMapIpv6.begin(); i != g_interfaceStreamMapIpv6.end(); ++i) { if ((*i).first.first == id) { diff --git a/src/internet/helper/internet-trace-helper.cc b/src/internet/helper/internet-trace-helper.cc index 4e63373a9..c75919b17 100644 --- a/src/internet/helper/internet-trace-helper.cc +++ b/src/internet/helper/internet-trace-helper.cc @@ -57,7 +57,7 @@ PcapHelperForIpv4::EnablePcapIpv4(std::string prefix, void PcapHelperForIpv4::EnablePcapIpv4(std::string prefix, Ipv4InterfaceContainer c) { - for (Ipv4InterfaceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { EnablePcapIpv4(prefix, (*i).first, (*i).second, false); } @@ -66,7 +66,7 @@ PcapHelperForIpv4::EnablePcapIpv4(std::string prefix, Ipv4InterfaceContainer c) void PcapHelperForIpv4::EnablePcapIpv4(std::string prefix, NodeContainer n) { - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; Ptr ipv4 = node->GetObject(); @@ -94,7 +94,7 @@ PcapHelperForIpv4::EnablePcapIpv4(std::string prefix, { NodeContainer n = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; if (node->GetId() != nodeid) @@ -197,7 +197,7 @@ AsciiTraceHelperForIpv4::EnableAsciiIpv4Impl(Ptr stream, std::string prefix, Ipv4InterfaceContainer c) { - for (Ipv4InterfaceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { EnableAsciiIpv4Internal(stream, prefix, (*i).first, (*i).second, false); } @@ -229,7 +229,7 @@ AsciiTraceHelperForIpv4::EnableAsciiIpv4Impl(Ptr stream, std::string prefix, NodeContainer n) { - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; Ptr ipv4 = node->GetObject(); @@ -297,7 +297,7 @@ AsciiTraceHelperForIpv4::EnableAsciiIpv4Impl(Ptr stream, { NodeContainer n = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; if (node->GetId() != nodeid) @@ -337,7 +337,7 @@ PcapHelperForIpv6::EnablePcapIpv6(std::string prefix, void PcapHelperForIpv6::EnablePcapIpv6(std::string prefix, Ipv6InterfaceContainer c) { - for (Ipv6InterfaceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { EnablePcapIpv6(prefix, (*i).first, (*i).second, false); } @@ -346,7 +346,7 @@ PcapHelperForIpv6::EnablePcapIpv6(std::string prefix, Ipv6InterfaceContainer c) void PcapHelperForIpv6::EnablePcapIpv6(std::string prefix, NodeContainer n) { - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; Ptr ipv6 = node->GetObject(); @@ -374,7 +374,7 @@ PcapHelperForIpv6::EnablePcapIpv6(std::string prefix, { NodeContainer n = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; if (node->GetId() != nodeid) @@ -477,7 +477,7 @@ AsciiTraceHelperForIpv6::EnableAsciiIpv6Impl(Ptr stream, std::string prefix, Ipv6InterfaceContainer c) { - for (Ipv6InterfaceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { EnableAsciiIpv6Internal(stream, prefix, (*i).first, (*i).second, false); } @@ -509,7 +509,7 @@ AsciiTraceHelperForIpv6::EnableAsciiIpv6Impl(Ptr stream, std::string prefix, NodeContainer n) { - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; Ptr ipv6 = node->GetObject(); @@ -576,7 +576,7 @@ AsciiTraceHelperForIpv6::EnableAsciiIpv6Impl(Ptr stream, { NodeContainer n = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; if (node->GetId() != nodeid) diff --git a/src/internet/helper/ipv4-interface-container.cc b/src/internet/helper/ipv4-interface-container.cc index 15d589ed6..0a80d6d5c 100644 --- a/src/internet/helper/ipv4-interface-container.cc +++ b/src/internet/helper/ipv4-interface-container.cc @@ -32,9 +32,7 @@ Ipv4InterfaceContainer::Ipv4InterfaceContainer() void Ipv4InterfaceContainer::Add(const Ipv4InterfaceContainer& other) { - for (InterfaceVector::const_iterator i = other.m_interfaces.begin(); - i != other.m_interfaces.end(); - i++) + for (auto i = other.m_interfaces.begin(); i != other.m_interfaces.end(); i++) { m_interfaces.push_back(*i); } diff --git a/src/internet/helper/ipv4-list-routing-helper.cc b/src/internet/helper/ipv4-list-routing-helper.cc index 9f5707d66..22db916e7 100644 --- a/src/internet/helper/ipv4-list-routing-helper.cc +++ b/src/internet/helper/ipv4-list-routing-helper.cc @@ -30,9 +30,7 @@ Ipv4ListRoutingHelper::Ipv4ListRoutingHelper() Ipv4ListRoutingHelper::~Ipv4ListRoutingHelper() { - for (std::list>::iterator i = m_list.begin(); - i != m_list.end(); - ++i) + for (auto i = m_list.begin(); i != m_list.end(); ++i) { delete i->first; } @@ -40,8 +38,7 @@ Ipv4ListRoutingHelper::~Ipv4ListRoutingHelper() Ipv4ListRoutingHelper::Ipv4ListRoutingHelper(const Ipv4ListRoutingHelper& o) { - std::list>::const_iterator i; - for (i = o.m_list.begin(); i != o.m_list.end(); ++i) + for (auto i = o.m_list.begin(); i != o.m_list.end(); ++i) { m_list.emplace_back(const_cast(i->first->Copy()), i->second); } @@ -63,9 +60,7 @@ Ptr Ipv4ListRoutingHelper::Create(Ptr node) const { Ptr list = CreateObject(); - for (std::list>::const_iterator i = m_list.begin(); - i != m_list.end(); - ++i) + for (auto i = m_list.begin(); i != m_list.end(); ++i) { Ptr prot = i->first->Create(node); list->AddRoutingProtocol(prot, i->second); diff --git a/src/internet/helper/ipv4-static-routing-helper.cc b/src/internet/helper/ipv4-static-routing-helper.cc index 12f770eeb..87c8f8854 100644 --- a/src/internet/helper/ipv4-static-routing-helper.cc +++ b/src/internet/helper/ipv4-static-routing-helper.cc @@ -97,7 +97,7 @@ Ipv4StaticRoutingHelper::AddMulticastRoute(Ptr n, // We need to convert the NetDeviceContainer to an array of interface // numbers std::vector outputInterfaces; - for (NetDeviceContainer::Iterator i = output.Begin(); i != output.End(); ++i) + for (auto i = output.Begin(); i != output.End(); ++i) { Ptr nd = *i; int32_t interface = ipv4->GetInterfaceForDevice(nd); diff --git a/src/internet/helper/ipv6-interface-container.cc b/src/internet/helper/ipv6-interface-container.cc index 9018c3baf..2f9003763 100644 --- a/src/internet/helper/ipv6-interface-container.cc +++ b/src/internet/helper/ipv6-interface-container.cc @@ -81,8 +81,7 @@ Ipv6InterfaceContainer::Add(std::string ipv6Name, uint32_t interface) void Ipv6InterfaceContainer::Add(const Ipv6InterfaceContainer& c) { - for (InterfaceVector::const_iterator it = c.m_interfaces.begin(); it != c.m_interfaces.end(); - it++) + for (auto it = c.m_interfaces.begin(); it != c.m_interfaces.end(); it++) { m_interfaces.push_back(*it); } diff --git a/src/internet/helper/ipv6-list-routing-helper.cc b/src/internet/helper/ipv6-list-routing-helper.cc index 896a00f77..4547ac59f 100644 --- a/src/internet/helper/ipv6-list-routing-helper.cc +++ b/src/internet/helper/ipv6-list-routing-helper.cc @@ -31,9 +31,7 @@ Ipv6ListRoutingHelper::Ipv6ListRoutingHelper() Ipv6ListRoutingHelper::~Ipv6ListRoutingHelper() { - for (std::list>::iterator i = m_list.begin(); - i != m_list.end(); - ++i) + for (auto i = m_list.begin(); i != m_list.end(); ++i) { delete i->first; } @@ -41,8 +39,7 @@ Ipv6ListRoutingHelper::~Ipv6ListRoutingHelper() Ipv6ListRoutingHelper::Ipv6ListRoutingHelper(const Ipv6ListRoutingHelper& o) { - std::list>::const_iterator i; - for (i = o.m_list.begin(); i != o.m_list.end(); ++i) + for (auto i = o.m_list.begin(); i != o.m_list.end(); ++i) { m_list.emplace_back(const_cast(i->first->Copy()), i->second); } @@ -64,9 +61,7 @@ Ptr Ipv6ListRoutingHelper::Create(Ptr node) const { Ptr list = CreateObject(); - for (std::list>::const_iterator i = m_list.begin(); - i != m_list.end(); - ++i) + for (auto i = m_list.begin(); i != m_list.end(); ++i) { Ptr prot = i->first->Create(node); list->AddRoutingProtocol(prot, i->second); diff --git a/src/internet/helper/ipv6-static-routing-helper.cc b/src/internet/helper/ipv6-static-routing-helper.cc index 2979782a6..82f886405 100644 --- a/src/internet/helper/ipv6-static-routing-helper.cc +++ b/src/internet/helper/ipv6-static-routing-helper.cc @@ -97,7 +97,7 @@ Ipv6StaticRoutingHelper::AddMulticastRoute(Ptr n, // We need to convert the NetDeviceContainer to an array of interface // numbers std::vector outputInterfaces; - for (NetDeviceContainer::Iterator i = output.Begin(); i != output.End(); ++i) + for (auto i = output.Begin(); i != output.End(); ++i) { Ptr nd = *i; int32_t interface = ipv6->GetInterfaceForDevice(nd); diff --git a/src/internet/helper/rip-helper.cc b/src/internet/helper/rip-helper.cc index 3ad46a263..1f7b18842 100644 --- a/src/internet/helper/rip-helper.cc +++ b/src/internet/helper/rip-helper.cc @@ -56,20 +56,18 @@ RipHelper::Create(Ptr node) const { Ptr rip = m_factory.Create(); - std::map, std::set>::const_iterator it = m_interfaceExclusions.find(node); + auto it = m_interfaceExclusions.find(node); if (it != m_interfaceExclusions.end()) { rip->SetInterfaceExclusions(it->second); } - std::map, std::map>::const_iterator iter = - m_interfaceMetrics.find(node); + auto iter = m_interfaceMetrics.find(node); if (iter != m_interfaceMetrics.end()) { - std::map::const_iterator subiter; - for (subiter = iter->second.begin(); subiter != iter->second.end(); subiter++) + for (auto subiter = iter->second.begin(); subiter != iter->second.end(); subiter++) { rip->SetInterfaceMetric(subiter->first, subiter->second); } @@ -90,7 +88,7 @@ RipHelper::AssignStreams(NodeContainer c, int64_t stream) { int64_t currentStream = stream; Ptr node; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { node = (*i); Ptr ipv4 = node->GetObject(); @@ -160,7 +158,7 @@ RipHelper::SetDefaultRouter(Ptr node, Ipv4Address nextHop, uint32_t interf void RipHelper::ExcludeInterface(Ptr node, uint32_t interface) { - std::map, std::set>::iterator it = m_interfaceExclusions.find(node); + auto it = m_interfaceExclusions.find(node); if (it == m_interfaceExclusions.end()) { diff --git a/src/internet/helper/ripng-helper.cc b/src/internet/helper/ripng-helper.cc index 275fed0e4..de11d924f 100644 --- a/src/internet/helper/ripng-helper.cc +++ b/src/internet/helper/ripng-helper.cc @@ -58,20 +58,18 @@ RipNgHelper::Create(Ptr node) const { Ptr ripng = m_factory.Create(); - std::map, std::set>::const_iterator it = m_interfaceExclusions.find(node); + auto it = m_interfaceExclusions.find(node); if (it != m_interfaceExclusions.end()) { ripng->SetInterfaceExclusions(it->second); } - std::map, std::map>::const_iterator iter = - m_interfaceMetrics.find(node); + auto iter = m_interfaceMetrics.find(node); if (iter != m_interfaceMetrics.end()) { - std::map::const_iterator subiter; - for (subiter = iter->second.begin(); subiter != iter->second.end(); subiter++) + for (auto subiter = iter->second.begin(); subiter != iter->second.end(); subiter++) { ripng->SetInterfaceMetric(subiter->first, subiter->second); } @@ -92,7 +90,7 @@ RipNgHelper::AssignStreams(NodeContainer c, int64_t stream) { int64_t currentStream = stream; Ptr node; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { node = (*i); Ptr ipv6 = node->GetObject(); @@ -162,7 +160,7 @@ RipNgHelper::SetDefaultRouter(Ptr node, Ipv6Address nextHop, uint32_t inte void RipNgHelper::ExcludeInterface(Ptr node, uint32_t interface) { - std::map, std::set>::iterator it = m_interfaceExclusions.find(node); + auto it = m_interfaceExclusions.find(node); if (it == m_interfaceExclusions.end()) { diff --git a/src/internet/model/arp-cache.cc b/src/internet/model/arp-cache.cc index 020a5db62..1301b34dd 100644 --- a/src/internet/model/arp-cache.cc +++ b/src/internet/model/arp-cache.cc @@ -199,7 +199,7 @@ ArpCache::HandleWaitReplyTimeout() NS_LOG_FUNCTION(this); ArpCache::Entry* entry; bool restartWaitReplyTimer = false; - for (CacheI i = m_arpCache.begin(); i != m_arpCache.end(); i++) + for (auto i = m_arpCache.begin(); i != m_arpCache.end(); i++) { entry = (*i).second; if (entry != nullptr && entry->IsWaitReply()) @@ -245,7 +245,7 @@ void ArpCache::Flush() { NS_LOG_FUNCTION(this); - for (CacheI i = m_arpCache.begin(); i != m_arpCache.end(); i++) + for (auto i = m_arpCache.begin(); i != m_arpCache.end(); i++) { delete (*i).second; } @@ -264,7 +264,7 @@ ArpCache::PrintArpCache(Ptr stream) NS_LOG_FUNCTION(this << stream); std::ostream* os = stream->GetStream(); - for (CacheI i = m_arpCache.begin(); i != m_arpCache.end(); i++) + for (auto i = m_arpCache.begin(); i != m_arpCache.end(); i++) { *os << i->first << " dev "; std::string found = Names::FindName(m_device); @@ -306,7 +306,7 @@ void ArpCache::RemoveAutoGeneratedEntries() { NS_LOG_FUNCTION(this); - for (CacheI i = m_arpCache.begin(); i != m_arpCache.end();) + for (auto i = m_arpCache.begin(); i != m_arpCache.end();) { if (i->second->IsAutoGenerated()) { @@ -325,7 +325,7 @@ ArpCache::LookupInverse(Address to) NS_LOG_FUNCTION(this << to); std::list entryList; - for (CacheI i = m_arpCache.begin(); i != m_arpCache.end(); i++) + for (auto i = m_arpCache.begin(); i != m_arpCache.end(); i++) { ArpCache::Entry* entry = (*i).second; if (entry->GetMacAddress() == to) @@ -340,7 +340,7 @@ ArpCache::Entry* ArpCache::Lookup(Ipv4Address to) { NS_LOG_FUNCTION(this << to); - CacheI it = m_arpCache.find(to); + auto it = m_arpCache.find(to); if (it != m_arpCache.end()) { return it->second; @@ -354,7 +354,7 @@ ArpCache::Add(Ipv4Address to) NS_LOG_FUNCTION(this << to); NS_ASSERT(m_arpCache.find(to) == m_arpCache.end()); - ArpCache::Entry* entry = new ArpCache::Entry(this); + auto entry = new ArpCache::Entry(this); m_arpCache[to] = entry; entry->SetIpv4Address(to); return entry; @@ -365,7 +365,7 @@ ArpCache::Remove(ArpCache::Entry* entry) { NS_LOG_FUNCTION(this << entry); - for (CacheI i = m_arpCache.begin(); i != m_arpCache.end(); i++) + for (auto i = m_arpCache.begin(); i != m_arpCache.end(); i++) { if ((*i).second == entry) { diff --git a/src/internet/model/arp-l3-protocol.cc b/src/internet/model/arp-l3-protocol.cc index 3031246fc..40de28e9e 100644 --- a/src/internet/model/arp-l3-protocol.cc +++ b/src/internet/model/arp-l3-protocol.cc @@ -131,7 +131,7 @@ void ArpL3Protocol::DoDispose() { NS_LOG_FUNCTION(this); - for (CacheList::iterator i = m_cacheList.begin(); i != m_cacheList.end(); ++i) + for (auto i = m_cacheList.begin(); i != m_cacheList.end(); ++i) { Ptr cache = *i; cache->Dispose(); @@ -160,7 +160,7 @@ Ptr ArpL3Protocol::FindCache(Ptr device) { NS_LOG_FUNCTION(this << device); - for (CacheList::const_iterator i = m_cacheList.begin(); i != m_cacheList.end(); i++) + for (auto i = m_cacheList.begin(); i != m_cacheList.end(); i++) { if ((*i)->GetDevice() == device) { diff --git a/src/internet/model/candidate-queue.cc b/src/internet/model/candidate-queue.cc index 2998f5a4c..569752fa4 100644 --- a/src/internet/model/candidate-queue.cc +++ b/src/internet/model/candidate-queue.cc @@ -63,7 +63,7 @@ operator<<(std::ostream& os, const CandidateQueue& q) const CandidateQueue::CandidateList_t& list = q.m_candidates; os << "*** CandidateQueue Begin () ***" << std::endl; - for (CIter_t iter = list.begin(); iter != list.end(); iter++) + for (auto iter = list.begin(); iter != list.end(); iter++) { os << "<" << (*iter)->GetVertexId() << ", " << (*iter)->GetDistanceFromRoot() << ", " << (*iter)->GetVertexType() << ">" << std::endl; @@ -101,10 +101,10 @@ CandidateQueue::Push(SPFVertex* vNew) { NS_LOG_FUNCTION(this << vNew); - CandidateList_t::iterator i = std::upper_bound(m_candidates.begin(), - m_candidates.end(), - vNew, - &CandidateQueue::CompareSPFVertex); + auto i = std::upper_bound(m_candidates.begin(), + m_candidates.end(), + vNew, + &CandidateQueue::CompareSPFVertex); m_candidates.insert(i, vNew); } @@ -152,7 +152,7 @@ SPFVertex* CandidateQueue::Find(const Ipv4Address addr) const { NS_LOG_FUNCTION(this); - CandidateList_t::const_iterator i = m_candidates.begin(); + auto i = m_candidates.begin(); for (; i != m_candidates.end(); i++) { diff --git a/src/internet/model/global-route-manager-impl.cc b/src/internet/model/global-route-manager-impl.cc index ce7f41fac..3d85c5190 100644 --- a/src/internet/model/global-route-manager-impl.cc +++ b/src/internet/model/global-route-manager-impl.cc @@ -64,7 +64,7 @@ operator<<(std::ostream& os, const SPFVertex::ListOfSPFVertex_t& vs) { typedef SPFVertex::ListOfSPFVertex_t::const_iterator CIter_t; os << "{"; - for (CIter_t iter = vs.begin(); iter != vs.end();) + for (auto iter = vs.begin(); iter != vs.end();) { os << (*iter)->m_vertexId; if (++iter != vs.end()) @@ -133,7 +133,7 @@ SPFVertex::~SPFVertex() // find this node from all its parents and remove the entry of this node // from all its parents - for (ListOfSPFVertex_t::iterator piter = m_parents.begin(); piter != m_parents.end(); piter++) + for (auto piter = m_parents.begin(); piter != m_parents.end(); piter++) { // remove the current vertex from its parent's children list. Check // if the size of the list is reduced, or the child<->parent relation @@ -255,7 +255,7 @@ SPFVertex::GetParent(uint32_t i) const NS_LOG_LOGIC("Index to SPFVertex's parent is out-of-range."); return nullptr; } - ListOfSPFVertex_t::const_iterator iter = m_parents.begin(); + auto iter = m_parents.begin(); while (i-- > 0) { iter++; @@ -306,7 +306,7 @@ SPFVertex::GetRootExitDirection(uint32_t i) const NS_ASSERT_MSG(i < m_ecmpRootExits.size(), "Index out-of-range when accessing SPFVertex::m_ecmpRootExits!"); - CIter_t iter = m_ecmpRootExits.begin(); + auto iter = m_ecmpRootExits.begin(); while (i-- > 0) { iter++; @@ -376,7 +376,7 @@ SPFVertex::GetChild(uint32_t n) const NS_LOG_FUNCTION(this << n); uint32_t j = 0; - for (ListOfSPFVertex_t::const_iterator i = m_children.begin(); i != m_children.end(); i++, j++) + for (auto i = m_children.begin(); i != m_children.end(); i++, j++) { if (j == n) { @@ -436,8 +436,7 @@ GlobalRouteManagerLSDB::GlobalRouteManagerLSDB() GlobalRouteManagerLSDB::~GlobalRouteManagerLSDB() { NS_LOG_FUNCTION(this); - LSDBMap_t::iterator i; - for (i = m_database.begin(); i != m_database.end(); i++) + for (auto i = m_database.begin(); i != m_database.end(); i++) { NS_LOG_LOGIC("free LSA"); GlobalRoutingLSA* temp = i->second; @@ -457,8 +456,7 @@ void GlobalRouteManagerLSDB::Initialize() { NS_LOG_FUNCTION(this); - LSDBMap_t::iterator i; - for (i = m_database.begin(); i != m_database.end(); i++) + for (auto i = m_database.begin(); i != m_database.end(); i++) { GlobalRoutingLSA* temp = i->second; temp->SetStatus(GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED); @@ -500,8 +498,7 @@ GlobalRouteManagerLSDB::GetLSA(Ipv4Address addr) const // // Look up an LSA by its address. // - LSDBMap_t::const_iterator i; - for (i = m_database.begin(); i != m_database.end(); i++) + for (auto i = m_database.begin(); i != m_database.end(); i++) { if (i->first == addr) { @@ -518,8 +515,7 @@ GlobalRouteManagerLSDB::GetLSAByLinkData(Ipv4Address addr) const // // Look up an LSA by its address. // - LSDBMap_t::const_iterator i; - for (i = m_database.begin(); i != m_database.end(); i++) + for (auto i = m_database.begin(); i != m_database.end(); i++) { GlobalRoutingLSA* temp = i->second; // Iterate among temp's Link Records @@ -573,8 +569,7 @@ void GlobalRouteManagerImpl::DeleteGlobalRoutes() { NS_LOG_FUNCTION(this); - NodeList::Iterator listEnd = NodeList::End(); - for (NodeList::Iterator i = NodeList::Begin(); i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; Ptr router = node->GetObject(); @@ -621,8 +616,7 @@ GlobalRouteManagerImpl::BuildGlobalRoutingDatabase() // Walk the list of nodes looking for the GlobalRouter Interface. Nodes with // global router interfaces are, not too surprisingly, our routers. // - NodeList::Iterator listEnd = NodeList::End(); - for (NodeList::Iterator i = NodeList::Begin(); i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; @@ -648,7 +642,7 @@ GlobalRouteManagerImpl::BuildGlobalRoutingDatabase() for (uint32_t j = 0; j < numLSAs; ++j) { - GlobalRoutingLSA* lsa = new GlobalRoutingLSA(); + auto lsa = new GlobalRoutingLSA(); // // This is the call to actually fetch a Link State Advertisement from the // router. @@ -704,8 +698,7 @@ GlobalRouteManagerImpl::InitializeRoutes() // Walk the list of nodes in the system. // NS_LOG_INFO("About to start SPF calculation"); - NodeList::Iterator listEnd = NodeList::End(); - for (NodeList::Iterator i = NodeList::Begin(); i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; // @@ -1561,9 +1554,7 @@ GlobalRouteManagerImpl::SPFAddASExternal(GlobalRoutingLSA* extlsa, SPFVertex* v) // ID corresponding to the root vertex. This is the one we're going to write // the routing information to. // - NodeList::Iterator i = NodeList::Begin(); - NodeList::Iterator listEnd = NodeList::End(); - for (; i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; // @@ -1727,9 +1718,7 @@ GlobalRouteManagerImpl::SPFIntraAddStub(GlobalRoutingLinkRecord* l, SPFVertex* v // ID corresponding to the root vertex. This is the one we're going to write // the routing information to. // - NodeList::Iterator i = NodeList::Begin(); - NodeList::Iterator listEnd = NodeList::End(); - for (; i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; // @@ -1849,9 +1838,7 @@ GlobalRouteManagerImpl::FindOutgoingInterfaceId(Ipv4Address a, Ipv4Mask amask) // the node at the root of the SPF tree. This is the node for which we are // building the routing table. // - NodeList::Iterator i = NodeList::Begin(); - NodeList::Iterator listEnd = NodeList::End(); - for (; i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; @@ -1938,9 +1925,7 @@ GlobalRouteManagerImpl::SPFIntraAddRouter(SPFVertex* v) // ID corresponding to the root vertex. This is the one we're going to write // the routing information to. // - NodeList::Iterator i = NodeList::Begin(); - NodeList::Iterator listEnd = NodeList::End(); - for (; i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; // @@ -2082,9 +2067,7 @@ GlobalRouteManagerImpl::SPFIntraAddTransit(SPFVertex* v) // ID corresponding to the root vertex. This is the one we're going to write // the routing information to. // - NodeList::Iterator i = NodeList::Begin(); - NodeList::Iterator listEnd = NodeList::End(); - for (; i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; // diff --git a/src/internet/model/global-router-interface.cc b/src/internet/model/global-router-interface.cc index 1836cd777..2e83ebe12 100644 --- a/src/internet/model/global-router-interface.cc +++ b/src/internet/model/global-router-interface.cc @@ -193,12 +193,10 @@ void GlobalRoutingLSA::CopyLinkRecords(const GlobalRoutingLSA& lsa) { NS_LOG_FUNCTION(this << &lsa); - for (ListOfLinkRecords_t::const_iterator i = lsa.m_linkRecords.begin(); - i != lsa.m_linkRecords.end(); - i++) + for (auto i = lsa.m_linkRecords.begin(); i != lsa.m_linkRecords.end(); i++) { GlobalRoutingLinkRecord* pSrc = *i; - GlobalRoutingLinkRecord* pDst = new GlobalRoutingLinkRecord; + auto pDst = new GlobalRoutingLinkRecord; pDst->SetLinkType(pSrc->GetLinkType()); pDst->SetLinkId(pSrc->GetLinkId()); @@ -222,7 +220,7 @@ void GlobalRoutingLSA::ClearLinkRecords() { NS_LOG_FUNCTION(this); - for (ListOfLinkRecords_t::iterator i = m_linkRecords.begin(); i != m_linkRecords.end(); i++) + for (auto i = m_linkRecords.begin(); i != m_linkRecords.end(); i++) { NS_LOG_LOGIC("Free link record"); @@ -256,8 +254,7 @@ GlobalRoutingLSA::GetLinkRecord(uint32_t n) const { NS_LOG_FUNCTION(this << n); uint32_t j = 0; - for (ListOfLinkRecords_t::const_iterator i = m_linkRecords.begin(); i != m_linkRecords.end(); - i++, j++) + for (auto i = m_linkRecords.begin(); i != m_linkRecords.end(); i++, j++) { if (j == n) { @@ -358,9 +355,7 @@ GlobalRoutingLSA::GetAttachedRouter(uint32_t n) const { NS_LOG_FUNCTION(this << n); uint32_t j = 0; - for (ListOfAttachedRouters_t::const_iterator i = m_attachedRouters.begin(); - i != m_attachedRouters.end(); - i++, j++) + for (auto i = m_attachedRouters.begin(); i != m_attachedRouters.end(); i++, j++) { if (j == n) { @@ -422,9 +417,7 @@ GlobalRoutingLSA::Print(std::ostream& os) const if (m_lsType == GlobalRoutingLSA::RouterLSA) { - for (ListOfLinkRecords_t::const_iterator i = m_linkRecords.begin(); - i != m_linkRecords.end(); - i++) + for (auto i = m_linkRecords.begin(); i != m_linkRecords.end(); i++) { GlobalRoutingLinkRecord* p = *i; @@ -469,9 +462,7 @@ GlobalRoutingLSA::Print(std::ostream& os) const { os << "---------- NetworkLSA Link Record ----------" << std::endl; os << "m_networkLSANetworkMask = " << m_networkLSANetworkMask << std::endl; - for (ListOfAttachedRouters_t::const_iterator i = m_attachedRouters.begin(); - i != m_attachedRouters.end(); - i++) + for (auto i = m_attachedRouters.begin(); i != m_attachedRouters.end(); i++) { Ipv4Address p = *i; os << "attachedRouter = " << p << std::endl; @@ -545,7 +536,7 @@ GlobalRouter::DoDispose() { NS_LOG_FUNCTION(this); m_routingProtocol = nullptr; - for (InjectedRoutesI k = m_injectedRoutes.begin(); k != m_injectedRoutes.end(); + for (auto k = m_injectedRoutes.begin(); k != m_injectedRoutes.end(); k = m_injectedRoutes.erase(k)) { delete (*k); @@ -557,7 +548,7 @@ void GlobalRouter::ClearLSAs() { NS_LOG_FUNCTION(this); - for (ListOfLSAs_t::iterator i = m_LSAs.begin(); i != m_LSAs.end(); i++) + for (auto i = m_LSAs.begin(); i != m_LSAs.end(); i++) { NS_LOG_LOGIC("Free LSA"); @@ -614,7 +605,7 @@ GlobalRouter::DiscoverLSAs() // // Every router node originates a Router-LSA // - GlobalRoutingLSA* pLSA = new GlobalRoutingLSA; + auto pLSA = new GlobalRoutingLSA; pLSA->SetLSType(GlobalRoutingLSA::RouterLSA); pLSA->SetLinkStateId(m_routerId); pLSA->SetAdvertisingRouter(m_routerId); @@ -717,9 +708,9 @@ GlobalRouter::DiscoverLSAs() // Build injected route LSAs as external routes // RFC 2328, section 12.4.4 // - for (InjectedRoutesCI i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) + for (auto i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) { - GlobalRoutingLSA* pLSA = new GlobalRoutingLSA; + auto pLSA = new GlobalRoutingLSA; pLSA->SetLSType(GlobalRoutingLSA::ASExternalLSAs); pLSA->SetLinkStateId((*i)->GetDestNetwork()); pLSA->SetAdvertisingRouter(m_routerId); @@ -752,7 +743,7 @@ GlobalRouter::ProcessSingleBroadcastLink(Ptr nd, { NS_LOG_FUNCTION(this << nd << pLSA << &c); - GlobalRoutingLinkRecord* plr = new GlobalRoutingLinkRecord; + auto plr = new GlobalRoutingLinkRecord; NS_ABORT_MSG_IF(plr == nullptr, "GlobalRouter::ProcessSingleBroadcastLink(): Can't alloc link record"); @@ -1193,7 +1184,7 @@ GlobalRouter::BuildNetworkLSAs(NetDeviceContainer c) Ipv4Address addrLocal = ipv4Local->GetAddress(interfaceLocal, 0).GetLocal(); Ipv4Mask maskLocal = ipv4Local->GetAddress(interfaceLocal, 0).GetMask(); - GlobalRoutingLSA* pLSA = new GlobalRoutingLSA; + auto pLSA = new GlobalRoutingLSA; NS_ABORT_MSG_IF(pLSA == nullptr, "GlobalRouter::BuildNetworkLSAs(): Can't alloc link record"); @@ -1604,7 +1595,7 @@ GlobalRouter::GetLSA(uint32_t n, GlobalRoutingLSA& lsa) const // walk the list of link state advertisements created there and return the // one the client is interested in. // - ListOfLSAs_t::const_iterator i = m_LSAs.begin(); + auto i = m_LSAs.begin(); uint32_t j = 0; for (; i != m_LSAs.end(); i++, j++) @@ -1624,7 +1615,7 @@ void GlobalRouter::InjectRoute(Ipv4Address network, Ipv4Mask networkMask) { NS_LOG_FUNCTION(this << network << networkMask); - Ipv4RoutingTableEntry* route = new Ipv4RoutingTableEntry(); + auto route = new Ipv4RoutingTableEntry(); // // Interface number does not matter here, using 1. // @@ -1639,7 +1630,7 @@ GlobalRouter::GetInjectedRoute(uint32_t index) if (index < m_injectedRoutes.size()) { uint32_t tmp = 0; - for (InjectedRoutesCI i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) + for (auto i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) { if (tmp == index) { @@ -1666,7 +1657,7 @@ GlobalRouter::RemoveInjectedRoute(uint32_t index) NS_LOG_FUNCTION(this << index); NS_ASSERT(index < m_injectedRoutes.size()); uint32_t tmp = 0; - for (InjectedRoutesI i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) + for (auto i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) { if (tmp == index) { @@ -1683,7 +1674,7 @@ bool GlobalRouter::WithdrawRoute(Ipv4Address network, Ipv4Mask networkMask) { NS_LOG_FUNCTION(this << network << networkMask); - for (InjectedRoutesI i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) + for (auto i = m_injectedRoutes.begin(); i != m_injectedRoutes.end(); i++) { if ((*i)->GetDestNetwork() == network && (*i)->GetDestNetworkMask() == networkMask) { @@ -1791,8 +1782,7 @@ GlobalRouter::ClearBridgesVisited() const bool GlobalRouter::BridgeHasAlreadyBeenVisited(Ptr bridgeNetDevice) const { - std::vector>::iterator iter; - for (iter = m_bridgesVisited.begin(); iter != m_bridgesVisited.end(); ++iter) + for (auto iter = m_bridgesVisited.begin(); iter != m_bridgesVisited.end(); ++iter) { if (bridgeNetDevice == *iter) { diff --git a/src/internet/model/icmpv6-header.cc b/src/internet/model/icmpv6-header.cc index 9f01ac8f2..3f12240fd 100644 --- a/src/internet/model/icmpv6-header.cc +++ b/src/internet/model/icmpv6-header.cc @@ -1192,7 +1192,7 @@ Icmpv6DestinationUnreachable::Serialize(Buffer::Iterator start) const iter.WriteU32(0); uint32_t size = m_packet->GetSize(); - uint8_t* buf = new uint8_t[size]; + auto buf = new uint8_t[size]; m_packet->CopyData(buf, size); iter.Write(buf, size); delete[] buf; @@ -1308,7 +1308,7 @@ Icmpv6TooBig::Serialize(Buffer::Iterator start) const iter.WriteHtonU32(GetMtu()); uint32_t size = m_packet->GetSize(); - uint8_t* buf = new uint8_t[size]; + auto buf = new uint8_t[size]; m_packet->CopyData(buf, size); iter.Write(buf, size); delete[] buf; @@ -1410,7 +1410,7 @@ Icmpv6TimeExceeded::Serialize(Buffer::Iterator start) const iter.WriteU32(0); uint32_t size = m_packet->GetSize(); - uint8_t* buf = new uint8_t[size]; + auto buf = new uint8_t[size]; m_packet->CopyData(buf, size); iter.Write(buf, size); delete[] buf; @@ -1527,7 +1527,7 @@ Icmpv6ParameterError::Serialize(Buffer::Iterator start) const iter.WriteHtonU32(GetPtr()); uint32_t size = m_packet->GetSize(); - uint8_t* buf = new uint8_t[size]; + auto buf = new uint8_t[size]; m_packet->CopyData(buf, size); iter.Write(buf, size); delete[] buf; @@ -2128,7 +2128,7 @@ Icmpv6OptionRedirected::Serialize(Buffer::Iterator start) const i.WriteU32(0); uint32_t size = m_packet->GetSize(); - uint8_t* buf = new uint8_t[size]; + auto buf = new uint8_t[size]; m_packet->CopyData(buf, size); i.Write(buf, size); delete[] buf; @@ -2147,7 +2147,7 @@ Icmpv6OptionRedirected::Deserialize(Buffer::Iterator start) i.ReadU32(); uint32_t len2 = (GetLength() - 1) * 8; - uint8_t* buff = new uint8_t[len2]; + auto buff = new uint8_t[len2]; i.Read(buff, len2); m_packet = Create(buff, len2); delete[] buff; diff --git a/src/internet/model/icmpv6-l4-protocol.cc b/src/internet/model/icmpv6-l4-protocol.cc index d6d202a77..3bd99ecd8 100644 --- a/src/internet/model/icmpv6-l4-protocol.cc +++ b/src/internet/model/icmpv6-l4-protocol.cc @@ -168,7 +168,7 @@ void Icmpv6L4Protocol::DoDispose() { NS_LOG_FUNCTION(this); - for (CacheList::const_iterator it = m_cacheList.begin(); it != m_cacheList.end(); it++) + for (auto it = m_cacheList.begin(); it != m_cacheList.end(); it++) { Ptr cache = *it; cache->Dispose(); @@ -397,7 +397,7 @@ Icmpv6L4Protocol::HandleEchoRequest(Ptr packet, { NS_LOG_FUNCTION(this << packet << src << dst << interface); Icmpv6Echo request; - uint8_t* buf = new uint8_t[packet->GetSize()]; + auto buf = new uint8_t[packet->GetSize()]; packet->RemoveHeader(request); /* XXX IPv6 extension: obtain a fresh copy of data otherwise it crash... */ @@ -522,9 +522,7 @@ Icmpv6L4Protocol::ReceiveLLA(Icmpv6OptionLinkLayerAddress lla, waiting = entry->MarkReachable(lla.GetAddress()); entry->StartReachableTimer(); // send out waiting packet - for (std::list::const_iterator it = waiting.begin(); - it != waiting.end(); - it++) + for (auto it = waiting.begin(); it != waiting.end(); it++) { cache->GetInterface()->Send(it->first, it->second, src); } @@ -558,10 +556,7 @@ Icmpv6L4Protocol::ReceiveLLA(Icmpv6OptionLinkLayerAddress lla, { entry->StopNudTimer(); waiting = entry->MarkReachable(lla.GetAddress()); - for (std::list::const_iterator it = - waiting.begin(); - it != waiting.end(); - it++) + for (auto it = waiting.begin(); it != waiting.end(); it++) { cache->GetInterface()->Send(it->first, it->second, src); } @@ -911,9 +906,7 @@ Icmpv6L4Protocol::HandleNA(Ptr packet, waiting = entry->MarkReachable(lla.GetAddress()); entry->StartReachableTimer(); /* send out waiting packet */ - for (std::list::const_iterator it = waiting.begin(); - it != waiting.end(); - it++) + for (auto it = waiting.begin(); it != waiting.end(); it++) { cache->GetInterface()->Send(it->first, it->second, src); } @@ -978,10 +971,7 @@ Icmpv6L4Protocol::HandleNA(Ptr packet, if (naHeader.GetFlagS()) { waiting = entry->MarkReachable(lla.GetAddress()); - for (std::list::const_iterator it = - waiting.begin(); - it != waiting.end(); - it++) + for (auto it = waiting.begin(); it != waiting.end(); it++) { cache->GetInterface()->Send(it->first, it->second, src); } @@ -1676,7 +1666,7 @@ Icmpv6L4Protocol::FindCache(Ptr device) { NS_LOG_FUNCTION(this << device); - for (CacheList::const_iterator i = m_cacheList.begin(); i != m_cacheList.end(); i++) + for (auto i = m_cacheList.begin(); i != m_cacheList.end(); i++) { if ((*i)->GetDevice() == device) { diff --git a/src/internet/model/ipv4-address-generator.cc b/src/internet/model/ipv4-address-generator.cc index fb069c3c8..9181f8c02 100644 --- a/src/internet/model/ipv4-address-generator.cc +++ b/src/internet/model/ipv4-address-generator.cc @@ -342,8 +342,8 @@ Ipv4AddressGeneratorImpl::NextAddress(const Ipv4Mask mask) NS_ABORT_MSG_UNLESS(m_netTable[index].addr <= m_netTable[index].addrMax, "Ipv4AddressGeneratorImpl::NextAddress(): Address overflow"); - Ipv4Address addr = Ipv4Address((m_netTable[index].network << m_netTable[index].shift) | - m_netTable[index].addr); + Ipv4Address addr((m_netTable[index].network << m_netTable[index].shift) | + m_netTable[index].addr); ++m_netTable[index].addr; // @@ -404,7 +404,7 @@ Ipv4AddressGeneratorImpl::AddAllocated(const Ipv4Address address) // if (addr == (*i).addrHigh + 1) { - std::list::iterator j = i; + auto j = i; ++j; if (j != m_entries.end()) @@ -459,9 +459,7 @@ Ipv4AddressGeneratorImpl::IsAddressAllocated(const Ipv4Address address) addr, "Ipv4AddressGeneratorImpl::IsAddressAllocated(): Don't check for the broadcast address..."); - std::list::iterator i; - - for (i = m_entries.begin(); i != m_entries.end(); ++i) + for (auto i = m_entries.begin(); i != m_entries.end(); ++i) { NS_LOG_LOGIC("examine entry: " << Ipv4Address((*i).addrLow) << " to " << Ipv4Address((*i).addrHigh)); @@ -485,14 +483,12 @@ Ipv4AddressGeneratorImpl::IsNetworkAllocated(const Ipv4Address address, const Ip "Ipv4AddressGeneratorImpl::IsNetworkAllocated(): network address and mask don't match " << address << " " << mask); - std::list::iterator i; - - for (i = m_entries.begin(); i != m_entries.end(); ++i) + for (auto i = m_entries.begin(); i != m_entries.end(); ++i) { NS_LOG_LOGIC("examine entry: " << Ipv4Address((*i).addrLow) << " to " << Ipv4Address((*i).addrHigh)); - Ipv4Address low = Ipv4Address((*i).addrLow); - Ipv4Address high = Ipv4Address((*i).addrHigh); + Ipv4Address low((*i).addrLow); + Ipv4Address high((*i).addrHigh); if (address == low.CombineMask(mask) || address == high.CombineMask(mask)) { diff --git a/src/internet/model/ipv4-end-point-demux.cc b/src/internet/model/ipv4-end-point-demux.cc index 058e1569b..c23018a07 100644 --- a/src/internet/model/ipv4-end-point-demux.cc +++ b/src/internet/model/ipv4-end-point-demux.cc @@ -40,7 +40,7 @@ Ipv4EndPointDemux::Ipv4EndPointDemux() Ipv4EndPointDemux::~Ipv4EndPointDemux() { NS_LOG_FUNCTION(this); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { Ipv4EndPoint* endPoint = *i; delete endPoint; @@ -52,7 +52,7 @@ bool Ipv4EndPointDemux::LookupPortLocal(uint16_t port) { NS_LOG_FUNCTION(this << port); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if ((*i)->GetLocalPort() == port) { @@ -66,7 +66,7 @@ bool Ipv4EndPointDemux::LookupLocal(Ptr boundNetDevice, Ipv4Address addr, uint16_t port) { NS_LOG_FUNCTION(this << addr << port); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if ((*i)->GetLocalPort() == port && (*i)->GetLocalAddress() == addr && (*i)->GetBoundNetDevice() == boundNetDevice) @@ -87,7 +87,7 @@ Ipv4EndPointDemux::Allocate() NS_LOG_WARN("Ephemeral port allocation failed."); return nullptr; } - Ipv4EndPoint* endPoint = new Ipv4EndPoint(Ipv4Address::GetAny(), port); + auto endPoint = new Ipv4EndPoint(Ipv4Address::GetAny(), port); m_endPoints.push_back(endPoint); NS_LOG_DEBUG("Now have >>" << m_endPoints.size() << "<< endpoints."); return endPoint; @@ -103,7 +103,7 @@ Ipv4EndPointDemux::Allocate(Ipv4Address address) NS_LOG_WARN("Ephemeral port allocation failed."); return nullptr; } - Ipv4EndPoint* endPoint = new Ipv4EndPoint(address, port); + auto endPoint = new Ipv4EndPoint(address, port); m_endPoints.push_back(endPoint); NS_LOG_DEBUG("Now have >>" << m_endPoints.size() << "<< endpoints."); return endPoint; @@ -126,7 +126,7 @@ Ipv4EndPointDemux::Allocate(Ptr boundNetDevice, Ipv4Address address, NS_LOG_WARN("Duplicated endpoint."); return nullptr; } - Ipv4EndPoint* endPoint = new Ipv4EndPoint(address, port); + auto endPoint = new Ipv4EndPoint(address, port); m_endPoints.push_back(endPoint); NS_LOG_DEBUG("Now have >>" << m_endPoints.size() << "<< endpoints."); return endPoint; @@ -140,7 +140,7 @@ Ipv4EndPointDemux::Allocate(Ptr boundNetDevice, uint16_t peerPort) { NS_LOG_FUNCTION(this << localAddress << localPort << peerAddress << peerPort << boundNetDevice); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if ((*i)->GetLocalPort() == localPort && (*i)->GetLocalAddress() == localAddress && (*i)->GetPeerPort() == peerPort && (*i)->GetPeerAddress() == peerAddress && @@ -150,7 +150,7 @@ Ipv4EndPointDemux::Allocate(Ptr boundNetDevice, return nullptr; } } - Ipv4EndPoint* endPoint = new Ipv4EndPoint(localAddress, localPort); + auto endPoint = new Ipv4EndPoint(localAddress, localPort); endPoint->SetPeer(peerAddress, peerPort); m_endPoints.push_back(endPoint); @@ -163,7 +163,7 @@ void Ipv4EndPointDemux::DeAllocate(Ipv4EndPoint* endPoint) { NS_LOG_FUNCTION(this << endPoint); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if (*i == endPoint) { @@ -183,7 +183,7 @@ Ipv4EndPointDemux::GetAllEndPoints() NS_LOG_FUNCTION(this); EndPoints ret; - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { Ipv4EndPoint* endP = *i; ret.push_back(endP); @@ -211,7 +211,7 @@ Ipv4EndPointDemux::Lookup(Ipv4Address daddr, EndPoints retval4; // Exact match on all 4 NS_LOG_DEBUG("Looking up endpoint for destination address " << daddr << ":" << dport); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { Ipv4EndPoint* endP = *i; @@ -376,7 +376,7 @@ Ipv4EndPointDemux::SimpleLookup(Ipv4Address daddr, // function. uint32_t genericity = 3; Ipv4EndPoint* generic = nullptr; - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if ((*i)->GetLocalPort() != dport) { diff --git a/src/internet/model/ipv4-global-routing.cc b/src/internet/model/ipv4-global-routing.cc index 890f6b16f..9fe879047 100644 --- a/src/internet/model/ipv4-global-routing.cc +++ b/src/internet/model/ipv4-global-routing.cc @@ -80,7 +80,7 @@ void Ipv4GlobalRouting::AddHostRouteTo(Ipv4Address dest, Ipv4Address nextHop, uint32_t interface) { NS_LOG_FUNCTION(this << dest << nextHop << interface); - Ipv4RoutingTableEntry* route = new Ipv4RoutingTableEntry(); + auto route = new Ipv4RoutingTableEntry(); *route = Ipv4RoutingTableEntry::CreateHostRouteTo(dest, nextHop, interface); m_hostRoutes.push_back(route); } @@ -89,7 +89,7 @@ void Ipv4GlobalRouting::AddHostRouteTo(Ipv4Address dest, uint32_t interface) { NS_LOG_FUNCTION(this << dest << interface); - Ipv4RoutingTableEntry* route = new Ipv4RoutingTableEntry(); + auto route = new Ipv4RoutingTableEntry(); *route = Ipv4RoutingTableEntry::CreateHostRouteTo(dest, interface); m_hostRoutes.push_back(route); } @@ -101,7 +101,7 @@ Ipv4GlobalRouting::AddNetworkRouteTo(Ipv4Address network, uint32_t interface) { NS_LOG_FUNCTION(this << network << networkMask << nextHop << interface); - Ipv4RoutingTableEntry* route = new Ipv4RoutingTableEntry(); + auto route = new Ipv4RoutingTableEntry(); *route = Ipv4RoutingTableEntry::CreateNetworkRouteTo(network, networkMask, nextHop, interface); m_networkRoutes.push_back(route); } @@ -110,7 +110,7 @@ void Ipv4GlobalRouting::AddNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, uint32_t interface) { NS_LOG_FUNCTION(this << network << networkMask << interface); - Ipv4RoutingTableEntry* route = new Ipv4RoutingTableEntry(); + auto route = new Ipv4RoutingTableEntry(); *route = Ipv4RoutingTableEntry::CreateNetworkRouteTo(network, networkMask, interface); m_networkRoutes.push_back(route); } @@ -122,7 +122,7 @@ Ipv4GlobalRouting::AddASExternalRouteTo(Ipv4Address network, uint32_t interface) { NS_LOG_FUNCTION(this << network << networkMask << nextHop << interface); - Ipv4RoutingTableEntry* route = new Ipv4RoutingTableEntry(); + auto route = new Ipv4RoutingTableEntry(); *route = Ipv4RoutingTableEntry::CreateNetworkRouteTo(network, networkMask, nextHop, interface); m_ASexternalRoutes.push_back(route); } @@ -138,7 +138,7 @@ Ipv4GlobalRouting::LookupGlobal(Ipv4Address dest, Ptr oif) RouteVec_t allRoutes; NS_LOG_LOGIC("Number of m_hostRoutes = " << m_hostRoutes.size()); - for (HostRoutesCI i = m_hostRoutes.begin(); i != m_hostRoutes.end(); i++) + for (auto i = m_hostRoutes.begin(); i != m_hostRoutes.end(); i++) { NS_ASSERT((*i)->IsHost()); if ((*i)->GetDest() == dest) @@ -158,7 +158,7 @@ Ipv4GlobalRouting::LookupGlobal(Ipv4Address dest, Ptr oif) if (allRoutes.empty()) // if no host route is found { NS_LOG_LOGIC("Number of m_networkRoutes" << m_networkRoutes.size()); - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { Ipv4Mask mask = (*j)->GetDestNetworkMask(); Ipv4Address entry = (*j)->GetDestNetwork(); @@ -179,7 +179,7 @@ Ipv4GlobalRouting::LookupGlobal(Ipv4Address dest, Ptr oif) } if (allRoutes.empty()) // consider external if no host/network found { - for (ASExternalRoutesI k = m_ASexternalRoutes.begin(); k != m_ASexternalRoutes.end(); k++) + for (auto k = m_ASexternalRoutes.begin(); k != m_ASexternalRoutes.end(); k++) { Ipv4Mask mask = (*k)->GetDestNetworkMask(); Ipv4Address entry = (*k)->GetDestNetwork(); @@ -248,7 +248,7 @@ Ipv4GlobalRouting::GetRoute(uint32_t index) const if (index < m_hostRoutes.size()) { uint32_t tmp = 0; - for (HostRoutesCI i = m_hostRoutes.begin(); i != m_hostRoutes.end(); i++) + for (auto i = m_hostRoutes.begin(); i != m_hostRoutes.end(); i++) { if (tmp == index) { @@ -261,7 +261,7 @@ Ipv4GlobalRouting::GetRoute(uint32_t index) const uint32_t tmp = 0; if (index < m_networkRoutes.size()) { - for (NetworkRoutesCI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { if (tmp == index) { @@ -272,7 +272,7 @@ Ipv4GlobalRouting::GetRoute(uint32_t index) const } index -= m_networkRoutes.size(); tmp = 0; - for (ASExternalRoutesCI k = m_ASexternalRoutes.begin(); k != m_ASexternalRoutes.end(); k++) + for (auto k = m_ASexternalRoutes.begin(); k != m_ASexternalRoutes.end(); k++) { if (tmp == index) { @@ -292,7 +292,7 @@ Ipv4GlobalRouting::RemoveRoute(uint32_t index) if (index < m_hostRoutes.size()) { uint32_t tmp = 0; - for (HostRoutesI i = m_hostRoutes.begin(); i != m_hostRoutes.end(); i++) + for (auto i = m_hostRoutes.begin(); i != m_hostRoutes.end(); i++) { if (tmp == index) { @@ -308,7 +308,7 @@ Ipv4GlobalRouting::RemoveRoute(uint32_t index) } index -= m_hostRoutes.size(); uint32_t tmp = 0; - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { if (tmp == index) { @@ -323,7 +323,7 @@ Ipv4GlobalRouting::RemoveRoute(uint32_t index) } index -= m_networkRoutes.size(); tmp = 0; - for (ASExternalRoutesI k = m_ASexternalRoutes.begin(); k != m_ASexternalRoutes.end(); k++) + for (auto k = m_ASexternalRoutes.begin(); k != m_ASexternalRoutes.end(); k++) { if (tmp == index) { @@ -351,16 +351,15 @@ void Ipv4GlobalRouting::DoDispose() { NS_LOG_FUNCTION(this); - for (HostRoutesI i = m_hostRoutes.begin(); i != m_hostRoutes.end(); i = m_hostRoutes.erase(i)) + for (auto i = m_hostRoutes.begin(); i != m_hostRoutes.end(); i = m_hostRoutes.erase(i)) { delete (*i); } - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); - j = m_networkRoutes.erase(j)) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j = m_networkRoutes.erase(j)) { delete (*j); } - for (ASExternalRoutesI l = m_ASexternalRoutes.begin(); l != m_ASexternalRoutes.end(); + for (auto l = m_ASexternalRoutes.begin(); l != m_ASexternalRoutes.end(); l = m_ASexternalRoutes.erase(l)) { delete (*l); diff --git a/src/internet/model/ipv4-interface.cc b/src/internet/model/ipv4-interface.cc index 8790e1409..9848e1fee 100644 --- a/src/internet/model/ipv4-interface.cc +++ b/src/internet/model/ipv4-interface.cc @@ -232,7 +232,7 @@ Ipv4Interface::Send(Ptr p, const Ipv4Header& hdr, Ipv4Address dest) NS_ASSERT(m_tc); // is this packet aimed at a local interface ? - for (Ipv4InterfaceAddressListCI i = m_ifaddrs.begin(); i != m_ifaddrs.end(); ++i) + for (auto i = m_ifaddrs.begin(); i != m_ifaddrs.end(); ++i) { if (dest == (*i).GetLocal()) { @@ -271,7 +271,7 @@ Ipv4Interface::Send(Ptr p, const Ipv4Header& hdr, Ipv4Address dest) } else { - for (Ipv4InterfaceAddressListCI i = m_ifaddrs.begin(); i != m_ifaddrs.end(); ++i) + for (auto i = m_ifaddrs.begin(); i != m_ifaddrs.end(); ++i) { if (dest.IsSubnetDirectedBroadcast((*i).GetMask())) { @@ -335,7 +335,7 @@ Ipv4Interface::GetAddress(uint32_t index) const if (index < m_ifaddrs.size()) { uint32_t tmp = 0; - for (Ipv4InterfaceAddressListCI i = m_ifaddrs.begin(); i != m_ifaddrs.end(); i++) + for (auto i = m_ifaddrs.begin(); i != m_ifaddrs.end(); i++) { if (tmp == index) { @@ -360,7 +360,7 @@ Ipv4Interface::RemoveAddress(uint32_t index) { NS_FATAL_ERROR("Bug in Ipv4Interface::RemoveAddress"); } - Ipv4InterfaceAddressListI i = m_ifaddrs.begin(); + auto i = m_ifaddrs.begin(); uint32_t tmp = 0; while (i != m_ifaddrs.end()) { @@ -393,7 +393,7 @@ Ipv4Interface::RemoveAddress(Ipv4Address address) return Ipv4InterfaceAddress(); } - for (Ipv4InterfaceAddressListI it = m_ifaddrs.begin(); it != m_ifaddrs.end(); it++) + for (auto it = m_ifaddrs.begin(); it != m_ifaddrs.end(); it++) { if ((*it).GetLocal() == address) { diff --git a/src/internet/model/ipv4-l3-protocol.cc b/src/internet/model/ipv4-l3-protocol.cc index fd8fcbf4a..9903c7784 100644 --- a/src/internet/model/ipv4-l3-protocol.cc +++ b/src/internet/model/ipv4-l3-protocol.cc @@ -176,7 +176,7 @@ Ipv4L3Protocol::Remove(Ptr protocol) NS_LOG_FUNCTION(this << protocol); L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), -1); - L4List_t::iterator iter = m_protocols.find(key); + auto iter = m_protocols.find(key); if (iter == m_protocols.end()) { NS_LOG_WARN("Trying to remove an non-existent default protocol " @@ -194,7 +194,7 @@ Ipv4L3Protocol::Remove(Ptr protocol, uint32_t interfaceIndex) NS_LOG_FUNCTION(this << protocol << interfaceIndex); L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), interfaceIndex); - L4List_t::iterator iter = m_protocols.find(key); + auto iter = m_protocols.find(key); if (iter == m_protocols.end()) { NS_LOG_WARN("Trying to remove an non-existent protocol " @@ -220,21 +220,19 @@ Ipv4L3Protocol::GetProtocol(int protocolNumber, int32_t interfaceIndex) const { NS_LOG_FUNCTION(this << protocolNumber << interfaceIndex); - L4ListKey_t key; - L4List_t::const_iterator i; if (interfaceIndex >= 0) { // try the interface-specific protocol. - key = std::make_pair(protocolNumber, interfaceIndex); - i = m_protocols.find(key); + auto key = std::make_pair(protocolNumber, interfaceIndex); + auto i = m_protocols.find(key); if (i != m_protocols.end()) { return i->second; } } // try the generic protocol. - key = std::make_pair(protocolNumber, -1); - i = m_protocols.find(key); + auto key = std::make_pair(protocolNumber, -1); + auto i = m_protocols.find(key); if (i != m_protocols.end()) { return i->second; @@ -266,7 +264,7 @@ void Ipv4L3Protocol::DeleteRawSocket(Ptr socket) { NS_LOG_FUNCTION(this << socket); - for (SocketList::iterator i = m_sockets.begin(); i != m_sockets.end(); ++i) + for (auto i = m_sockets.begin(); i != m_sockets.end(); ++i) { if ((*i) == socket) { @@ -316,13 +314,13 @@ void Ipv4L3Protocol::DoDispose() { NS_LOG_FUNCTION(this); - for (L4List_t::iterator i = m_protocols.begin(); i != m_protocols.end(); ++i) + for (auto i = m_protocols.begin(); i != m_protocols.end(); ++i) { i->second = nullptr; } m_protocols.clear(); - for (Ipv4InterfaceList::iterator i = m_interfaces.begin(); i != m_interfaces.end(); ++i) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); ++i) { *i = nullptr; } @@ -333,7 +331,7 @@ Ipv4L3Protocol::DoDispose() m_node = nullptr; m_routingProtocol = nullptr; - for (MapFragments_t::iterator it = m_fragments.begin(); it != m_fragments.end(); it++) + for (auto it = m_fragments.begin(); it != m_fragments.end(); it++) { it->second = nullptr; } @@ -464,8 +462,7 @@ Ipv4L3Protocol::GetInterfaceForAddress(Ipv4Address address) const { NS_LOG_FUNCTION(this << address); int32_t interface = 0; - for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); - i++, interface++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++, interface++) { for (uint32_t j = 0; j < (*i)->GetNAddresses(); j++) { @@ -484,8 +481,7 @@ Ipv4L3Protocol::GetInterfaceForPrefix(Ipv4Address address, Ipv4Mask mask) const { NS_LOG_FUNCTION(this << address << mask); int32_t interface = 0; - for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); - i++, interface++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++, interface++) { for (uint32_t j = 0; j < (*i)->GetNAddresses(); j++) { @@ -504,7 +500,7 @@ Ipv4L3Protocol::GetInterfaceForDevice(Ptr device) const { NS_LOG_FUNCTION(this << device); - Ipv4InterfaceReverseContainer::const_iterator iter = m_reverseInterfacesContainer.find(device); + auto iter = m_reverseInterfacesContainer.find(device); if (iter != m_reverseInterfacesContainer.end()) { return (*iter).second; @@ -650,8 +646,7 @@ Ipv4L3Protocol::Receive(Ptr device, // addresses. In doubt, update all of them. Note: it's a confirmed behavior for Linux // routers. std::list entryList = arpCache->LookupInverse(from); - std::list::iterator iter; - for (iter = entryList.begin(); iter != entryList.end(); iter++) + for (auto iter = entryList.begin(); iter != entryList.end(); iter++) { if ((*iter)->IsAlive()) { @@ -661,7 +656,7 @@ Ipv4L3Protocol::Receive(Ptr device, } } - for (SocketList::iterator i = m_sockets.begin(); i != m_sockets.end(); ++i) + for (auto i = m_sockets.begin(); i != m_sockets.end(); ++i) { NS_LOG_LOGIC("Forwarding to raw socket"); Ptr socket = *i; @@ -834,8 +829,7 @@ Ipv4L3Protocol::Send(Ptr packet, { NS_LOG_LOGIC("Ipv4L3Protocol::Send case 2: limited broadcast - no route"); uint32_t ifaceIndex = 0; - for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin(); - ifaceIter != m_interfaces.end(); + for (auto ifaceIter = m_interfaces.begin(); ifaceIter != m_interfaces.end(); ifaceIter++, ifaceIndex++) { Ptr outInterface = *ifaceIter; @@ -866,9 +860,7 @@ Ipv4L3Protocol::Send(Ptr packet, } // 3) check: packet is destined to a subnet-directed broadcast address - for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin(); - ifaceIter != m_interfaces.end(); - ifaceIter++) + for (auto ifaceIter = m_interfaces.begin(); ifaceIter != m_interfaces.end(); ifaceIter++) { Ptr outInterface = *ifaceIter; uint32_t ifaceIndex = GetInterfaceForDevice(outInterface->GetDevice()); @@ -1019,9 +1011,7 @@ Ipv4L3Protocol::SendRealOut(Ptr route, Ptr packet, const Ipv4 { std::list listFragments; DoFragmentation(packet, ipHeader, outInterface->GetDevice()->GetMtu(), listFragments); - for (std::list::iterator it = listFragments.begin(); - it != listFragments.end(); - it++) + for (auto it = listFragments.begin(); it != listFragments.end(); it++) { NS_LOG_LOGIC("Sending fragment " << *(it->first)); CallTxTrace(it->second, it->first, this, interface); @@ -1046,9 +1036,8 @@ Ipv4L3Protocol::IpMulticastForward(Ptr mrtentry, NS_LOG_LOGIC("Multicast forwarding logic for node: " << m_node->GetId()); std::map ttlMap = mrtentry->GetOutputTtlMap(); - std::map::iterator mapIter; - for (mapIter = ttlMap.begin(); mapIter != ttlMap.end(); mapIter++) + for (auto mapIter = ttlMap.begin(); mapIter != ttlMap.end(); mapIter++) { uint32_t interface = mapIter->first; // uint32_t outputTtl = mapIter->second; // Unused for now @@ -1435,7 +1424,7 @@ Ipv4L3Protocol::SetIpForward(bool forward) { NS_LOG_FUNCTION(this << forward); m_ipForward = forward; - for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { (*i)->SetForwarding(forward); } @@ -1577,13 +1566,13 @@ Ipv4L3Protocol::ProcessFragment(Ptr& packet, Ipv4Header& ipHeader, uint3 Ptr fragments; - MapFragments_t::iterator it = m_fragments.find(key); + auto it = m_fragments.find(key); if (it == m_fragments.end()) { fragments = Create(); m_fragments.insert(std::make_pair(key, fragments)); - FragmentsTimeoutsListI_t iter = SetTimeout(key, ipHeader, iif); + auto iter = SetTimeout(key, ipHeader, iif); fragments->SetTimeoutIter(iter); } else @@ -1650,9 +1639,7 @@ Ipv4L3Protocol::Fragments::IsEntire() const { uint16_t lastEndOffset = 0; - for (std::list, uint16_t>>::const_iterator it = m_fragments.begin(); - it != m_fragments.end(); - it++) + for (auto it = m_fragments.begin(); it != m_fragments.end(); it++) { // overlapping fragments do exist NS_LOG_LOGIC("Checking overlaps " << lastEndOffset << " - " << it->second); @@ -1676,7 +1663,7 @@ Ipv4L3Protocol::Fragments::GetPacket() const { NS_LOG_FUNCTION(this); - std::list, uint16_t>>::const_iterator it = m_fragments.begin(); + auto it = m_fragments.begin(); Ptr p = it->first->Copy(); uint16_t lastEndOffset = p->GetSize(); @@ -1714,7 +1701,7 @@ Ipv4L3Protocol::Fragments::GetPartialPacket() const { NS_LOG_FUNCTION(this); - std::list, uint16_t>>::const_iterator it = m_fragments.begin(); + auto it = m_fragments.begin(); Ptr p = Create(); uint16_t lastEndOffset = 0; @@ -1761,7 +1748,7 @@ Ipv4L3Protocol::HandleFragmentsTimeout(FragmentKey_t key, Ipv4Header& ipHeader, { NS_LOG_FUNCTION(this << &key << &ipHeader << iif); - MapFragments_t::iterator it = m_fragments.find(key); + auto it = m_fragments.find(key); Ptr packet = it->second->GetPartialPacket(); // if we have at least 8 bytes, we can send an ICMP. @@ -1837,11 +1824,8 @@ Ipv4L3Protocol::UpdateDuplicate(Ptr p, const Ipv4Header& header) << std::get<3>(key) << ")"); // place a new entry, on collision the existing entry iterator is returned - DupMap_t::iterator iter; - bool inserted; - bool isDup; - std::tie(iter, inserted) = m_dups.emplace(key, Seconds(0)); - isDup = !inserted && iter->second > Simulator::Now(); + auto [iter, inserted] = m_dups.emplace(key, Seconds(0)); + bool isDup = !inserted && iter->second > Simulator::Now(); // set the expiration event iter->second = Simulator::Now() + m_expire; @@ -1894,7 +1878,7 @@ Ipv4L3Protocol::SetTimeout(FragmentKey_t key, Ipv4Header ipHeader, uint32_t iif) } m_timeoutEventList.emplace_back(now, key, ipHeader, iif); - Ipv4L3Protocol::FragmentsTimeoutsListI_t iter = --m_timeoutEventList.end(); + auto iter = --m_timeoutEventList.end(); return (iter); } diff --git a/src/internet/model/ipv4-list-routing.cc b/src/internet/model/ipv4-list-routing.cc index dad69ebc9..b3bd1e306 100644 --- a/src/internet/model/ipv4-list-routing.cc +++ b/src/internet/model/ipv4-list-routing.cc @@ -56,8 +56,7 @@ void Ipv4ListRouting::DoDispose() { NS_LOG_FUNCTION(this); - for (Ipv4RoutingProtocolList::iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { // Note: Calling dispose on these protocols causes memory leak @@ -77,9 +76,7 @@ Ipv4ListRouting::PrintRoutingTable(Ptr stream, Time::Unit u << ", Time: " << Now().As(unit) << ", Local time: " << m_ipv4->GetObject()->GetLocalTime().As(unit) << ", Ipv4ListRouting table" << std::endl; - for (Ipv4RoutingProtocolList::const_iterator i = m_routingProtocols.begin(); - i != m_routingProtocols.end(); - i++) + for (auto i = m_routingProtocols.begin(); i != m_routingProtocols.end(); i++) { *stream->GetStream() << " Priority: " << (*i).first << " Protocol: " << (*i).second->GetInstanceTypeId() << std::endl; @@ -91,8 +88,7 @@ void Ipv4ListRouting::DoInitialize() { NS_LOG_FUNCTION(this); - for (Ipv4RoutingProtocolList::iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { Ptr protocol = (*rprotoIter).second; @@ -110,9 +106,7 @@ Ipv4ListRouting::RouteOutput(Ptr p, NS_LOG_FUNCTION(this << p << header.GetDestination() << header.GetSource() << oif << sockerr); Ptr route; - for (Ipv4RoutingProtocolList::const_iterator i = m_routingProtocols.begin(); - i != m_routingProtocols.end(); - i++) + for (auto i = m_routingProtocols.begin(); i != m_routingProtocols.end(); i++) { NS_LOG_LOGIC("Checking protocol " << (*i).second->GetInstanceTypeId() << " with priority " << (*i).first); @@ -182,8 +176,7 @@ Ipv4ListRouting::RouteInput(Ptr p, { downstreamLcb = MakeNullCallback, const Ipv4Header&, uint32_t>(); } - for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { if ((*rprotoIter).second->RouteInput(p, header, idev, ucb, mcb, downstreamLcb, ecb)) @@ -201,8 +194,7 @@ void Ipv4ListRouting::NotifyInterfaceUp(uint32_t interface) { NS_LOG_FUNCTION(this << interface); - for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyInterfaceUp(interface); @@ -213,8 +205,7 @@ void Ipv4ListRouting::NotifyInterfaceDown(uint32_t interface) { NS_LOG_FUNCTION(this << interface); - for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyInterfaceDown(interface); @@ -225,8 +216,7 @@ void Ipv4ListRouting::NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address) { NS_LOG_FUNCTION(this << interface << address); - for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyAddAddress(interface, address); @@ -237,8 +227,7 @@ void Ipv4ListRouting::NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address) { NS_LOG_FUNCTION(this << interface << address); - for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyRemoveAddress(interface, address); @@ -250,8 +239,7 @@ Ipv4ListRouting::SetIpv4(Ptr ipv4) { NS_LOG_FUNCTION(this << ipv4); NS_ASSERT(!m_ipv4); - for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->SetIpv4(ipv4); @@ -288,8 +276,7 @@ Ipv4ListRouting::GetRoutingProtocol(uint32_t index, int16_t& priority) const << " out of range"); } uint32_t i = 0; - for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++, i++) { if (i == index) diff --git a/src/internet/model/ipv4-raw-socket-impl.cc b/src/internet/model/ipv4-raw-socket-impl.cc index c4f98fc0b..86e4a547d 100644 --- a/src/internet/model/ipv4-raw-socket-impl.cc +++ b/src/internet/model/ipv4-raw-socket-impl.cc @@ -400,7 +400,7 @@ Ipv4RawSocketImpl::GetRxAvailable() const { NS_LOG_FUNCTION(this); uint32_t rx = 0; - for (std::list::const_iterator i = m_recv.begin(); i != m_recv.end(); ++i) + for (auto i = m_recv.begin(); i != m_recv.end(); ++i) { rx += (i->packet)->GetSize(); } diff --git a/src/internet/model/ipv4-route.cc b/src/internet/model/ipv4-route.cc index 0ac391236..4182cfd34 100644 --- a/src/internet/model/ipv4-route.cc +++ b/src/internet/model/ipv4-route.cc @@ -151,8 +151,7 @@ Ipv4MulticastRoute::SetOutputTtl(uint32_t oif, uint32_t ttl) if (ttl >= MAX_TTL) { // This TTL value effectively disables the interface - std::map::iterator iter; - iter = m_ttls.find(oif); + auto iter = m_ttls.find(oif); if (iter != m_ttls.end()) { m_ttls.erase(iter); diff --git a/src/internet/model/ipv4-static-routing.cc b/src/internet/model/ipv4-static-routing.cc index 781c88f4e..2d81e8d36 100644 --- a/src/internet/model/ipv4-static-routing.cc +++ b/src/internet/model/ipv4-static-routing.cc @@ -78,7 +78,7 @@ Ipv4StaticRouting::AddNetworkRouteTo(Ipv4Address network, if (!LookupRoute(route, metric)) { - Ipv4RoutingTableEntry* routePtr = new Ipv4RoutingTableEntry(route); + auto routePtr = new Ipv4RoutingTableEntry(route); m_networkRoutes.emplace_back(routePtr, metric); } } @@ -95,7 +95,7 @@ Ipv4StaticRouting::AddNetworkRouteTo(Ipv4Address network, Ipv4RoutingTableEntry::CreateNetworkRouteTo(network, networkMask, interface); if (!LookupRoute(route, metric)) { - Ipv4RoutingTableEntry* routePtr = new Ipv4RoutingTableEntry(route); + auto routePtr = new Ipv4RoutingTableEntry(route); m_networkRoutes.emplace_back(routePtr, metric); } @@ -133,7 +133,7 @@ Ipv4StaticRouting::AddMulticastRoute(Ipv4Address origin, { NS_LOG_FUNCTION(this << origin << " " << group << " " << inputInterface << " " << &outputInterfaces); - Ipv4MulticastRoutingTableEntry* route = new Ipv4MulticastRoutingTableEntry(); + auto route = new Ipv4MulticastRoutingTableEntry(); *route = Ipv4MulticastRoutingTableEntry::CreateMulticastRoute(origin, group, inputInterface, @@ -148,9 +148,9 @@ void Ipv4StaticRouting::SetDefaultMulticastRoute(uint32_t outputInterface) { NS_LOG_FUNCTION(this << outputInterface); - Ipv4RoutingTableEntry* route = new Ipv4RoutingTableEntry(); - Ipv4Address network = Ipv4Address("224.0.0.0"); - Ipv4Mask networkMask = Ipv4Mask("240.0.0.0"); + auto route = new Ipv4RoutingTableEntry(); + Ipv4Address network("224.0.0.0"); + Ipv4Mask networkMask("240.0.0.0"); *route = Ipv4RoutingTableEntry::CreateNetworkRouteTo(network, networkMask, outputInterface); m_networkRoutes.emplace_back(route, 0); } @@ -172,7 +172,7 @@ Ipv4StaticRouting::GetMulticastRoute(uint32_t index) const if (index < m_multicastRoutes.size()) { uint32_t tmp = 0; - for (MulticastRoutesCI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { if (tmp == index) { @@ -190,7 +190,7 @@ Ipv4StaticRouting::RemoveMulticastRoute(Ipv4Address origin, uint32_t inputInterface) { NS_LOG_FUNCTION(this << origin << " " << group << " " << inputInterface); - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { Ipv4MulticastRoutingTableEntry* route = *i; if (origin == route->GetOrigin() && group == route->GetGroup() && @@ -209,7 +209,7 @@ Ipv4StaticRouting::RemoveMulticastRoute(uint32_t index) { NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { if (tmp == index) { @@ -224,7 +224,7 @@ Ipv4StaticRouting::RemoveMulticastRoute(uint32_t index) bool Ipv4StaticRouting::LookupRoute(const Ipv4RoutingTableEntry& route, uint32_t metric) { - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { Ipv4RoutingTableEntry* rtentry = j->first; @@ -261,7 +261,7 @@ Ipv4StaticRouting::LookupStatic(Ipv4Address dest, Ptr oif) return rtentry; } - for (NetworkRoutesI i = m_networkRoutes.begin(); i != m_networkRoutes.end(); i++) + for (auto i = m_networkRoutes.begin(); i != m_networkRoutes.end(); i++) { Ipv4RoutingTableEntry* j = i->first; uint32_t metric = i->second; @@ -328,7 +328,7 @@ Ipv4StaticRouting::LookupStatic(Ipv4Address origin, Ipv4Address group, uint32_t NS_LOG_FUNCTION(this << origin << " " << group << " " << interface); Ptr mrtentry = nullptr; - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { Ipv4MulticastRoutingTableEntry* route = *i; // @@ -385,7 +385,7 @@ Ipv4StaticRouting::GetDefaultRoute() Ipv4Address dest("0.0.0.0"); uint32_t shortest_metric = 0xffffffff; Ipv4RoutingTableEntry* result = nullptr; - for (NetworkRoutesI i = m_networkRoutes.begin(); i != m_networkRoutes.end(); i++) + for (auto i = m_networkRoutes.begin(); i != m_networkRoutes.end(); i++) { Ipv4RoutingTableEntry* j = i->first; uint32_t metric = i->second; @@ -417,7 +417,7 @@ Ipv4StaticRouting::GetRoute(uint32_t index) const { NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (NetworkRoutesCI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { if (tmp == index) { @@ -435,7 +435,7 @@ Ipv4StaticRouting::GetMetric(uint32_t index) const { NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (NetworkRoutesCI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { if (tmp == index) { @@ -453,7 +453,7 @@ Ipv4StaticRouting::RemoveRoute(uint32_t index) { NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { if (tmp == index) { @@ -588,12 +588,11 @@ void Ipv4StaticRouting::DoDispose() { NS_LOG_FUNCTION(this); - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); - j = m_networkRoutes.erase(j)) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j = m_networkRoutes.erase(j)) { delete (j->first); } - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i = m_multicastRoutes.erase(i)) { delete (*i); @@ -628,7 +627,7 @@ Ipv4StaticRouting::NotifyInterfaceDown(uint32_t i) { NS_LOG_FUNCTION(this << i); // Remove all static routes that are going through this interface - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end();) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end();) { if (it->first->GetInterface() == i) { @@ -671,7 +670,7 @@ Ipv4StaticRouting::NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress Ipv4Mask networkMask = address.GetMask(); // Remove all static routes that are going through this interface // which reference this network - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end();) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end();) { if (it->first->GetInterface() == interface && it->first->IsNetwork() && it->first->GetDestNetwork() == networkAddress && diff --git a/src/internet/model/ipv6-address-generator.cc b/src/internet/model/ipv6-address-generator.cc index a266895db..f1836f6ec 100644 --- a/src/internet/model/ipv6-address-generator.cc +++ b/src/internet/model/ipv6-address-generator.cc @@ -515,7 +515,7 @@ Ipv6AddressGeneratorImpl::AddAllocated(const Ipv6Address address) taddr[15] += 1; if (Ipv6Address(addr) == Ipv6Address(taddr)) { - std::list::iterator j = i; + auto j = i; ++j; if (j != m_entries.end()) @@ -581,9 +581,7 @@ Ipv6AddressGeneratorImpl::IsAddressAllocated(const Ipv6Address address) uint8_t addr[16]; address.GetBytes(addr); - std::list::iterator i; - - for (i = m_entries.begin(); i != m_entries.end(); ++i) + for (auto i = m_entries.begin(); i != m_entries.end(); ++i) { NS_LOG_LOGIC("examine entry: " << Ipv6Address((*i).addrLow) << " to " << Ipv6Address((*i).addrHigh)); @@ -610,9 +608,7 @@ Ipv6AddressGeneratorImpl::IsNetworkAllocated(const Ipv6Address address, const Ip "Ipv6AddressGeneratorImpl::IsNetworkAllocated(): network address and mask don't match " << address << " " << prefix); - std::list::iterator i; - - for (i = m_entries.begin(); i != m_entries.end(); ++i) + for (auto i = m_entries.begin(); i != m_entries.end(); ++i) { NS_LOG_LOGIC("examine entry: " << Ipv6Address((*i).addrLow) << " to " << Ipv6Address((*i).addrHigh)); diff --git a/src/internet/model/ipv6-end-point-demux.cc b/src/internet/model/ipv6-end-point-demux.cc index 94a3944fa..f22a72811 100644 --- a/src/internet/model/ipv6-end-point-demux.cc +++ b/src/internet/model/ipv6-end-point-demux.cc @@ -39,7 +39,7 @@ Ipv6EndPointDemux::Ipv6EndPointDemux() Ipv6EndPointDemux::~Ipv6EndPointDemux() { NS_LOG_FUNCTION(this); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { Ipv6EndPoint* endPoint = *i; delete endPoint; @@ -51,7 +51,7 @@ bool Ipv6EndPointDemux::LookupPortLocal(uint16_t port) { NS_LOG_FUNCTION(this << port); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if ((*i)->GetLocalPort() == port) { @@ -65,7 +65,7 @@ bool Ipv6EndPointDemux::LookupLocal(Ptr boundNetDevice, Ipv6Address addr, uint16_t port) { NS_LOG_FUNCTION(this << addr << port); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if ((*i)->GetLocalPort() == port && (*i)->GetLocalAddress() == addr && (*i)->GetBoundNetDevice() == boundNetDevice) @@ -86,7 +86,7 @@ Ipv6EndPointDemux::Allocate() NS_LOG_WARN("Ephemeral port allocation failed."); return nullptr; } - Ipv6EndPoint* endPoint = new Ipv6EndPoint(Ipv6Address::GetAny(), port); + auto endPoint = new Ipv6EndPoint(Ipv6Address::GetAny(), port); m_endPoints.push_back(endPoint); NS_LOG_DEBUG("Now have >>" << m_endPoints.size() << "<< endpoints."); return endPoint; @@ -102,7 +102,7 @@ Ipv6EndPointDemux::Allocate(Ipv6Address address) NS_LOG_WARN("Ephemeral port allocation failed."); return nullptr; } - Ipv6EndPoint* endPoint = new Ipv6EndPoint(address, port); + auto endPoint = new Ipv6EndPoint(address, port); m_endPoints.push_back(endPoint); NS_LOG_DEBUG("Now have >>" << m_endPoints.size() << "<< endpoints."); return endPoint; @@ -125,7 +125,7 @@ Ipv6EndPointDemux::Allocate(Ptr boundNetDevice, Ipv6Address address, NS_LOG_WARN("Duplicated endpoint."); return nullptr; } - Ipv6EndPoint* endPoint = new Ipv6EndPoint(address, port); + auto endPoint = new Ipv6EndPoint(address, port); m_endPoints.push_back(endPoint); NS_LOG_DEBUG("Now have >>" << m_endPoints.size() << "<< endpoints."); return endPoint; @@ -139,7 +139,7 @@ Ipv6EndPointDemux::Allocate(Ptr boundNetDevice, uint16_t peerPort) { NS_LOG_FUNCTION(this << boundNetDevice << localAddress << localPort << peerAddress << peerPort); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if ((*i)->GetLocalPort() == localPort && (*i)->GetLocalAddress() == localAddress && (*i)->GetPeerPort() == peerPort && (*i)->GetPeerAddress() == peerAddress && @@ -149,7 +149,7 @@ Ipv6EndPointDemux::Allocate(Ptr boundNetDevice, return nullptr; } } - Ipv6EndPoint* endPoint = new Ipv6EndPoint(localAddress, localPort); + auto endPoint = new Ipv6EndPoint(localAddress, localPort); endPoint->SetPeer(peerAddress, peerPort); m_endPoints.push_back(endPoint); @@ -162,7 +162,7 @@ void Ipv6EndPointDemux::DeAllocate(Ipv6EndPoint* endPoint) { NS_LOG_FUNCTION(this); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { if (*i == endPoint) { @@ -193,7 +193,7 @@ Ipv6EndPointDemux::Lookup(Ipv6Address daddr, EndPoints retval4; /* Exact match on all 4 */ NS_LOG_DEBUG("Looking up endpoint for destination address " << daddr); - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { Ipv6EndPoint* endP = *i; @@ -313,7 +313,7 @@ Ipv6EndPointDemux::SimpleLookup(Ipv6Address dst, uint16_t dport, Ipv6Address src uint32_t genericity = 3; Ipv6EndPoint* generic = nullptr; - for (EndPointsI i = m_endPoints.begin(); i != m_endPoints.end(); i++) + for (auto i = m_endPoints.begin(); i != m_endPoints.end(); i++) { uint32_t tmp = 0; diff --git a/src/internet/model/ipv6-extension-demux.cc b/src/internet/model/ipv6-extension-demux.cc index be715e54a..f7e9eb45d 100644 --- a/src/internet/model/ipv6-extension-demux.cc +++ b/src/internet/model/ipv6-extension-demux.cc @@ -58,7 +58,7 @@ Ipv6ExtensionDemux::~Ipv6ExtensionDemux() void Ipv6ExtensionDemux::DoDispose() { - for (Ipv6ExtensionList_t::iterator it = m_extensions.begin(); it != m_extensions.end(); it++) + for (auto it = m_extensions.begin(); it != m_extensions.end(); it++) { (*it)->Dispose(); *it = nullptr; @@ -83,7 +83,7 @@ Ipv6ExtensionDemux::Insert(Ptr extension) Ptr Ipv6ExtensionDemux::GetExtension(uint8_t extensionNumber) { - for (Ipv6ExtensionList_t::iterator i = m_extensions.begin(); i != m_extensions.end(); ++i) + for (auto i = m_extensions.begin(); i != m_extensions.end(); ++i) { if ((*i)->GetExtensionNumber() == extensionNumber) { diff --git a/src/internet/model/ipv6-extension-header.cc b/src/internet/model/ipv6-extension-header.cc index a53eb88bf..dc1fc12fc 100644 --- a/src/internet/model/ipv6-extension-header.cc +++ b/src/internet/model/ipv6-extension-header.cc @@ -118,7 +118,7 @@ Ipv6ExtensionHeader::Deserialize(Buffer::Iterator start) m_length = i.ReadU8(); uint32_t dataLength = GetLength() - 2; - uint8_t* data = new uint8_t[dataLength]; + auto data = new uint8_t[dataLength]; i.Read(data, dataLength); if (dataLength > m_data.GetSize()) @@ -175,7 +175,7 @@ OptionField::Serialize(Buffer::Iterator start) const uint32_t OptionField::Deserialize(Buffer::Iterator start, uint32_t length) { - uint8_t* buf = new uint8_t[length]; + auto buf = new uint8_t[length]; start.Read(buf, length); m_optionData = Buffer(); m_optionData.AddAtEnd(length); @@ -613,9 +613,7 @@ Ipv6ExtensionLooseRoutingHeader::Print(std::ostream& os) const << " typeRouting = " << (uint32_t)GetTypeRouting() << " segmentsLeft = " << (uint32_t)GetSegmentsLeft() << " "; - for (std::vector::const_iterator it = m_routersAddress.begin(); - it != m_routersAddress.end(); - it++) + for (auto it = m_routersAddress.begin(); it != m_routersAddress.end(); it++) { os << *it << " "; } @@ -643,9 +641,7 @@ Ipv6ExtensionLooseRoutingHeader::Serialize(Buffer::Iterator start) const i.WriteU8(GetSegmentsLeft()); i.WriteU32(0); - for (VectorIpv6Address_t::const_iterator it = m_routersAddress.begin(); - it != m_routersAddress.end(); - it++) + for (auto it = m_routersAddress.begin(); it != m_routersAddress.end(); it++) { it->Serialize(buff); i.Write(buff, 16); diff --git a/src/internet/model/ipv6-extension.cc b/src/internet/model/ipv6-extension.cc index 809562e1d..5126f971f 100644 --- a/src/internet/model/ipv6-extension.cc +++ b/src/internet/model/ipv6-extension.cc @@ -109,7 +109,7 @@ Ipv6Extension::ProcessOptions(Ptr& packet, uint8_t processedSize = 0; uint32_t size = p->GetSize(); - uint8_t* data = new uint8_t[size]; + auto data = new uint8_t[size]; p->CopyData(data, size); uint8_t optionType = 0; @@ -354,7 +354,7 @@ Ipv6ExtensionFragment::DoDispose() { NS_LOG_FUNCTION(this); - for (MapFragments_t::iterator it = m_fragments.begin(); it != m_fragments.end(); it++) + for (auto it = m_fragments.begin(); it != m_fragments.end(); it++) { it->second = nullptr; } @@ -408,7 +408,7 @@ Ipv6ExtensionFragment::Process(Ptr& packet, Ipv6Header ipHeader = ipv6Header; ipHeader.SetNextHeader(fragmentHeader.GetNextHeader()); - MapFragments_t::iterator it = m_fragments.find(fragmentKey); + auto it = m_fragments.find(fragmentKey); if (it == m_fragments.end()) { fragments = Create(); @@ -416,7 +416,7 @@ Ipv6ExtensionFragment::Process(Ptr& packet, NS_LOG_DEBUG("Insert new fragment key: src: " << src << " IP hdr id " << identification << " m_fragments.size() " << m_fragments.size() << " offset " << fragmentOffset); - FragmentsTimeoutsListI_t iter = SetTimeout(fragmentKey, ipHeader); + auto iter = SetTimeout(fragmentKey, ipHeader); fragments->SetTimeoutIter(iter); } else @@ -487,7 +487,7 @@ Ipv6ExtensionFragment::GetFragments(Ptr packet, { if (nextHeader == Ipv6Header::IPV6_EXT_HOP_BY_HOP) { - Ipv6ExtensionHopByHopHeader* hopbyhopHeader = new Ipv6ExtensionHopByHopHeader(); + auto hopbyhopHeader = new Ipv6ExtensionHopByHopHeader(); p->RemoveHeader(*hopbyhopHeader); nextHeader = hopbyhopHeader->GetNextHeader(); @@ -541,8 +541,7 @@ Ipv6ExtensionFragment::GetFragments(Ptr packet, } else if (nextHeader == Ipv6Header::IPV6_EXT_DESTINATION) { - Ipv6ExtensionDestinationHeader* destinationHeader = - new Ipv6ExtensionDestinationHeader(); + auto destinationHeader = new Ipv6ExtensionDestinationHeader(); p->RemoveHeader(*destinationHeader); nextHeader = destinationHeader->GetNextHeader(); @@ -572,7 +571,7 @@ Ipv6ExtensionFragment::GetFragments(Ptr packet, uint32_t currentFragmentablePartSize = 0; bool moreFragment = true; - uint32_t identification = (uint32_t)m_uvar->GetValue(0, (uint32_t)-1); + auto identification = (uint32_t)m_uvar->GetValue(0, (uint32_t)-1); uint16_t offset = 0; do @@ -599,29 +598,23 @@ Ipv6ExtensionFragment::GetFragments(Ptr packet, fragment->AddHeader(fragmentHeader); - for (std::list>::iterator it = - unfragmentablePart.begin(); - it != unfragmentablePart.end(); - it++) + for (auto it = unfragmentablePart.begin(); it != unfragmentablePart.end(); it++) { if (it->second == Ipv6Header::IPV6_EXT_HOP_BY_HOP) { - Ipv6ExtensionHopByHopHeader* p = - dynamic_cast(it->first); + auto p = dynamic_cast(it->first); NS_ASSERT(p != nullptr); fragment->AddHeader(*p); } else if (it->second == Ipv6Header::IPV6_EXT_ROUTING) { - Ipv6ExtensionLooseRoutingHeader* p = - dynamic_cast(it->first); + auto p = dynamic_cast(it->first); NS_ASSERT(p != nullptr); fragment->AddHeader(*p); } else if (it->second == Ipv6Header::IPV6_EXT_DESTINATION) { - Ipv6ExtensionDestinationHeader* p = - dynamic_cast(it->first); + auto p = dynamic_cast(it->first); NS_ASSERT(p != nullptr); fragment->AddHeader(*p); } @@ -636,10 +629,7 @@ Ipv6ExtensionFragment::GetFragments(Ptr packet, listFragments.emplace_back(fragment, ipv6Header); } while (moreFragment); - for (std::list>::iterator it = - unfragmentablePart.begin(); - it != unfragmentablePart.end(); - it++) + for (auto it = unfragmentablePart.begin(); it != unfragmentablePart.end(); it++) { delete it->first; } @@ -653,7 +643,7 @@ Ipv6ExtensionFragment::HandleFragmentsTimeout(FragmentKey_t fragmentKey, Ipv6Hea NS_LOG_FUNCTION(this << fragmentKey.first << fragmentKey.second << ipHeader); Ptr fragments; - MapFragments_t::iterator it = m_fragments.find(fragmentKey); + auto it = m_fragments.find(fragmentKey); NS_ASSERT_MSG(it != m_fragments.end(), "IPv6 Fragment timeout reached for non-existent fragment"); fragments = it->second; @@ -694,7 +684,7 @@ Ipv6ExtensionFragment::SetTimeout(FragmentKey_t key, Ipv6Header ipHeader) << key.second); m_timeoutEventList.emplace_back(Simulator::Now() + m_fragmentExpirationTimeout, key, ipHeader); - Ipv6ExtensionFragment::FragmentsTimeoutsListI_t iter = --m_timeoutEventList.end(); + auto iter = --m_timeoutEventList.end(); return (iter); } @@ -778,10 +768,7 @@ Ipv6ExtensionFragment::Fragments::IsEntire() const { uint16_t lastEndOffset = 0; - for (std::list, uint16_t>>::const_iterator it = - m_packetFragments.begin(); - it != m_packetFragments.end(); - it++) + for (auto it = m_packetFragments.begin(); it != m_packetFragments.end(); it++) { if (lastEndOffset != it->second) { @@ -801,9 +788,7 @@ Ipv6ExtensionFragment::Fragments::GetPacket() const { Ptr p = m_unfragmentable->Copy(); - for (std::list, uint16_t>>::const_iterator it = m_packetFragments.begin(); - it != m_packetFragments.end(); - it++) + for (auto it = m_packetFragments.begin(); it != m_packetFragments.end(); it++) { p->AddAtEnd(it->first); } @@ -827,9 +812,7 @@ Ipv6ExtensionFragment::Fragments::GetPartialPacket() const uint16_t lastEndOffset = 0; - for (std::list, uint16_t>>::const_iterator it = m_packetFragments.begin(); - it != m_packetFragments.end(); - it++) + for (auto it = m_packetFragments.begin(); it != m_packetFragments.end(); it++) { if (lastEndOffset != it->second) { @@ -993,9 +976,7 @@ void Ipv6ExtensionRoutingDemux::DoDispose() { NS_LOG_FUNCTION(this); - for (Ipv6ExtensionRoutingList_t::iterator it = m_extensionsRouting.begin(); - it != m_extensionsRouting.end(); - it++) + for (auto it = m_extensionsRouting.begin(); it != m_extensionsRouting.end(); it++) { (*it)->Dispose(); *it = nullptr; diff --git a/src/internet/model/ipv6-interface.cc b/src/internet/model/ipv6-interface.cc index 3e137a5d4..dd6d36ae8 100644 --- a/src/internet/model/ipv6-interface.cc +++ b/src/internet/model/ipv6-interface.cc @@ -215,7 +215,7 @@ Ipv6Interface::AddAddress(Ipv6InterfaceAddress iface) /* DAD handling */ if (!addr.IsAny()) { - for (Ipv6InterfaceAddressListCI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (it->first.GetAddress() == addr) { @@ -282,7 +282,7 @@ Ipv6Interface::IsSolicitedMulticastAddress(Ipv6Address address) const /* IPv6 interface has always at least one IPv6 Solicited Multicast address */ NS_LOG_FUNCTION(this << address); - for (Ipv6InterfaceAddressListCI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (it->second == address) { @@ -301,7 +301,7 @@ Ipv6Interface::GetAddress(uint32_t index) const if (m_addresses.size() > index) { - for (Ipv6InterfaceAddressListCI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (i == index) { @@ -336,7 +336,7 @@ Ipv6Interface::RemoveAddress(uint32_t index) NS_FATAL_ERROR("Removing index that does not exist in Ipv6Interface::RemoveAddress"); } - for (Ipv6InterfaceAddressListI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (i == index) { @@ -367,7 +367,7 @@ Ipv6Interface::RemoveAddress(Ipv6Address address) return Ipv6InterfaceAddress(); } - for (Ipv6InterfaceAddressListI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (it->first.GetAddress() == address) { @@ -388,8 +388,7 @@ Ipv6Interface::GetAddressMatchingDestination(Ipv6Address dst) { NS_LOG_FUNCTION(this << dst); - for (Ipv6InterfaceAddressList::const_iterator it = m_addresses.begin(); it != m_addresses.end(); - ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { Ipv6InterfaceAddress ifaddr = it->first; @@ -431,7 +430,7 @@ Ipv6Interface::Send(Ptr p, const Ipv6Header& hdr, Ipv6Address dest) NS_ASSERT(m_tc); /* check if destination is for one of our interface */ - for (Ipv6InterfaceAddressListCI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (dest == it->first.GetAddress()) { @@ -559,7 +558,7 @@ Ipv6Interface::SetState(Ipv6Address address, Ipv6InterfaceAddress::State_e state { NS_LOG_FUNCTION(this << address << state); - for (Ipv6InterfaceAddressListI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (it->first.GetAddress() == address) { @@ -575,7 +574,7 @@ Ipv6Interface::SetNsDadUid(Ipv6Address address, uint32_t uid) { NS_LOG_FUNCTION(this << address << uid); - for (Ipv6InterfaceAddressListI it = m_addresses.begin(); it != m_addresses.end(); ++it) + for (auto it = m_addresses.begin(); it != m_addresses.end(); ++it) { if (it->first.GetAddress() == address) { diff --git a/src/internet/model/ipv6-l3-protocol.cc b/src/internet/model/ipv6-l3-protocol.cc index 4ee84f1f5..512653ec8 100644 --- a/src/internet/model/ipv6-l3-protocol.cc +++ b/src/internet/model/ipv6-l3-protocol.cc @@ -150,14 +150,14 @@ Ipv6L3Protocol::DoDispose() NS_LOG_FUNCTION(this); /* clear protocol and interface list */ - for (L4List_t::iterator it = m_protocols.begin(); it != m_protocols.end(); ++it) + for (auto it = m_protocols.begin(); it != m_protocols.end(); ++it) { it->second = nullptr; } m_protocols.clear(); /* remove interfaces */ - for (Ipv6InterfaceList::iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it) + for (auto it = m_interfaces.begin(); it != m_interfaces.end(); ++it) { *it = nullptr; } @@ -165,14 +165,14 @@ Ipv6L3Protocol::DoDispose() m_reverseInterfacesContainer.clear(); /* remove raw sockets */ - for (SocketList::iterator it = m_sockets.begin(); it != m_sockets.end(); ++it) + for (auto it = m_sockets.begin(); it != m_sockets.end(); ++it) { *it = nullptr; } m_sockets.clear(); /* remove list of prefix */ - for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin(); it != m_prefixes.end(); ++it) + for (auto it = m_prefixes.begin(); it != m_prefixes.end(); ++it) { (*it)->StopValidTimer(); (*it)->StopPreferredTimer(); @@ -263,8 +263,7 @@ Ipv6L3Protocol::GetInterfaceForAddress(Ipv6Address address) const NS_LOG_FUNCTION(this << address); int32_t index = 0; - for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin(); it != m_interfaces.end(); - it++) + for (auto it = m_interfaces.begin(); it != m_interfaces.end(); it++) { uint32_t j = 0; uint32_t max = (*it)->GetNAddresses(); @@ -287,8 +286,7 @@ Ipv6L3Protocol::GetInterfaceForPrefix(Ipv6Address address, Ipv6Prefix mask) cons NS_LOG_FUNCTION(this << address << mask); int32_t index = 0; - for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin(); it != m_interfaces.end(); - it++) + for (auto it = m_interfaces.begin(); it != m_interfaces.end(); it++) { uint32_t j = 0; for (j = 0; j < (*it)->GetNAddresses(); j++) @@ -316,7 +314,7 @@ Ipv6L3Protocol::GetInterfaceForDevice(Ptr device) const { NS_LOG_FUNCTION(this << device); - Ipv6InterfaceReverseContainer::const_iterator iter = m_reverseInterfacesContainer.find(device); + auto iter = m_reverseInterfacesContainer.find(device); if (iter != m_reverseInterfacesContainer.end()) { return (*iter).second; @@ -361,7 +359,7 @@ Ipv6L3Protocol::AddAutoconfiguredAddress(uint32_t interface, address.SetOnLink(onLink); /* see if we have already the prefix */ - for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin(); it != m_prefixes.end(); ++it) + for (auto it = m_prefixes.begin(); it != m_prefixes.end(); ++it) { if ((*it)->GetInterface() == interface && (*it)->GetPrefix() == network && (*it)->GetMask() == mask) @@ -421,7 +419,7 @@ Ipv6L3Protocol::RemoveAutoconfiguredAddress(uint32_t interface, } /* remove from list of autoconfigured address */ - for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin(); it != m_prefixes.end(); ++it) + for (auto it = m_prefixes.begin(); it != m_prefixes.end(); ++it) { if ((*it)->GetInterface() == interface && (*it)->GetPrefix() == network && (*it)->GetMask() == mask) @@ -721,8 +719,7 @@ Ipv6L3Protocol::SetIpForward(bool forward) NS_LOG_FUNCTION(this << forward); m_ipForward = forward; - for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin(); it != m_interfaces.end(); - it++) + for (auto it = m_interfaces.begin(); it != m_interfaces.end(); it++) { (*it)->SetForwarding(forward); } @@ -823,7 +820,7 @@ Ipv6L3Protocol::Remove(Ptr protocol) NS_LOG_FUNCTION(this << protocol); L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), -1); - L4List_t::iterator iter = m_protocols.find(key); + auto iter = m_protocols.find(key); if (iter == m_protocols.end()) { NS_LOG_WARN("Trying to remove an non-existent default protocol " @@ -841,7 +838,7 @@ Ipv6L3Protocol::Remove(Ptr protocol, uint32_t interfaceIndex) NS_LOG_FUNCTION(this << protocol << interfaceIndex); L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), interfaceIndex); - L4List_t::iterator iter = m_protocols.find(key); + auto iter = m_protocols.find(key); if (iter == m_protocols.end()) { NS_LOG_WARN("Trying to remove an non-existent protocol " @@ -867,21 +864,19 @@ Ipv6L3Protocol::GetProtocol(int protocolNumber, int32_t interfaceIndex) const { NS_LOG_FUNCTION(this << protocolNumber << interfaceIndex); - L4ListKey_t key; - L4List_t::const_iterator i; if (interfaceIndex >= 0) { // try the interface-specific protocol. - key = std::make_pair(protocolNumber, interfaceIndex); - i = m_protocols.find(key); + auto key = std::make_pair(protocolNumber, interfaceIndex); + auto i = m_protocols.find(key); if (i != m_protocols.end()) { return i->second; } } // try the generic protocol. - key = std::make_pair(protocolNumber, -1); - i = m_protocols.find(key); + auto key = std::make_pair(protocolNumber, -1); + auto i = m_protocols.find(key); if (i != m_protocols.end()) { return i->second; @@ -905,7 +900,7 @@ Ipv6L3Protocol::DeleteRawSocket(Ptr socket) { NS_LOG_FUNCTION(this << socket); - for (SocketList::iterator it = m_sockets.begin(); it != m_sockets.end(); ++it) + for (auto it = m_sockets.begin(); it != m_sockets.end(); ++it) { if ((*it) == socket) { @@ -1089,8 +1084,7 @@ Ipv6L3Protocol::Receive(Ptr device, // addresses. In doubt, update all of them. Note: it's a confirmed behavior for Linux // routers. std::list entryList = ndiscCache->LookupInverse(from); - std::list::iterator iter; - for (iter = entryList.begin(); iter != entryList.end(); iter++) + for (auto iter = entryList.begin(); iter != entryList.end(); iter++) { (*iter)->UpdateReachableTimer(); } @@ -1098,7 +1092,7 @@ Ipv6L3Protocol::Receive(Ptr device, } /* forward up to IPv6 raw sockets */ - for (SocketList::iterator it = m_sockets.begin(); it != m_sockets.end(); ++it) + for (auto it = m_sockets.begin(); it != m_sockets.end(); ++it) { Ptr socket = *it; socket->ForwardUp(packet, hdr, device); @@ -1301,10 +1295,7 @@ Ipv6L3Protocol::SendRealOut(Ptr route, Ptr packet, const Ipv6 { std::ostringstream oss; - for (std::list::const_iterator it = - fragments.begin(); - it != fragments.end(); - it++) + for (auto it = fragments.begin(); it != fragments.end(); it++) { CallTxTrace(it->second, it->first, this, interface); outInterface->Send(it->first, it->second, route->GetGateway()); @@ -1332,10 +1323,7 @@ Ipv6L3Protocol::SendRealOut(Ptr route, Ptr packet, const Ipv6 { std::ostringstream oss; - for (std::list::const_iterator it = - fragments.begin(); - it != fragments.end(); - it++) + for (auto it = fragments.begin(); it != fragments.end(); it++) { CallTxTrace(it->second, it->first, this, interface); outInterface->Send(it->first, it->second, ipHeader.GetDestination()); @@ -1458,9 +1446,8 @@ Ipv6L3Protocol::IpMulticastForward(Ptr idev, NS_LOG_LOGIC("Multicast forwarding logic for node: " << m_node->GetId()); std::map ttlMap = mrtentry->GetOutputTtlMap(); - std::map::iterator mapIter; - for (mapIter = ttlMap.begin(); mapIter != ttlMap.end(); mapIter++) + for (auto mapIter = ttlMap.begin(); mapIter != ttlMap.end(); mapIter++) { uint32_t interfaceId = mapIter->first; // uint32_t outputTtl = mapIter->second; // Unused for now @@ -1788,7 +1775,7 @@ Ipv6L3Protocol::IsRegisteredMulticastAddress(Ipv6Address address, uint32_t inter NS_LOG_FUNCTION(address << interface); Ipv6RegisteredMulticastAddressKey_t key = std::make_pair(address, interface); - Ipv6RegisteredMulticastAddressCIter_t iter = m_multicastAddresses.find(key); + auto iter = m_multicastAddresses.find(key); return iter != m_multicastAddresses.end(); } @@ -1798,8 +1785,7 @@ Ipv6L3Protocol::IsRegisteredMulticastAddress(Ipv6Address address) const { NS_LOG_FUNCTION(address); - Ipv6RegisteredMulticastAddressNoInterfaceCIter_t iter = - m_multicastAddressesNoInterface.find(address); + auto iter = m_multicastAddressesNoInterface.find(address); return iter != m_multicastAddressesNoInterface.end(); } @@ -1837,9 +1823,7 @@ Ipv6L3Protocol::ReachabilityHint(uint32_t ipInterfaceIndex, Ipv6Address address) // we just confirm the entry's MAC address to get the waiting packets (if any) std::list waiting = entry->MarkReachable(entry->GetMacAddress()); - for (std::list::const_iterator it = waiting.begin(); - it != waiting.end(); - it++) + for (auto it = waiting.begin(); it != waiting.end(); it++) { ndiscCache->GetInterface()->Send(it->first, it->second, it->second.GetSource()); } diff --git a/src/internet/model/ipv6-list-routing.cc b/src/internet/model/ipv6-list-routing.cc index f6f0b4829..32b041b2e 100644 --- a/src/internet/model/ipv6-list-routing.cc +++ b/src/internet/model/ipv6-list-routing.cc @@ -57,8 +57,7 @@ void Ipv6ListRouting::DoDispose() { NS_LOG_FUNCTION(this); - for (Ipv6RoutingProtocolList::iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { // Note: Calling dispose on these protocols causes memory leak @@ -79,9 +78,7 @@ Ipv6ListRouting::RouteOutput(Ptr p, NS_LOG_FUNCTION(this << header.GetDestination() << header.GetSource() << oif); Ptr route; - for (Ipv6RoutingProtocolList::const_iterator i = m_routingProtocols.begin(); - i != m_routingProtocols.end(); - i++) + for (auto i = m_routingProtocols.begin(); i != m_routingProtocols.end(); i++) { NS_LOG_LOGIC("Checking protocol " << (*i).second->GetInstanceTypeId() << " with priority " << (*i).first); @@ -131,8 +128,7 @@ Ipv6ListRouting::RouteInput(Ptr p, ErrorCallback nullEcb = MakeNullCallback, const Ipv6Header&, Socket::SocketErrno>(); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { if ((*rprotoIter).second->RouteInput(p, header, idev, ucb, mcb, lcb, nullEcb)) @@ -150,8 +146,7 @@ void Ipv6ListRouting::NotifyInterfaceUp(uint32_t interface) { NS_LOG_FUNCTION(this << interface); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyInterfaceUp(interface); @@ -162,8 +157,7 @@ void Ipv6ListRouting::NotifyInterfaceDown(uint32_t interface) { NS_LOG_FUNCTION(this << interface); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyInterfaceDown(interface); @@ -174,8 +168,7 @@ void Ipv6ListRouting::NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address) { NS_LOG_FUNCTION(this << interface << address); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyAddAddress(interface, address); @@ -186,8 +179,7 @@ void Ipv6ListRouting::NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress address) { NS_LOG_FUNCTION(this << interface << address); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyRemoveAddress(interface, address); @@ -202,8 +194,7 @@ Ipv6ListRouting::NotifyAddRoute(Ipv6Address dst, Ipv6Address prefixToUse) { NS_LOG_FUNCTION(this << dst << mask << nextHop << interface); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyAddRoute(dst, mask, nextHop, interface, prefixToUse); @@ -218,8 +209,7 @@ Ipv6ListRouting::NotifyRemoveRoute(Ipv6Address dst, Ipv6Address prefixToUse) { NS_LOG_FUNCTION(this << dst << mask << nextHop << interface); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->NotifyRemoveRoute(dst, mask, nextHop, interface, prefixToUse); @@ -235,9 +225,7 @@ Ipv6ListRouting::PrintRoutingTable(Ptr stream, Time::Unit u << ", Time: " << Now().As(unit) << ", Local time: " << m_ipv6->GetObject()->GetLocalTime().As(unit) << ", Ipv6ListRouting table" << std::endl; - for (Ipv6RoutingProtocolList::const_iterator i = m_routingProtocols.begin(); - i != m_routingProtocols.end(); - i++) + for (auto i = m_routingProtocols.begin(); i != m_routingProtocols.end(); i++) { *stream->GetStream() << " Priority: " << (*i).first << " Protocol: " << (*i).second->GetInstanceTypeId() << std::endl; @@ -250,8 +238,7 @@ Ipv6ListRouting::SetIpv6(Ptr ipv6) { NS_LOG_FUNCTION(this << ipv6); NS_ASSERT(!m_ipv6); - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++) { (*rprotoIter).second->SetIpv6(ipv6); @@ -288,8 +275,7 @@ Ipv6ListRouting::GetRoutingProtocol(uint32_t index, int16_t& priority) const << " out of range"); } uint32_t i = 0; - for (Ipv6RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin(); - rprotoIter != m_routingProtocols.end(); + for (auto rprotoIter = m_routingProtocols.begin(); rprotoIter != m_routingProtocols.end(); rprotoIter++, i++) { if (i == index) diff --git a/src/internet/model/ipv6-option-demux.cc b/src/internet/model/ipv6-option-demux.cc index c333d1011..4f8ea668a 100644 --- a/src/internet/model/ipv6-option-demux.cc +++ b/src/internet/model/ipv6-option-demux.cc @@ -57,7 +57,7 @@ Ipv6OptionDemux::~Ipv6OptionDemux() void Ipv6OptionDemux::DoDispose() { - for (Ipv6OptionList_t::iterator it = m_options.begin(); it != m_options.end(); it++) + for (auto it = m_options.begin(); it != m_options.end(); it++) { (*it)->Dispose(); *it = nullptr; @@ -82,7 +82,7 @@ Ipv6OptionDemux::Insert(Ptr option) Ptr Ipv6OptionDemux::GetOption(int optionNumber) { - for (Ipv6OptionList_t::iterator i = m_options.begin(); i != m_options.end(); ++i) + for (auto i = m_options.begin(); i != m_options.end(); ++i) { if ((*i)->GetOptionNumber() == optionNumber) { diff --git a/src/internet/model/ipv6-pmtu-cache.cc b/src/internet/model/ipv6-pmtu-cache.cc index f8c58a298..3f5c156e8 100644 --- a/src/internet/model/ipv6-pmtu-cache.cc +++ b/src/internet/model/ipv6-pmtu-cache.cc @@ -56,7 +56,7 @@ Ipv6PmtuCache::~Ipv6PmtuCache() void Ipv6PmtuCache::DoDispose() { - for (pathMtuTimerIter iter = m_pathMtuTimer.begin(); iter != m_pathMtuTimer.end(); iter++) + for (auto iter = m_pathMtuTimer.begin(); iter != m_pathMtuTimer.end(); iter++) { iter->second.Cancel(); } diff --git a/src/internet/model/ipv6-raw-socket-impl.cc b/src/internet/model/ipv6-raw-socket-impl.cc index 3908077c8..85560782e 100644 --- a/src/internet/model/ipv6-raw-socket-impl.cc +++ b/src/internet/model/ipv6-raw-socket-impl.cc @@ -421,7 +421,7 @@ Ipv6RawSocketImpl::GetRxAvailable() const NS_LOG_FUNCTION(this); uint32_t rx = 0; - for (std::list::const_iterator it = m_data.begin(); it != m_data.end(); ++it) + for (auto it = m_data.begin(); it != m_data.end(); ++it) { rx += (it->packet)->GetSize(); } diff --git a/src/internet/model/ipv6-route.cc b/src/internet/model/ipv6-route.cc index 0543cd3d8..9161e6d40 100644 --- a/src/internet/model/ipv6-route.cc +++ b/src/internet/model/ipv6-route.cc @@ -141,8 +141,7 @@ Ipv6MulticastRoute::SetOutputTtl(uint32_t oif, uint32_t ttl) if (ttl >= MAX_TTL) { // This TTL value effectively disables the interface - std::map::iterator iter; - iter = m_ttls.find(oif); + auto iter = m_ttls.find(oif); if (iter != m_ttls.end()) { m_ttls.erase(iter); diff --git a/src/internet/model/ipv6-static-routing.cc b/src/internet/model/ipv6-static-routing.cc index f6a752296..58bd1c412 100644 --- a/src/internet/model/ipv6-static-routing.cc +++ b/src/internet/model/ipv6-static-routing.cc @@ -181,7 +181,7 @@ Ipv6StaticRouting::AddNetworkRouteTo(Ipv6Address network, if (!LookupRoute(route, metric)) { - Ipv6RoutingTableEntry* routePtr = new Ipv6RoutingTableEntry(route); + auto routePtr = new Ipv6RoutingTableEntry(route); m_networkRoutes.emplace_back(routePtr, metric); } } @@ -208,7 +208,7 @@ Ipv6StaticRouting::AddNetworkRouteTo(Ipv6Address network, prefixToUse); if (!LookupRoute(route, metric)) { - Ipv6RoutingTableEntry* routePtr = new Ipv6RoutingTableEntry(route); + auto routePtr = new Ipv6RoutingTableEntry(route); m_networkRoutes.emplace_back(routePtr, metric); } } @@ -225,7 +225,7 @@ Ipv6StaticRouting::AddNetworkRouteTo(Ipv6Address network, Ipv6RoutingTableEntry::CreateNetworkRouteTo(network, networkPrefix, interface); if (!LookupRoute(route, metric)) { - Ipv6RoutingTableEntry* routePtr = new Ipv6RoutingTableEntry(route); + auto routePtr = new Ipv6RoutingTableEntry(route); m_networkRoutes.emplace_back(routePtr, metric); } } @@ -252,7 +252,7 @@ Ipv6StaticRouting::AddMulticastRoute(Ipv6Address origin, std::vector outputInterfaces) { NS_LOG_FUNCTION(this << origin << group << inputInterface); - Ipv6MulticastRoutingTableEntry* route = new Ipv6MulticastRoutingTableEntry(); + auto route = new Ipv6MulticastRoutingTableEntry(); *route = Ipv6MulticastRoutingTableEntry::CreateMulticastRoute(origin, group, inputInterface, @@ -264,7 +264,7 @@ void Ipv6StaticRouting::SetDefaultMulticastRoute(uint32_t outputInterface) { NS_LOG_FUNCTION(this << outputInterface); - Ipv6RoutingTableEntry* route = new Ipv6RoutingTableEntry(); + auto route = new Ipv6RoutingTableEntry(); Ipv6Address network = Ipv6Address("ff00::"); /* RFC 3513 */ Ipv6Prefix networkMask = Ipv6Prefix(8); *route = Ipv6RoutingTableEntry::CreateNetworkRouteTo(network, networkMask, outputInterface); @@ -288,7 +288,7 @@ Ipv6StaticRouting::GetMulticastRoute(uint32_t index) const if (index < m_multicastRoutes.size()) { uint32_t tmp = 0; - for (MulticastRoutesCI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { if (tmp == index) { @@ -306,7 +306,7 @@ Ipv6StaticRouting::RemoveMulticastRoute(Ipv6Address origin, uint32_t inputInterface) { NS_LOG_FUNCTION(this << origin << group << inputInterface); - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { Ipv6MulticastRoutingTableEntry* route = *i; if (origin == route->GetOrigin() && group == route->GetGroup() && @@ -326,7 +326,7 @@ Ipv6StaticRouting::RemoveMulticastRoute(uint32_t index) NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { if (tmp == index) { @@ -344,7 +344,7 @@ Ipv6StaticRouting::HasNetworkDest(Ipv6Address network, uint32_t interfaceIndex) NS_LOG_FUNCTION(this << network << interfaceIndex); /* in the network table */ - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { Ipv6RoutingTableEntry* rtentry = j->first; Ipv6Prefix prefix = rtentry->GetDestNetworkPrefix(); @@ -363,7 +363,7 @@ Ipv6StaticRouting::HasNetworkDest(Ipv6Address network, uint32_t interfaceIndex) bool Ipv6StaticRouting::LookupRoute(const Ipv6RoutingTableEntry& route, uint32_t metric) { - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j++) { Ipv6RoutingTableEntry* rtentry = j->first; @@ -402,7 +402,7 @@ Ipv6StaticRouting::LookupStatic(Ipv6Address dst, Ptr interface) return rtentry; } - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) { Ipv6RoutingTableEntry* j = it->first; uint32_t metric = it->second; @@ -485,14 +485,13 @@ Ipv6StaticRouting::DoDispose() { NS_LOG_FUNCTION(this); - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end(); - j = m_networkRoutes.erase(j)) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end(); j = m_networkRoutes.erase(j)) { delete j->first; } m_networkRoutes.clear(); - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i = m_multicastRoutes.erase(i)) { delete (*i); @@ -509,7 +508,7 @@ Ipv6StaticRouting::LookupStatic(Ipv6Address origin, Ipv6Address group, uint32_t NS_LOG_FUNCTION(this << origin << group << interface); Ptr mrtentry = nullptr; - for (MulticastRoutesI i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) + for (auto i = m_multicastRoutes.begin(); i != m_multicastRoutes.end(); i++) { Ipv6MulticastRoutingTableEntry* route = *i; @@ -569,7 +568,7 @@ Ipv6StaticRouting::GetDefaultRoute() uint32_t shortestMetric = 0xffffffff; Ipv6RoutingTableEntry* result = nullptr; - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) { Ipv6RoutingTableEntry* j = it->first; uint32_t metric = it->second; @@ -606,7 +605,7 @@ Ipv6StaticRouting::GetRoute(uint32_t index) const NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (NetworkRoutesCI it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) { if (tmp == index) { @@ -625,7 +624,7 @@ Ipv6StaticRouting::GetMetric(uint32_t index) const NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (NetworkRoutesCI it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) { if (tmp == index) { @@ -644,7 +643,7 @@ Ipv6StaticRouting::RemoveRoute(uint32_t index) NS_LOG_FUNCTION(this << index); uint32_t tmp = 0; - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) { if (tmp == index) { @@ -665,7 +664,7 @@ Ipv6StaticRouting::RemoveRoute(Ipv6Address network, { NS_LOG_FUNCTION(this << network << prefix << ifIndex); - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end(); it++) { Ipv6RoutingTableEntry* rtentry = it->first; if (network == rtentry->GetDest() && rtentry->GetInterface() == ifIndex && @@ -809,7 +808,7 @@ Ipv6StaticRouting::NotifyInterfaceDown(uint32_t i) NS_LOG_FUNCTION(this << i); /* remove all static routes that are going through this interface */ - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end();) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end();) { if (it->first->GetInterface() == i) { @@ -845,7 +844,7 @@ Ipv6StaticRouting::NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress // Remove all static routes that are going through this interface // which reference this network - for (NetworkRoutesI it = m_networkRoutes.begin(); it != m_networkRoutes.end();) + for (auto it = m_networkRoutes.begin(); it != m_networkRoutes.end();) { if (it->first->GetInterface() == interface && it->first->IsNetwork() && it->first->GetDestNetwork() == networkAddress && @@ -901,7 +900,7 @@ Ipv6StaticRouting::NotifyRemoveRoute(Ipv6Address dst, NS_LOG_FUNCTION(this << dst << mask << nextHop << interface); if (dst != Ipv6Address::GetZero()) { - for (NetworkRoutesI j = m_networkRoutes.begin(); j != m_networkRoutes.end();) + for (auto j = m_networkRoutes.begin(); j != m_networkRoutes.end();) { Ipv6RoutingTableEntry* rtentry = j->first; Ipv6Prefix prefix = rtentry->GetDestNetworkPrefix(); diff --git a/src/internet/model/ndisc-cache.cc b/src/internet/model/ndisc-cache.cc index 935eacda9..3f9b97095 100644 --- a/src/internet/model/ndisc-cache.cc +++ b/src/internet/model/ndisc-cache.cc @@ -118,7 +118,7 @@ NdiscCache::LookupInverse(Address dst) NS_LOG_FUNCTION(this << dst); std::list entryList; - for (CacheI i = m_ndCache.begin(); i != m_ndCache.end(); i++) + for (auto i = m_ndCache.begin(); i != m_ndCache.end(); i++) { NdiscCache::Entry* entry = (*i).second; if (entry->GetMacAddress() == dst) @@ -136,7 +136,7 @@ NdiscCache::Add(Ipv6Address to) NS_LOG_FUNCTION(this << to); NS_ASSERT(m_ndCache.find(to) == m_ndCache.end()); - NdiscCache::Entry* entry = new NdiscCache::Entry(this); + auto entry = new NdiscCache::Entry(this); entry->SetIpv6Address(to); m_ndCache[to] = entry; return entry; @@ -147,7 +147,7 @@ NdiscCache::Remove(NdiscCache::Entry* entry) { NS_LOG_FUNCTION(this << entry); - for (CacheI i = m_ndCache.begin(); i != m_ndCache.end(); i++) + for (auto i = m_ndCache.begin(); i != m_ndCache.end(); i++) { if ((*i).second == entry) { @@ -164,7 +164,7 @@ NdiscCache::Flush() { NS_LOG_FUNCTION(this); - for (CacheI i = m_ndCache.begin(); i != m_ndCache.end(); i++) + for (auto i = m_ndCache.begin(); i != m_ndCache.end(); i++) { delete (*i).second; /* delete the pointer NdiscCache::Entry */ } @@ -192,7 +192,7 @@ NdiscCache::PrintNdiscCache(Ptr stream) NS_LOG_FUNCTION(this << stream); std::ostream* os = stream->GetStream(); - for (CacheI i = m_ndCache.begin(); i != m_ndCache.end(); i++) + for (auto i = m_ndCache.begin(); i != m_ndCache.end(); i++) { *os << i->first << " dev "; std::string found = Names::FindName(m_device); @@ -717,7 +717,7 @@ void NdiscCache::RemoveAutoGeneratedEntries() { NS_LOG_FUNCTION(this); - for (CacheI i = m_ndCache.begin(); i != m_ndCache.end();) + for (auto i = m_ndCache.begin(); i != m_ndCache.end();) { if (i->second->IsAutoGenerated()) { diff --git a/src/internet/model/rip-header.cc b/src/internet/model/rip-header.cc index 2833fb111..766412e86 100644 --- a/src/internet/model/rip-header.cc +++ b/src/internet/model/rip-header.cc @@ -197,8 +197,7 @@ void RipHeader::Print(std::ostream& os) const { os << "command " << int(m_command); - for (std::list::const_iterator iter = m_rteList.begin(); iter != m_rteList.end(); - iter++) + for (auto iter = m_rteList.begin(); iter != m_rteList.end(); iter++) { os << " | "; iter->Print(os); @@ -221,8 +220,7 @@ RipHeader::Serialize(Buffer::Iterator start) const i.WriteU8(2); i.WriteU16(0); - for (std::list::const_iterator iter = m_rteList.begin(); iter != m_rteList.end(); - iter++) + for (auto iter = m_rteList.begin(); iter != m_rteList.end(); iter++) { iter->Serialize(i); i.Next(iter->GetSerializedSize()); diff --git a/src/internet/model/rip.cc b/src/internet/model/rip.cc index f51a36f28..f6f155764 100644 --- a/src/internet/model/rip.cc +++ b/src/internet/model/rip.cc @@ -346,7 +346,7 @@ Rip::NotifyInterfaceUp(uint32_t i) } bool sendSocketFound = false; - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { if (iter->second == i) { @@ -406,7 +406,7 @@ Rip::NotifyInterfaceDown(uint32_t interface) NS_LOG_FUNCTION(this << interface); /* remove all routes that are going through this interface */ - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first->GetInterface() == interface) { @@ -414,7 +414,7 @@ Rip::NotifyInterfaceDown(uint32_t interface) } } - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { NS_LOG_INFO("Checking socket for interface " << interface); if (iter->second == interface) @@ -478,7 +478,7 @@ Rip::NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address) // Remove all routes that are going through this interface // which reference this network - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first->GetInterface() == interface && it->first->IsNetwork() && it->first->GetDestNetwork() == networkAddress && @@ -536,7 +536,7 @@ Rip::PrintRoutingTable(Ptr stream, Time::Unit unit) const { *os << "Destination Gateway Genmask Flags Metric Ref Use Iface" << std::endl; - for (RoutesCI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { RipRoutingTableEntry* route = it->first; RipRoutingTableEntry::Status_e status = route->GetRouteStatus(); @@ -592,7 +592,7 @@ Rip::DoDispose() { NS_LOG_FUNCTION(this); - for (RoutesI j = m_routes.begin(); j != m_routes.end(); j = m_routes.erase(j)) + for (auto j = m_routes.begin(); j != m_routes.end(); j = m_routes.erase(j)) { delete j->first; } @@ -603,7 +603,7 @@ Rip::DoDispose() m_nextTriggeredUpdate = EventId(); m_nextUnsolicitedUpdate = EventId(); - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { iter->first->Close(); } @@ -639,7 +639,7 @@ Rip::Lookup(Ipv4Address dst, bool setSource, Ptr interface) return rtentry; } - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { RipRoutingTableEntry* j = it->first; @@ -708,8 +708,7 @@ Rip::AddNetworkRouteTo(Ipv4Address network, { NS_LOG_FUNCTION(this << network << networkPrefix << nextHop << interface); - RipRoutingTableEntry* route = - new RipRoutingTableEntry(network, networkPrefix, nextHop, interface); + auto route = new RipRoutingTableEntry(network, networkPrefix, nextHop, interface); route->SetRouteMetric(1); route->SetRouteStatus(RipRoutingTableEntry::RIP_VALID); route->SetRouteChanged(true); @@ -722,7 +721,7 @@ Rip::AddNetworkRouteTo(Ipv4Address network, Ipv4Mask networkPrefix, uint32_t int { NS_LOG_FUNCTION(this << network << networkPrefix << interface); - RipRoutingTableEntry* route = new RipRoutingTableEntry(network, networkPrefix, interface); + auto route = new RipRoutingTableEntry(network, networkPrefix, interface); route->SetRouteMetric(1); route->SetRouteStatus(RipRoutingTableEntry::RIP_VALID); route->SetRouteChanged(true); @@ -735,7 +734,7 @@ Rip::InvalidateRoute(RipRoutingTableEntry* route) { NS_LOG_FUNCTION(this << *route); - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first == route) { @@ -759,7 +758,7 @@ Rip::DeleteRoute(RipRoutingTableEntry* route) { NS_LOG_FUNCTION(this << *route); - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first == route) { @@ -869,8 +868,7 @@ Rip::HandleRequests(RipHeader requestHdr, // we use one of the sending sockets, as they're bound to the right interface // and the local address might be used on different interfaces. Ptr sendingSocket; - for (SocketListI iter = m_unicastSocketList.begin(); - iter != m_unicastSocketList.end(); + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { if (iter->second == incomingInterface) @@ -903,7 +901,7 @@ Rip::HandleRequests(RipHeader requestHdr, RipHeader hdr; hdr.SetCommand(RipHeader::RESPONSE); - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { bool splitHorizoning = (rtIter->first->GetInterface() == incomingInterface); @@ -976,10 +974,10 @@ Rip::HandleRequests(RipHeader requestHdr, RipHeader hdr; hdr.SetCommand(RipHeader::RESPONSE); - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { bool found = false; - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { Ipv4InterfaceAddress rtDestAddr = Ipv4InterfaceAddress(rtIter->first->GetDestNetwork(), @@ -1033,7 +1031,7 @@ Rip::HandleResponses(RipHeader hdr, std::list rtes = hdr.GetRteList(); // validate the RTEs before processing - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { if (iter->GetRouteMetric() == 0 || iter->GetRouteMetric() > m_linkDown) { @@ -1051,7 +1049,7 @@ Rip::HandleResponses(RipHeader hdr, bool changed = false; - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { Ipv4Mask rtePrefixMask = iter->GetSubnetMask(); Ipv4Address rteAddr = iter->GetPrefix().CombineMask(rtePrefixMask); @@ -1081,10 +1079,10 @@ Rip::HandleResponses(RipHeader hdr, { if (senderAddress != it->first->GetGateway()) { - RipRoutingTableEntry* route = new RipRoutingTableEntry(rteAddr, - rtePrefixMask, - senderAddress, - incomingInterface); + auto route = new RipRoutingTableEntry(rteAddr, + rtePrefixMask, + senderAddress, + incomingInterface); delete it->first; it->first = route; } @@ -1111,11 +1109,10 @@ Rip::HandleResponses(RipHeader hdr, { if (Simulator::GetDelayLeft(it->second) < m_timeoutDelay / 2) { - RipRoutingTableEntry* route = - new RipRoutingTableEntry(rteAddr, - rtePrefixMask, - senderAddress, - incomingInterface); + auto route = new RipRoutingTableEntry(rteAddr, + rtePrefixMask, + senderAddress, + incomingInterface); route->SetRouteMetric(rteMetric); route->SetRouteStatus(RipRoutingTableEntry::RIP_VALID); route->SetRouteTag(iter->GetRouteTag()); @@ -1159,7 +1156,7 @@ Rip::HandleResponses(RipHeader hdr, { NS_LOG_LOGIC("Received a RTE with new route, adding."); - RipRoutingTableEntry* route = + auto route = new RipRoutingTableEntry(rteAddr, rtePrefixMask, senderAddress, incomingInterface); route->SetRouteMetric(rteMetric); route->SetRouteStatus(RipRoutingTableEntry::RIP_VALID); @@ -1183,7 +1180,7 @@ Rip::DoSendRouteUpdate(bool periodic) { NS_LOG_FUNCTION(this << (periodic ? " periodic" : " triggered")); - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { uint32_t interface = iter->second; @@ -1202,7 +1199,7 @@ Rip::DoSendRouteUpdate(bool periodic) RipHeader hdr; hdr.SetCommand(RipHeader::RESPONSE); - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { bool splitHorizoning = (rtIter->first->GetInterface() == interface); Ipv4InterfaceAddress rtDestAddr = @@ -1270,7 +1267,7 @@ Rip::DoSendRouteUpdate(bool periodic) } } } - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { rtIter->first->SetRouteChanged(false); } @@ -1344,7 +1341,7 @@ Rip::GetInterfaceMetric(uint32_t interface) const { NS_LOG_FUNCTION(this << interface); - std::map::const_iterator iter = m_interfaceMetrics.find(interface); + auto iter = m_interfaceMetrics.find(interface); if (iter != m_interfaceMetrics.end()) { return iter->second; @@ -1385,7 +1382,7 @@ Rip::SendRouteRequest() hdr.AddRte(rte); p->AddHeader(hdr); - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { uint32_t interface = iter->second; diff --git a/src/internet/model/ripng-header.cc b/src/internet/model/ripng-header.cc index 854525b46..3deb38d71 100644 --- a/src/internet/model/ripng-header.cc +++ b/src/internet/model/ripng-header.cc @@ -179,8 +179,7 @@ void RipNgHeader::Print(std::ostream& os) const { os << "command " << int(m_command); - for (std::list::const_iterator iter = m_rteList.begin(); iter != m_rteList.end(); - iter++) + for (auto iter = m_rteList.begin(); iter != m_rteList.end(); iter++) { os << " | "; iter->Print(os); @@ -203,8 +202,7 @@ RipNgHeader::Serialize(Buffer::Iterator start) const i.WriteU8(1); i.WriteU16(0); - for (std::list::const_iterator iter = m_rteList.begin(); iter != m_rteList.end(); - iter++) + for (auto iter = m_rteList.begin(); iter != m_rteList.end(); iter++) { iter->Serialize(i); i.Next(iter->GetSerializedSize()); diff --git a/src/internet/model/ripng.cc b/src/internet/model/ripng.cc index 6fae1a8fe..1bff980ae 100644 --- a/src/internet/model/ripng.cc +++ b/src/internet/model/ripng.cc @@ -313,7 +313,7 @@ RipNg::NotifyInterfaceUp(uint32_t i) } bool sendSocketFound = false; - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { if (iter->second == i) { @@ -374,7 +374,7 @@ RipNg::NotifyInterfaceDown(uint32_t interface) NS_LOG_FUNCTION(this << interface); /* remove all routes that are going through this interface */ - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first->GetInterface() == interface) { @@ -382,7 +382,7 @@ RipNg::NotifyInterfaceDown(uint32_t interface) } } - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { NS_LOG_INFO("Checking socket for interface " << interface); if (iter->second == interface) @@ -446,7 +446,7 @@ RipNg::NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress address) // Remove all routes that are going through this interface // which reference this network - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first->GetInterface() == interface && it->first->IsNetwork() && it->first->GetDestNetwork() == networkAddress && @@ -522,7 +522,7 @@ RipNg::PrintRoutingTable(Ptr stream, Time::Unit unit) const { *os << "Destination Next Hop Flag Met Ref Use If" << std::endl; - for (RoutesCI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { RipNgRoutingTableEntry* route = it->first; RipNgRoutingTableEntry::Status_e status = route->GetRouteStatus(); @@ -576,7 +576,7 @@ RipNg::DoDispose() { NS_LOG_FUNCTION(this); - for (RoutesI j = m_routes.begin(); j != m_routes.end(); j = m_routes.erase(j)) + for (auto j = m_routes.begin(); j != m_routes.end(); j = m_routes.erase(j)) { delete j->first; } @@ -587,7 +587,7 @@ RipNg::DoDispose() m_nextTriggeredUpdate = EventId(); m_nextUnsolicitedUpdate = EventId(); - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { iter->first->Close(); } @@ -624,7 +624,7 @@ RipNg::Lookup(Ipv6Address dst, bool setSource, Ptr interface) return rtentry; } - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { RipNgRoutingTableEntry* j = it->first; @@ -705,7 +705,7 @@ RipNg::AddNetworkRouteTo(Ipv6Address network, NS_LOG_WARN("Ripng::AddNetworkRouteTo - Next hop should be link-local"); } - RipNgRoutingTableEntry* route = + auto route = new RipNgRoutingTableEntry(network, networkPrefix, nextHop, interface, prefixToUse); route->SetRouteMetric(1); route->SetRouteStatus(RipNgRoutingTableEntry::RIPNG_VALID); @@ -719,7 +719,7 @@ RipNg::AddNetworkRouteTo(Ipv6Address network, Ipv6Prefix networkPrefix, uint32_t { NS_LOG_FUNCTION(this << network << networkPrefix << interface); - RipNgRoutingTableEntry* route = new RipNgRoutingTableEntry(network, networkPrefix, interface); + auto route = new RipNgRoutingTableEntry(network, networkPrefix, interface); route->SetRouteMetric(1); route->SetRouteStatus(RipNgRoutingTableEntry::RIPNG_VALID); route->SetRouteChanged(true); @@ -732,7 +732,7 @@ RipNg::InvalidateRoute(RipNgRoutingTableEntry* route) { NS_LOG_FUNCTION(this << *route); - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first == route) { @@ -756,7 +756,7 @@ RipNg::DeleteRoute(RipNgRoutingTableEntry* route) { NS_LOG_FUNCTION(this << *route); - for (RoutesI it = m_routes.begin(); it != m_routes.end(); it++) + for (auto it = m_routes.begin(); it != m_routes.end(); it++) { if (it->first == route) { @@ -851,8 +851,7 @@ RipNg::HandleRequests(RipNgHeader requestHdr, // we use one of the sending sockets, as they're bound to the right interface // and the local address might be used on different interfaces. Ptr sendingSocket; - for (SocketListI iter = m_unicastSocketList.begin(); - iter != m_unicastSocketList.end(); + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { if (iter->second == incomingInterface) @@ -878,7 +877,7 @@ RipNg::HandleRequests(RipNgHeader requestHdr, RipNgHeader hdr; hdr.SetCommand(RipNgHeader::RESPONSE); - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { bool splitHorizoning = (rtIter->first->GetInterface() == incomingInterface); @@ -940,8 +939,7 @@ RipNg::HandleRequests(RipNgHeader requestHdr, Ptr sendingSocket; if (senderAddress.IsLinkLocal()) { - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); - iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { if (iter->second == incomingInterface) { @@ -963,10 +961,10 @@ RipNg::HandleRequests(RipNgHeader requestHdr, RipNgHeader hdr; hdr.SetCommand(RipNgHeader::RESPONSE); - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { bool found = false; - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { Ipv6InterfaceAddress rtDestAddr = Ipv6InterfaceAddress(rtIter->first->GetDestNetwork(), @@ -1032,7 +1030,7 @@ RipNg::HandleResponses(RipNgHeader hdr, std::list rtes = hdr.GetRteList(); // validate the RTEs before processing - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { if (iter->GetRouteMetric() == 0 || iter->GetRouteMetric() > m_linkDown) { @@ -1056,7 +1054,7 @@ RipNg::HandleResponses(RipNgHeader hdr, bool changed = false; - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { Ipv6Prefix rtePrefix = Ipv6Prefix(iter->GetPrefixLen()); Ipv6Address rteAddr = iter->GetPrefix().CombinePrefix(rtePrefix); @@ -1085,12 +1083,11 @@ RipNg::HandleResponses(RipNgHeader hdr, { if (senderAddress != it->first->GetGateway()) { - RipNgRoutingTableEntry* route = - new RipNgRoutingTableEntry(rteAddr, - rtePrefix, - senderAddress, - incomingInterface, - Ipv6Address::GetAny()); + auto route = new RipNgRoutingTableEntry(rteAddr, + rtePrefix, + senderAddress, + incomingInterface, + Ipv6Address::GetAny()); delete it->first; it->first = route; } @@ -1119,12 +1116,11 @@ RipNg::HandleResponses(RipNgHeader hdr, { if (Simulator::GetDelayLeft(it->second) < m_timeoutDelay / 2) { - RipNgRoutingTableEntry* route = - new RipNgRoutingTableEntry(rteAddr, - rtePrefix, - senderAddress, - incomingInterface, - Ipv6Address::GetAny()); + auto route = new RipNgRoutingTableEntry(rteAddr, + rtePrefix, + senderAddress, + incomingInterface, + Ipv6Address::GetAny()); route->SetRouteMetric(rteMetric); route->SetRouteStatus(RipNgRoutingTableEntry::RIPNG_VALID); route->SetRouteTag(iter->GetRouteTag()); @@ -1168,11 +1164,11 @@ RipNg::HandleResponses(RipNgHeader hdr, { NS_LOG_LOGIC("Received a RTE with new route, adding."); - RipNgRoutingTableEntry* route = new RipNgRoutingTableEntry(rteAddr, - rtePrefix, - senderAddress, - incomingInterface, - Ipv6Address::GetAny()); + auto route = new RipNgRoutingTableEntry(rteAddr, + rtePrefix, + senderAddress, + incomingInterface, + Ipv6Address::GetAny()); route->SetRouteMetric(rteMetric); route->SetRouteStatus(RipNgRoutingTableEntry::RIPNG_VALID); route->SetRouteChanged(true); @@ -1195,7 +1191,7 @@ RipNg::DoSendRouteUpdate(bool periodic) { NS_LOG_FUNCTION(this << (periodic ? " periodic" : " triggered")); - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { uint32_t interface = iter->second; @@ -1215,7 +1211,7 @@ RipNg::DoSendRouteUpdate(bool periodic) RipNgHeader hdr; hdr.SetCommand(RipNgHeader::RESPONSE); - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { bool splitHorizoning = (rtIter->first->GetInterface() == interface); Ipv6InterfaceAddress rtDestAddr = @@ -1271,7 +1267,7 @@ RipNg::DoSendRouteUpdate(bool periodic) } } } - for (RoutesI rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) + for (auto rtIter = m_routes.begin(); rtIter != m_routes.end(); rtIter++) { rtIter->first->SetRouteChanged(false); } @@ -1345,7 +1341,7 @@ RipNg::GetInterfaceMetric(uint32_t interface) const { NS_LOG_FUNCTION(this << interface); - std::map::const_iterator iter = m_interfaceMetrics.find(interface); + auto iter = m_interfaceMetrics.find(interface); if (iter != m_interfaceMetrics.end()) { return iter->second; @@ -1386,7 +1382,7 @@ RipNg::SendRouteRequest() hdr.AddRte(rte); p->AddHeader(hdr); - for (SocketListI iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) + for (auto iter = m_unicastSocketList.begin(); iter != m_unicastSocketList.end(); iter++) { uint32_t interface = iter->second; diff --git a/src/internet/model/tcp-header.cc b/src/internet/model/tcp-header.cc index 83fdc58e4..bb782bf9d 100644 --- a/src/internet/model/tcp-header.cc +++ b/src/internet/model/tcp-header.cc @@ -267,9 +267,7 @@ TcpHeader::Print(std::ostream& os) const os << " Seq=" << m_sequenceNumber << " Ack=" << m_ackNumber << " Win=" << m_windowSize; - TcpOptionList::const_iterator op; - - for (op = m_options.begin(); op != m_options.end(); ++op) + for (auto op = m_options.begin(); op != m_options.end(); ++op) { os << " " << (*op)->GetInstanceTypeId().GetName() << "("; (*op)->Print(os); @@ -300,8 +298,8 @@ TcpHeader::Serialize(Buffer::Iterator start) const // This implementation does not presently try to align options on word // boundaries using NOP options uint32_t optionLen = 0; - TcpOptionList::const_iterator op; - for (op = m_options.begin(); op != m_options.end(); ++op) + + for (auto op = m_options.begin(); op != m_options.end(); ++op) { optionLen += (*op)->GetSerializedSize(); (*op)->Serialize(i); @@ -417,9 +415,8 @@ uint8_t TcpHeader::CalculateHeaderLength() const { uint32_t len = 20; - TcpOptionList::const_iterator i; - for (i = m_options.begin(); i != m_options.end(); ++i) + for (auto i = m_options.begin(); i != m_options.end(); ++i) { len += (*i)->GetSerializedSize(); } @@ -466,9 +463,7 @@ TcpHeader::GetOptionList() const Ptr TcpHeader::GetOption(uint8_t kind) const { - TcpOptionList::const_iterator i; - - for (i = m_options.begin(); i != m_options.end(); ++i) + for (auto i = m_options.begin(); i != m_options.end(); ++i) { if ((*i)->GetKind() == kind) { @@ -482,9 +477,7 @@ TcpHeader::GetOption(uint8_t kind) const bool TcpHeader::HasOption(uint8_t kind) const { - TcpOptionList::const_iterator i; - - for (i = m_options.begin(); i != m_options.end(); ++i) + for (auto i = m_options.begin(); i != m_options.end(); ++i) { if ((*i)->GetKind() == kind) { diff --git a/src/internet/model/tcp-htcp.cc b/src/internet/model/tcp-htcp.cc index 488b1c96a..f6af49841 100644 --- a/src/internet/model/tcp-htcp.cc +++ b/src/internet/model/tcp-htcp.cc @@ -182,7 +182,7 @@ TcpHtcp::GetSsThresh(Ptr tcb, uint32_t bytesInFlight) UpdateAlpha(); uint32_t segWin = 2 * tcb->m_segmentSize; - uint32_t bFlight = static_cast(bytesInFlight * m_beta); + auto bFlight = static_cast(bytesInFlight * m_beta); uint32_t ssThresh = std::max(segWin, bFlight); m_minRtt = Time::Max(); m_maxRtt = Time::Min(); diff --git a/src/internet/model/tcp-hybla.cc b/src/internet/model/tcp-hybla.cc index 29f6f4f7a..8d50c710a 100644 --- a/src/internet/model/tcp-hybla.cc +++ b/src/internet/model/tcp-hybla.cc @@ -106,7 +106,7 @@ TcpHybla::SlowStart(Ptr tcb, uint32_t segmentsAcked) */ double increment = std::pow(2, m_rho) - 1.0; - uint32_t incr = static_cast(increment * tcb->m_segmentSize); + auto incr = static_cast(increment * tcb->m_segmentSize); NS_LOG_INFO("Slow start: inc=" << increment); tcb->m_cWnd = std::min(tcb->m_cWnd + incr, tcb->m_ssThresh); @@ -145,7 +145,7 @@ TcpHybla::CongestionAvoidance(Ptr tcb, uint32_t segmentsAcked) if (m_cWndCnt >= 1.0) { // double to int truncates every time. - uint32_t inc = static_cast(m_cWndCnt); + auto inc = static_cast(m_cWndCnt); m_cWndCnt -= inc; NS_ASSERT(m_cWndCnt >= 0.0); diff --git a/src/internet/model/tcp-ledbat.cc b/src/internet/model/tcp-ledbat.cc index 2bab9ba4f..03244c74c 100644 --- a/src/internet/model/tcp-ledbat.cc +++ b/src/internet/model/tcp-ledbat.cc @@ -288,7 +288,7 @@ TcpLedbat::UpdateBaseDelay(uint32_t owd) } else { - uint32_t last = static_cast(m_baseHistory.buffer.size() - 1); + auto last = static_cast(m_baseHistory.buffer.size() - 1); if (owd < m_baseHistory.buffer[last]) { m_baseHistory.buffer[last] = owd; diff --git a/src/internet/model/tcp-option-sack.cc b/src/internet/model/tcp-option-sack.cc index f4bf62fb2..3a95ab718 100644 --- a/src/internet/model/tcp-option-sack.cc +++ b/src/internet/model/tcp-option-sack.cc @@ -62,7 +62,7 @@ void TcpOptionSack::Print(std::ostream& os) const { os << "blocks: " << GetNumSackBlocks() << ","; - for (SackList::const_iterator it = m_sackList.begin(); it != m_sackList.end(); ++it) + for (auto it = m_sackList.begin(); it != m_sackList.end(); ++it) { os << "[" << it->first << "," << it->second << "]"; } @@ -82,10 +82,10 @@ TcpOptionSack::Serialize(Buffer::Iterator start) const NS_LOG_FUNCTION(this); Buffer::Iterator i = start; i.WriteU8(GetKind()); // Kind - uint8_t length = static_cast(GetNumSackBlocks() * 8 + 2); + auto length = static_cast(GetNumSackBlocks() * 8 + 2); i.WriteU8(length); // Length - for (SackList::const_iterator it = m_sackList.begin(); it != m_sackList.end(); ++it) + for (auto it = m_sackList.begin(); it != m_sackList.end(); ++it) { SequenceNumber32 leftEdge = it->first; SequenceNumber32 rightEdge = it->second; @@ -112,8 +112,8 @@ TcpOptionSack::Deserialize(Buffer::Iterator start) uint8_t sackCount = (size - 2) / 8; while (sackCount) { - SequenceNumber32 leftEdge = SequenceNumber32(i.ReadNtohU32()); - SequenceNumber32 rightEdge = SequenceNumber32(i.ReadNtohU32()); + SequenceNumber32 leftEdge(i.ReadNtohU32()); + SequenceNumber32 rightEdge(i.ReadNtohU32()); SackBlock s(leftEdge, rightEdge); AddSackBlock(s); sackCount--; diff --git a/src/internet/model/tcp-rx-buffer.cc b/src/internet/model/tcp-rx-buffer.cc index 6bb9c6068..dda76e070 100644 --- a/src/internet/model/tcp-rx-buffer.cc +++ b/src/internet/model/tcp-rx-buffer.cc @@ -172,7 +172,7 @@ TcpRxBuffer::Add(Ptr p, const TcpHeader& tcph) } } // Remove overlapped bytes from packet - BufIterator i = m_data.begin(); + auto i = m_data.begin(); while (i != m_data.end() && i->first <= tailSeq) { SequenceNumber32 lastByteSeq = i->first + SequenceNumber32(i->second->GetSize()); @@ -204,7 +204,7 @@ TcpRxBuffer::Add(Ptr p, const TcpHeader& tcph) else { uint32_t start = static_cast(headSeq - tcph.GetSequenceNumber()); - uint32_t length = static_cast(tailSeq - headSeq); + auto length = static_cast(tailSeq - headSeq); p = p->CreateFragment(start, length); NS_ASSERT(length == p->GetSize()); } @@ -292,7 +292,7 @@ TcpRxBuffer::UpdateSackList(const SequenceNumber32& head, const SequenceNumber32 // We have inserted the block at the beginning of the list. Now, we should // check if any existing blocks overlap with that. bool updated = false; - TcpOptionSack::SackList::iterator it = m_sackList.begin(); + auto it = m_sackList.begin(); TcpOptionSack::SackBlock begin = *it; TcpOptionSack::SackBlock merged; ++it; @@ -353,8 +353,7 @@ TcpRxBuffer::ClearSackList(const SequenceNumber32& seq) { NS_LOG_FUNCTION(this << seq); - TcpOptionSack::SackList::iterator it; - for (it = m_sackList.begin(); it != m_sackList.end();) + for (auto it = m_sackList.begin(); it != m_sackList.end();) { TcpOptionSack::SackBlock block = *it; NS_ASSERT(block.first < block.second); diff --git a/src/internet/model/tcp-socket-base.cc b/src/internet/model/tcp-socket-base.cc index 4fc36b548..c305f278d 100644 --- a/src/internet/model/tcp-socket-base.cc +++ b/src/internet/model/tcp-socket-base.cc @@ -1851,7 +1851,7 @@ TcpSocketBase::ReceivedAck(Ptr packet, const TcpHeader& tcpHeader) m_txBuffer->DiscardUpTo(ackNumber, MakeCallback(&TcpRateOps::SkbDelivered, m_rateOps)); - uint32_t currentDelivered = + auto currentDelivered = static_cast(m_rateOps->GetConnectionRate().m_delivered - previousDelivered); m_tcb->m_lastAckedSackedBytes = currentDelivered; @@ -3272,7 +3272,7 @@ TcpSocketBase::UpdateRttHistory(const SequenceNumber32& seq, uint32_t sz, bool i } else { // This is a retransmit, find in list and mark as re-tx - for (std::deque::iterator i = m_history.begin(); i != m_history.end(); ++i) + for (auto i = m_history.begin(); i != m_history.end(); ++i) { if ((seq >= i->seq) && (seq < (i->seq + SequenceNumber32(i->count)))) { // Found it @@ -3370,7 +3370,7 @@ TcpSocketBase::SendPendingData(bool withAck) uint32_t s = std::min(availableWindow, m_tcb->m_segmentSize); // NextSeg () may have further constrained the segment size - uint32_t maxSizeToSend = static_cast(nextHigh - next); + auto maxSizeToSend = static_cast(nextHigh - next); s = std::min(s, maxSizeToSend); // (C.2) If any of the data octets sent in (C.1) are below HighData, @@ -4317,8 +4317,8 @@ TcpSocketBase::AddOptionSack(TcpHeader& header) // Append the allowed number of SACK blocks Ptr option = CreateObject(); - TcpOptionSack::SackList::iterator i; - for (i = sackList.begin(); allowedSackBlocks > 0 && i != sackList.end(); ++i) + + for (auto i = sackList.begin(); allowedSackBlocks > 0 && i != sackList.end(); ++i) { option->AddSackBlock(*i); allowedSackBlocks--; diff --git a/src/internet/model/tcp-tx-buffer.cc b/src/internet/model/tcp-tx-buffer.cc index 105833b76..99ff8af00 100644 --- a/src/internet/model/tcp-tx-buffer.cc +++ b/src/internet/model/tcp-tx-buffer.cc @@ -68,16 +68,14 @@ TcpTxBuffer::TcpTxBuffer(uint32_t n) TcpTxBuffer::~TcpTxBuffer() { - PacketList::iterator it; - - for (it = m_sentList.begin(); it != m_sentList.end(); ++it) + for (auto it = m_sentList.begin(); it != m_sentList.end(); ++it) { TcpTxItem* item = *it; m_sentSize -= item->m_packet->GetSize(); delete item; } - for (it = m_appList.begin(); it != m_appList.end(); ++it) + for (auto it = m_appList.begin(); it != m_appList.end(); ++it) { TcpTxItem* item = *it; m_size -= item->m_packet->GetSize(); @@ -189,7 +187,7 @@ TcpTxBuffer::Add(Ptr p) { if (p->GetSize() > 0) { - TcpTxItem* item = new TcpTxItem(); + auto item = new TcpTxItem(); item->m_packet = p->Copy(); m_appList.insert(m_appList.end(), item); m_size += p->GetSize(); @@ -437,7 +435,7 @@ TcpTxBuffer::GetPacketFromList(PacketList& list, Ptr currentPacket = nullptr; TcpTxItem* currentItem = nullptr; TcpTxItem* outItem = nullptr; - PacketList::iterator it = list.begin(); + auto it = list.begin(); SequenceNumber32 beginOfCurrentPacket = listStartFrom; while (it != list.end()) @@ -469,7 +467,7 @@ TcpTxBuffer::GetPacketFromList(PacketList& list, NS_LOG_INFO("we are at " << beginOfCurrentPacket << " searching for " << seq << " and now we recurse because packet ends at " << beginOfCurrentPacket + currentPacket->GetSize()); - TcpTxItem* firstPart = new TcpTxItem(); + auto firstPart = new TcpTxItem(); SplitItems(firstPart, currentItem, seq - beginOfCurrentPacket); // insert firstPart before currentItem @@ -535,7 +533,7 @@ TcpTxBuffer::GetPacketFromList(PacketList& list, { // the end is inside the current packet, but it isn't exactly // the packet end. Just fragment, fix the list, and return. - TcpTxItem* firstPart = new TcpTxItem(); + auto firstPart = new TcpTxItem(); SplitItems(firstPart, currentItem, numBytes); // insert firstPart before currentItem @@ -603,14 +601,14 @@ TcpTxBuffer::MergeItems(TcpTxItem* t1, TcpTxItem* t2) const { if (t1->m_retrans) { - TcpTxBuffer* self = const_cast(this); + auto self = const_cast(this); self->m_retrans -= t1->m_packet->GetSize(); t1->m_retrans = false; } else { NS_ASSERT(t2->m_retrans); - TcpTxBuffer* self = const_cast(this); + auto self = const_cast(this); self->m_retrans -= t2->m_packet->GetSize(); t2->m_retrans = false; } @@ -681,7 +679,7 @@ TcpTxBuffer::DiscardUpTo(const SequenceNumber32& seq, const Callback 0 && offset > 0) { if (i == m_sentList.end()) @@ -790,7 +788,7 @@ TcpTxBuffer::Update(const TcpOptionSack::SackList& list, const Callback= m_highestSack.second) { @@ -938,7 +935,7 @@ TcpTxBuffer::IsLost(const SequenceNumber32& seq) const // In theory, using a map and hints when inserting elements can improve // performance - for (it = m_sentList.begin(); it != m_sentList.end(); ++it) + for (auto it = m_sentList.begin(); it != m_sentList.end(); ++it) { // Search for the right iterator before calling IsLost() if (beginOfCurrentPacket >= seq) @@ -980,13 +977,12 @@ TcpTxBuffer::NextSeg(SequenceNumber32* seq, SequenceNumber32* seqHigh, bool isRe * * (1.c) IsLost (S2) returns true. */ - PacketList::const_iterator it; TcpTxItem* item; SequenceNumber32 seqPerRule3; bool isSeqPerRule3Valid = false; SequenceNumber32 beginOfCurrentPkt = m_firstByteSeq; - for (it = m_sentList.begin(); it != m_sentList.end(); ++it) + for (auto it = m_sentList.begin(); it != m_sentList.end(); ++it) { item = *it; @@ -1092,7 +1088,6 @@ TcpTxBuffer::BytesInFlight() const uint32_t TcpTxBuffer::BytesInFlightRFC() const { - PacketList::const_iterator it; TcpTxItem* item; uint32_t size = 0; // "pipe" in RFC SequenceNumber32 beginOfCurrentPkt = m_firstByteSeq; @@ -1104,7 +1099,7 @@ TcpTxBuffer::BytesInFlightRFC() const // After initializing pipe to zero, the following steps are taken for each // octet 'S1' in the sequence space between HighACK and HighData that has not // been SACKed: - for (it = m_sentList.begin(); it != m_sentList.end(); ++it) + for (auto it = m_sentList.begin(); it != m_sentList.end(); ++it) { item = *it; totalSize += item->m_packet->GetSize(); @@ -1472,14 +1467,13 @@ operator<<(std::ostream& os, const TcpTxItem& item) std::ostream& operator<<(std::ostream& os, const TcpTxBuffer& tcpTxBuf) { - TcpTxBuffer::PacketList::const_iterator it; std::stringstream ss; SequenceNumber32 beginOfCurrentPacket = tcpTxBuf.m_firstByteSeq; uint32_t sentSize = 0; uint32_t appSize = 0; Ptr p; - for (it = tcpTxBuf.m_sentList.begin(); it != tcpTxBuf.m_sentList.end(); ++it) + for (auto it = tcpTxBuf.m_sentList.begin(); it != tcpTxBuf.m_sentList.end(); ++it) { p = (*it)->GetPacket(); ss << "{"; @@ -1489,7 +1483,7 @@ operator<<(std::ostream& os, const TcpTxBuffer& tcpTxBuf) beginOfCurrentPacket += p->GetSize(); } - for (it = tcpTxBuf.m_appList.begin(); it != tcpTxBuf.m_appList.end(); ++it) + for (auto it = tcpTxBuf.m_appList.begin(); it != tcpTxBuf.m_appList.end(); ++it) { appSize += (*it)->GetPacket()->GetSize(); } diff --git a/src/internet/model/tcp-yeah.cc b/src/internet/model/tcp-yeah.cc index 1cc8d1648..f09486a6e 100644 --- a/src/internet/model/tcp-yeah.cc +++ b/src/internet/model/tcp-yeah.cc @@ -249,7 +249,7 @@ TcpYeah::IncreaseWindow(Ptr tcb, uint32_t segmentsAcked) // queue = rttQueue * bw = rttQueue * (cwnd/RTTmin) double bw = segCwnd / m_minRtt.GetSeconds(); - uint32_t queue = static_cast(bw * rttQueue.GetSeconds()); + auto queue = static_cast(bw * rttQueue.GetSeconds()); NS_LOG_DEBUG("Queue backlog = " << queue << " given by cwnd = " << segCwnd << ", minRtt = " << m_minRtt.GetMilliSeconds() << " ms, baseRtt = " << m_baseRtt.GetMilliSeconds() diff --git a/src/internet/model/udp-l4-protocol.cc b/src/internet/model/udp-l4-protocol.cc index 9442b530c..ff290207c 100644 --- a/src/internet/model/udp-l4-protocol.cc +++ b/src/internet/model/udp-l4-protocol.cc @@ -382,8 +382,7 @@ UdpL4Protocol::Receive(Ptr packet, const Ipv4Header& header, PtrRemoveHeader(udpHeader); - for (Ipv4EndPointDemux::EndPointsI endPoint = endPoints.begin(); endPoint != endPoints.end(); - endPoint++) + for (auto endPoint = endPoints.begin(); endPoint != endPoints.end(); endPoint++) { (*endPoint)->ForwardUp(packet->Copy(), header, udpHeader.GetSourcePort(), interface); } @@ -422,8 +421,7 @@ UdpL4Protocol::Receive(Ptr packet, const Ipv6Header& header, PtrForwardUp(packet->Copy(), header, udpHeader.GetSourcePort(), interface); } diff --git a/src/internet/test/global-route-manager-impl-test-suite.cc b/src/internet/test/global-route-manager-impl-test-suite.cc index 991d6652b..0210ed46a 100644 --- a/src/internet/test/global-route-manager-impl-test-suite.cc +++ b/src/internet/test/global-route-manager-impl-test-suite.cc @@ -60,7 +60,7 @@ GlobalRouteManagerImplTestCase::DoRun() for (int i = 0; i < 100; ++i) { - SPFVertex* v = new SPFVertex; + auto v = new SPFVertex; v->SetDistanceFromRoot(std::rand() % 100); candidate.Push(v); } @@ -88,18 +88,17 @@ GlobalRouteManagerImplTestCase::DoRun() // link2: 10.1.3.1/30, 10.1.3.2/30 // // Router 0 - GlobalRoutingLinkRecord* lr0 = - new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, - "0.0.0.2", // router ID 0.0.0.2 - "10.1.1.1", // local ID - 1); // metric + auto lr0 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, + "0.0.0.2", // router ID 0.0.0.2 + "10.1.1.1", // local ID + 1); // metric - GlobalRoutingLinkRecord* lr1 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, - "10.1.1.1", - "255.255.255.252", - 1); + auto lr1 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, + "10.1.1.1", + "255.255.255.252", + 1); - GlobalRoutingLSA* lsa0 = new GlobalRoutingLSA(); + auto lsa0 = new GlobalRoutingLSA(); lsa0->SetLSType(GlobalRoutingLSA::RouterLSA); lsa0->SetLinkStateId("0.0.0.0"); lsa0->SetAdvertisingRouter("0.0.0.0"); @@ -107,18 +106,17 @@ GlobalRouteManagerImplTestCase::DoRun() lsa0->AddLinkRecord(lr1); // Router 1 - GlobalRoutingLinkRecord* lr2 = - new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, - "0.0.0.2", - "10.1.2.1", - 1); + auto lr2 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, + "0.0.0.2", + "10.1.2.1", + 1); - GlobalRoutingLinkRecord* lr3 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, - "10.1.2.1", - "255.255.255.252", - 1); + auto lr3 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, + "10.1.2.1", + "255.255.255.252", + 1); - GlobalRoutingLSA* lsa1 = new GlobalRoutingLSA(); + auto lsa1 = new GlobalRoutingLSA(); lsa1->SetLSType(GlobalRoutingLSA::RouterLSA); lsa1->SetLinkStateId("0.0.0.1"); lsa1->SetAdvertisingRouter("0.0.0.1"); @@ -126,40 +124,37 @@ GlobalRouteManagerImplTestCase::DoRun() lsa1->AddLinkRecord(lr3); // Router 2 - GlobalRoutingLinkRecord* lr4 = - new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, - "0.0.0.0", - "10.1.1.2", - 1); + auto lr4 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, + "0.0.0.0", + "10.1.1.2", + 1); - GlobalRoutingLinkRecord* lr5 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, - "10.1.1.2", - "255.255.255.252", - 1); + auto lr5 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, + "10.1.1.2", + "255.255.255.252", + 1); - GlobalRoutingLinkRecord* lr6 = - new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, - "0.0.0.1", - "10.1.2.2", - 1); + auto lr6 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, + "0.0.0.1", + "10.1.2.2", + 1); - GlobalRoutingLinkRecord* lr7 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, - "10.1.2.2", - "255.255.255.252", - 1); + auto lr7 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, + "10.1.2.2", + "255.255.255.252", + 1); - GlobalRoutingLinkRecord* lr8 = - new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, - "0.0.0.3", - "10.1.3.2", - 1); + auto lr8 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, + "0.0.0.3", + "10.1.3.2", + 1); - GlobalRoutingLinkRecord* lr9 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, - "10.1.3.2", - "255.255.255.252", - 1); + auto lr9 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, + "10.1.3.2", + "255.255.255.252", + 1); - GlobalRoutingLSA* lsa2 = new GlobalRoutingLSA(); + auto lsa2 = new GlobalRoutingLSA(); lsa2->SetLSType(GlobalRoutingLSA::RouterLSA); lsa2->SetLinkStateId("0.0.0.2"); lsa2->SetAdvertisingRouter("0.0.0.2"); @@ -171,19 +166,17 @@ GlobalRouteManagerImplTestCase::DoRun() lsa2->AddLinkRecord(lr9); // Router 3 - GlobalRoutingLinkRecord* lr10 = - new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, - "0.0.0.2", - "10.1.2.1", - 1); + auto lr10 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::PointToPoint, + "0.0.0.2", + "10.1.2.1", + 1); - GlobalRoutingLinkRecord* lr11 = - new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, - "10.1.2.1", - "255.255.255.252", - 1); + auto lr11 = new GlobalRoutingLinkRecord(GlobalRoutingLinkRecord::StubNetwork, + "10.1.2.1", + "255.255.255.252", + 1); - GlobalRoutingLSA* lsa3 = new GlobalRoutingLSA(); + auto lsa3 = new GlobalRoutingLSA(); lsa3->SetLSType(GlobalRoutingLSA::RouterLSA); lsa3->SetLinkStateId("0.0.0.3"); lsa3->SetAdvertisingRouter("0.0.0.3"); @@ -191,7 +184,7 @@ GlobalRouteManagerImplTestCase::DoRun() lsa3->AddLinkRecord(lr11); // Test the database - GlobalRouteManagerLSDB* srmlsdb = new GlobalRouteManagerLSDB(); + auto srmlsdb = new GlobalRouteManagerLSDB(); srmlsdb->Insert(lsa0->GetLinkStateId(), lsa0); srmlsdb->Insert(lsa1->GetLinkStateId(), lsa1); srmlsdb->Insert(lsa2->GetLinkStateId(), lsa2); @@ -201,7 +194,7 @@ GlobalRouteManagerImplTestCase::DoRun() "The Ipv4Address is not stored as the link state ID"); // next, calculate routes based on the manually created LSDB - GlobalRouteManagerImpl* srm = new GlobalRouteManagerImpl(); + auto srm = new GlobalRouteManagerImpl(); srm->DebugUseLsdb(srmlsdb); // manually add in an LSDB // Note-- this will succeed without any nodes in the topology // because the NodeList is empty diff --git a/src/internet/test/ipv4-global-routing-test-suite.cc b/src/internet/test/ipv4-global-routing-test-suite.cc index 5f257af86..9498512fa 100644 --- a/src/internet/test/ipv4-global-routing-test-suite.cc +++ b/src/internet/test/ipv4-global-routing-test-suite.cc @@ -894,9 +894,7 @@ Ipv4DynamicGlobalRoutingTestCase::Ipv4DynamicGlobalRoutingTestCase() Ipv4DynamicGlobalRoutingTestCase::~Ipv4DynamicGlobalRoutingTestCase() { - std::vector, bool>>::iterator iter; - - for (iter = m_sendSocks.begin(); iter != m_sendSocks.end(); iter++) + for (auto iter = m_sendSocks.begin(); iter != m_sendSocks.end(); iter++) { if (iter->second) { diff --git a/src/internet/test/ipv4-rip-test.cc b/src/internet/test/ipv4-rip-test.cc index 1945d02fb..010236c13 100644 --- a/src/internet/test/ipv4-rip-test.cc +++ b/src/internet/test/ipv4-rip-test.cc @@ -558,7 +558,7 @@ Ipv4RipSplitHorizonStrategyTest::ReceivePktProbe(Ptr socket) std::list rtes = hdr.GetRteList(); // validate the RTEs before processing - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { if (iter->GetPrefix() == "10.0.1.0") { diff --git a/src/internet/test/ipv6-ripng-test.cc b/src/internet/test/ipv6-ripng-test.cc index a070fcafc..c378a9ef9 100644 --- a/src/internet/test/ipv6-ripng-test.cc +++ b/src/internet/test/ipv6-ripng-test.cc @@ -556,7 +556,7 @@ Ipv6RipngSplitHorizonStrategyTest::ReceivePktProbe(Ptr socket) std::list rtes = hdr.GetRteList(); // validate the RTEs before processing - for (std::list::iterator iter = rtes.begin(); iter != rtes.end(); iter++) + for (auto iter = rtes.begin(); iter != rtes.end(); iter++) { if (iter->GetPrefix() == "2001:1::") { diff --git a/src/internet/test/tcp-advertised-window-test.cc b/src/internet/test/tcp-advertised-window-test.cc index 292b9d1f4..fb0c0f2cd 100644 --- a/src/internet/test/tcp-advertised-window-test.cc +++ b/src/internet/test/tcp-advertised-window-test.cc @@ -447,7 +447,7 @@ Ptr TcpAdvWindowOnLossTest::CreateReceiverErrorModel() { Ptr m_errorModel = CreateObject(); - for (std::vector::iterator it = m_toDrop.begin(); it != m_toDrop.end(); ++it) + for (auto it = m_toDrop.begin(); it != m_toDrop.end(); ++it) { m_errorModel->AddSeqToKill(SequenceNumber32(*it)); } diff --git a/src/internet/test/tcp-bytes-in-flight-test.cc b/src/internet/test/tcp-bytes-in-flight-test.cc index 59072c56d..526aedf33 100644 --- a/src/internet/test/tcp-bytes-in-flight-test.cc +++ b/src/internet/test/tcp-bytes-in-flight-test.cc @@ -141,7 +141,7 @@ Ptr TcpBytesInFlightTest::CreateReceiverErrorModel() { Ptr m_errorModel = CreateObject(); - for (std::vector::iterator it = m_toDrop.begin(); it != m_toDrop.end(); ++it) + for (auto it = m_toDrop.begin(); it != m_toDrop.end(); ++it) { m_errorModel->AddSeqToKill(SequenceNumber32(*it)); } @@ -236,7 +236,7 @@ TcpBytesInFlightTest::Tx(const Ptr p, const TcpHeader& h, SocketWh { if (who == SENDER) { - static SequenceNumber32 retr = SequenceNumber32(0); + static SequenceNumber32 retr(0); static uint32_t times = 0; if (m_greatestSeqSent <= h.GetSequenceNumber()) diff --git a/src/internet/test/tcp-fast-retr-test.cc b/src/internet/test/tcp-fast-retr-test.cc index 25aeae88d..fb8ee33fd 100644 --- a/src/internet/test/tcp-fast-retr-test.cc +++ b/src/internet/test/tcp-fast-retr-test.cc @@ -443,7 +443,7 @@ class TcpFastRetrTestSuite : public TestSuite types.insert(types.begin(), TcpWestwoodPlus::GetTypeId()); types.insert(types.begin(), TcpNewReno::GetTypeId()); - for (std::list::iterator it = types.begin(); it != types.end(); ++it) + for (auto it = types.begin(); it != types.end(); ++it) { AddTestCase(new TcpFastRetrTest((*it), 5001, "Fast Retransmit testing"), TestCase::QUICK); diff --git a/src/internet/test/tcp-rate-ops-test.cc b/src/internet/test/tcp-rate-ops-test.cc index 6c5f57b19..5ab857265 100644 --- a/src/internet/test/tcp-rate-ops-test.cc +++ b/src/internet/test/tcp-rate-ops-test.cc @@ -343,7 +343,7 @@ Ptr TcpRateLinuxWithSocketsTest::CreateReceiverErrorModel() { Ptr m_errorModel = CreateObject(); - for (std::vector::iterator it = m_toDrop.begin(); it != m_toDrop.end(); ++it) + for (auto it = m_toDrop.begin(); it != m_toDrop.end(); ++it) { m_errorModel->AddSeqToKill(SequenceNumber32(*it)); } diff --git a/src/internet/test/tcp-rtt-estimation.cc b/src/internet/test/tcp-rtt-estimation.cc index 2285ce039..2abc2a939 100644 --- a/src/internet/test/tcp-rtt-estimation.cc +++ b/src/internet/test/tcp-rtt-estimation.cc @@ -232,9 +232,7 @@ TcpRttEstimationWithLossTest::CreateReceiverErrorModel() { Ptr errorModel = CreateObject(); - std::vector::iterator it; - - for (it = m_toDrop.begin(); it != m_toDrop.end(); ++it) + for (auto it = m_toDrop.begin(); it != m_toDrop.end(); ++it) { errorModel->AddSeqToKill(SequenceNumber32((*it))); } diff --git a/src/internet/test/tcp-rx-buffer-test.cc b/src/internet/test/tcp-rx-buffer-test.cc index d64c80d5e..5ba345ca2 100644 --- a/src/internet/test/tcp-rx-buffer-test.cc +++ b/src/internet/test/tcp-rx-buffer-test.cc @@ -60,7 +60,6 @@ TcpRxBufferTestCase::TestUpdateSACKList() { TcpRxBuffer rxBuf; TcpOptionSack::SackList sackList; - TcpOptionSack::SackList::iterator it; Ptr p = Create(100); TcpHeader h; @@ -83,7 +82,7 @@ TcpRxBufferTestCase::TestUpdateSACKList() "Sequence number differs from expected"); sackList = rxBuf.GetSackList(); NS_TEST_ASSERT_MSG_EQ(sackList.size(), 1, "SACK list should contain one element"); - it = sackList.begin(); + auto it = sackList.begin(); NS_TEST_ASSERT_MSG_EQ(it->first, SequenceNumber32(501), "SACK block different than expected"); NS_TEST_ASSERT_MSG_EQ(it->second, SequenceNumber32(601), "SACK block different than expected"); diff --git a/src/internet/test/tcp-test.cc b/src/internet/test/tcp-test.cc index 8a6af9e4f..3024e4bcf 100644 --- a/src/internet/test/tcp-test.cc +++ b/src/internet/test/tcp-test.cc @@ -220,7 +220,7 @@ TcpTestCase::DoRun() m_serverRxPayload = new uint8_t[m_totalBytes]; for (uint32_t i = 0; i < m_totalBytes; ++i) { - uint8_t m = (uint8_t)(97 + (i % 26)); + auto m = (uint8_t)(97 + (i % 26)); m_sourceTxPayload[i] = m; } memset(m_sourceRxPayload, 0, m_totalBytes); diff --git a/src/lr-wpan/examples/lr-wpan-bootstrap.cc b/src/lr-wpan/examples/lr-wpan-bootstrap.cc index 28b17279d..787287219 100644 --- a/src/lr-wpan/examples/lr-wpan-bootstrap.cc +++ b/src/lr-wpan/examples/lr-wpan-bootstrap.cc @@ -381,7 +381,7 @@ main(int argc, char* argv[]) lrWpanHelper.SetExtendedAddresses(lrwpanDevices); // Devices hooks & MAC MLME-scan primitive set - for (NodeContainer::Iterator i = nodes.Begin(); i != nodes.End(); i++) + for (auto i = nodes.Begin(); i != nodes.End(); i++) { Ptr node = *i; Ptr netDevice = node->GetDevice(0); @@ -416,7 +416,7 @@ main(int argc, char* argv[]) } // Coordinator hooks - for (NodeContainer::Iterator i = coordinators.Begin(); i != coordinators.End(); i++) + for (auto i = coordinators.Begin(); i != coordinators.End(); i++) { Ptr coor = *i; Ptr netDevice = coor->GetDevice(0); diff --git a/src/lr-wpan/helper/lr-wpan-helper.cc b/src/lr-wpan/helper/lr-wpan-helper.cc index 0f73ab867..797be0194 100644 --- a/src/lr-wpan/helper/lr-wpan-helper.cc +++ b/src/lr-wpan/helper/lr-wpan-helper.cc @@ -179,7 +179,7 @@ NetDeviceContainer LrWpanHelper::Install(NodeContainer c) { NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { Ptr node = *i; @@ -218,7 +218,7 @@ LrWpanHelper::AssignStreams(NetDeviceContainer c, int64_t stream) { int64_t currentStream = stream; Ptr netDevice; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { netDevice = (*i); Ptr lrwpan = DynamicCast(netDevice); @@ -242,7 +242,7 @@ LrWpanHelper::CreateAssociatedPan(NetDeviceContainer c, uint16_t panId) Mac16Address coordShortAddr; Mac64Address coordExtAddr; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { if (id < 0x0001 || id > 0xFFFD) { @@ -285,7 +285,7 @@ LrWpanHelper::SetExtendedAddresses(NetDeviceContainer c) uint8_t idBuf[8] = {0, 0, 0, 0, 0, 0, 0, 0}; Mac64Address address64; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { Ptr device = DynamicCast(*i); if (device) diff --git a/src/lr-wpan/model/lr-wpan-interference-helper.cc b/src/lr-wpan/model/lr-wpan-interference-helper.cc index beba86404..7c1605be6 100644 --- a/src/lr-wpan/model/lr-wpan-interference-helper.cc +++ b/src/lr-wpan/model/lr-wpan-interference-helper.cc @@ -95,9 +95,8 @@ LrWpanInterferenceHelper::GetSignalPsd() const if (m_dirty) { // Sum up the current interference PSD. - std::set>::const_iterator it; m_signal = Create(m_spectrumModel); - for (it = m_signals.begin(); it != m_signals.end(); ++it) + for (auto it = m_signals.begin(); it != m_signals.end(); ++it) { *m_signal += *(*it); } diff --git a/src/lr-wpan/model/lr-wpan-mac-trailer.cc b/src/lr-wpan/model/lr-wpan-mac-trailer.cc index 47ba4c16b..7827e6fb2 100644 --- a/src/lr-wpan/model/lr-wpan-mac-trailer.cc +++ b/src/lr-wpan/model/lr-wpan-mac-trailer.cc @@ -93,7 +93,7 @@ LrWpanMacTrailer::SetFcs(Ptr p) if (m_calcFcs) { uint16_t size = p->GetSize(); - uint8_t* serial_packet = new uint8_t[size]; + auto serial_packet = new uint8_t[size]; p->CopyData(serial_packet, size); @@ -115,7 +115,7 @@ LrWpanMacTrailer::CheckFcs(Ptr p) { uint16_t checkFcs; uint16_t size = p->GetSize(); - uint8_t* serial_packet = new uint8_t[size]; + auto serial_packet = new uint8_t[size]; p->CopyData(serial_packet, size); diff --git a/src/lr-wpan/model/lr-wpan-mac.cc b/src/lr-wpan/model/lr-wpan-mac.cc index e7ac24e7b..4d6a43f1e 100644 --- a/src/lr-wpan/model/lr-wpan-mac.cc +++ b/src/lr-wpan/model/lr-wpan-mac.cc @@ -848,7 +848,7 @@ LrWpanMac::MlmeSyncRequest(MlmeSyncRequestParams params) NS_LOG_FUNCTION(this); NS_ASSERT(params.m_logCh <= 26 && m_macPanId != 0xffff); - uint64_t symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); // symbols per second + auto symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); // symbols per second // change phy current logical channel Ptr pibAttr = Create(); pibAttr->phyCurrentChannel = params.m_logCh; @@ -1660,7 +1660,7 @@ LrWpanMac::AwaitBeacon() void LrWpanMac::BeaconSearchTimeout() { - uint64_t symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); // symbols per second + auto symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); // symbols per second if (m_numLostBeacons > lrwpan::aMaxLostBeacons) { @@ -1872,8 +1872,8 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) // srcPanId = m_macPanId if only srcAddr field in Data or Command frame,accept frame if // srcPanId=m_macPanId - Ptr originalPkt = p->Copy(); // because we will strip headers - uint64_t symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); // symbols per second + Ptr originalPkt = p->Copy(); // because we will strip headers + auto symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); // symbols per second m_promiscSnifferTrace(originalPkt); m_macPromiscRxTrace(originalPkt); @@ -2667,7 +2667,7 @@ LrWpanMac::AckWaitTimeout() void LrWpanMac::IfsWaitTimeout(Time ifsTime) { - uint64_t symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); + auto symbolRate = (uint64_t)m_phy->GetDataOrSymbolRate(false); Time lifsTime = Seconds((double)m_macLIFSPeriod / symbolRate); Time sifsTime = Seconds((double)m_macSIFSPeriod / symbolRate); @@ -3419,7 +3419,7 @@ LrWpanMac::PlmeSetAttributeConfirm(LrWpanPhyEnumeration status, LrWpanPibAttribu { if (status == LrWpanPhyEnumeration::IEEE_802_15_4_PHY_SUCCESS) { - uint64_t symbolRate = static_cast(m_phy->GetDataOrSymbolRate(false)); + auto symbolRate = static_cast(m_phy->GetDataOrSymbolRate(false)); Time nextScanTime; if (m_scanParams.m_scanType == MLMESCAN_ORPHAN) diff --git a/src/lte/examples/lena-cc-helper.cc b/src/lte/examples/lena-cc-helper.cc index 066cc8fa8..db7ce5d97 100644 --- a/src/lte/examples/lena-cc-helper.cc +++ b/src/lte/examples/lena-cc-helper.cc @@ -44,10 +44,8 @@ main(int argc, char* argv[]) std::map ccm = cch->EquallySpacedCcs(); - std::map::iterator it; - std::cout << " CcMap size " << ccm.size() << std::endl; - for (it = ccm.begin(); it != ccm.end(); it++) + for (auto it = ccm.begin(); it != ccm.end(); it++) { Print(it->second); } diff --git a/src/lte/examples/lena-deactivate-bearer.cc b/src/lte/examples/lena-deactivate-bearer.cc index 01805ed69..466162fd1 100644 --- a/src/lte/examples/lena-deactivate-bearer.cc +++ b/src/lte/examples/lena-deactivate-bearer.cc @@ -69,7 +69,7 @@ main(int argc, char* argv[]) Ptr pgw = epcHelper->GetPgwNode(); // Enable Logging - LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); + auto logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); LogComponentEnable("BearerDeactivateExample", LOG_LEVEL_ALL); LogComponentEnable("LteHelper", logLevel); diff --git a/src/lte/examples/lena-distributed-ffr.cc b/src/lte/examples/lena-distributed-ffr.cc index 599911000..25e15b36d 100644 --- a/src/lte/examples/lena-distributed-ffr.cc +++ b/src/lte/examples/lena-distributed-ffr.cc @@ -45,7 +45,7 @@ PrintGnuplottableUeListToFile(std::string filename) NS_LOG_ERROR("Can't open file " << filename); return; } - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; int nDevs = node->GetNDevices(); @@ -74,7 +74,7 @@ PrintGnuplottableEnbListToFile(std::string filename) NS_LOG_ERROR("Can't open file " << filename); return; } - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; int nDevs = node->GetNDevices(); diff --git a/src/lte/examples/lena-dual-stripe.cc b/src/lte/examples/lena-dual-stripe.cc index 9df5111ea..1bb612ddf 100644 --- a/src/lte/examples/lena-dual-stripe.cc +++ b/src/lte/examples/lena-dual-stripe.cc @@ -158,7 +158,7 @@ FemtocellBlockAllocator::Create() bool FemtocellBlockAllocator::OverlapsWithAnyPrevious(Box box) { - for (std::list::iterator it = m_previousBlocks.begin(); it != m_previousBlocks.end(); ++it) + for (auto it = m_previousBlocks.begin(); it != m_previousBlocks.end(); ++it) { if (AreOverlapping(*it, box)) { @@ -184,7 +184,7 @@ PrintGnuplottableBuildingListToFile(std::string filename) return; } uint32_t index = 0; - for (BuildingList::Iterator it = BuildingList::Begin(); it != BuildingList::End(); ++it) + for (auto it = BuildingList::Begin(); it != BuildingList::End(); ++it) { ++index; Box box = (*it)->GetBoundaries(); @@ -208,7 +208,7 @@ PrintGnuplottableUeListToFile(std::string filename) NS_LOG_ERROR("Can't open file " << filename); return; } - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; int nDevs = node->GetNDevices(); @@ -242,7 +242,7 @@ PrintGnuplottableEnbListToFile(std::string filename) NS_LOG_ERROR("Can't open file " << filename); return; } - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; int nDevs = node->GetNDevices(); @@ -714,7 +714,7 @@ main(int argc, char* argv[]) // forcing initialization so we don't have to wait for Nodes to // start before positions are assigned (which is needed to // output node positions to file and to make AttachToClosestEnb work) - for (NodeContainer::Iterator it = macroUes.Begin(); it != macroUes.End(); ++it) + for (auto it = macroUes.Begin(); it != macroUes.End(); ++it) { (*it)->Initialize(); } diff --git a/src/lte/examples/lena-frequency-reuse.cc b/src/lte/examples/lena-frequency-reuse.cc index 926039584..5d727349a 100644 --- a/src/lte/examples/lena-frequency-reuse.cc +++ b/src/lte/examples/lena-frequency-reuse.cc @@ -41,7 +41,7 @@ PrintGnuplottableUeListToFile(std::string filename) NS_LOG_ERROR("Can't open file " << filename); return; } - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; int nDevs = node->GetNDevices(); @@ -70,7 +70,7 @@ PrintGnuplottableEnbListToFile(std::string filename) NS_LOG_ERROR("Can't open file " << filename); return; } - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; int nDevs = node->GetNDevices(); diff --git a/src/lte/examples/lena-radio-link-failure.cc b/src/lte/examples/lena-radio-link-failure.cc index f37853e9c..f9f8be365 100644 --- a/src/lte/examples/lena-radio-link-failure.cc +++ b/src/lte/examples/lena-radio-link-failure.cc @@ -49,7 +49,7 @@ uint32_t oldByteCounter = 0; //!< Old Byte counter, void PrintUePosition(uint64_t imsi) { - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; int nDevs = node->GetNDevices(); @@ -381,7 +381,7 @@ main(int argc, char* argv[]) if (enableNsLogs) { - LogLevel logLevel = + auto logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_NODE | LOG_PREFIX_TIME | LOG_LEVEL_ALL); LogComponentEnable("LteUeRrc", logLevel); LogComponentEnable("LteUeMac", logLevel); diff --git a/src/lte/helper/lte-global-pathloss-database.cc b/src/lte/helper/lte-global-pathloss-database.cc index 8804dca00..c360712f9 100644 --- a/src/lte/helper/lte-global-pathloss-database.cc +++ b/src/lte/helper/lte-global-pathloss-database.cc @@ -38,14 +38,9 @@ void LteGlobalPathlossDatabase::Print() { NS_LOG_FUNCTION(this); - for (std::map>::const_iterator cellIdIt = - m_pathlossMap.begin(); - cellIdIt != m_pathlossMap.end(); - ++cellIdIt) + for (auto cellIdIt = m_pathlossMap.begin(); cellIdIt != m_pathlossMap.end(); ++cellIdIt) { - for (std::map::const_iterator imsiIt = cellIdIt->second.begin(); - imsiIt != cellIdIt->second.end(); - ++imsiIt) + for (auto imsiIt = cellIdIt->second.begin(); imsiIt != cellIdIt->second.end(); ++imsiIt) { std::cout << "CellId: " << cellIdIt->first << " IMSI: " << imsiIt->first << " pathloss: " << imsiIt->second << " dB" << std::endl; @@ -57,12 +52,12 @@ double LteGlobalPathlossDatabase::GetPathloss(uint16_t cellId, uint64_t imsi) { NS_LOG_FUNCTION(this); - std::map>::iterator cellIt = m_pathlossMap.find(cellId); + auto cellIt = m_pathlossMap.find(cellId); if (cellIt == m_pathlossMap.end()) { return std::numeric_limits::infinity(); } - std::map::iterator ueIt = cellIt->second.find(imsi); + auto ueIt = cellIt->second.find(imsi); if (ueIt == cellIt->second.end()) { return std::numeric_limits::infinity(); diff --git a/src/lte/helper/lte-helper.cc b/src/lte/helper/lte-helper.cc index e2a1cc784..08f1eb978 100644 --- a/src/lte/helper/lte-helper.cc +++ b/src/lte/helper/lte-helper.cc @@ -487,7 +487,7 @@ LteHelper::InstallEnbDevice(NodeContainer c) NS_LOG_FUNCTION(this); Initialize(); // will run DoInitialize () if necessary NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr device = InstallSingleEnbDevice(node); @@ -501,7 +501,7 @@ LteHelper::InstallUeDevice(NodeContainer c) { NS_LOG_FUNCTION(this); NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr device = InstallSingleUeDevice(node); @@ -531,8 +531,7 @@ LteHelper::InstallSingleEnbDevice(Ptr n) << ")"); // create component carrier map for this eNb device std::map> ccMap; - for (std::map::iterator it = m_componentCarrierPhyParams.begin(); - it != m_componentCarrierPhyParams.end(); + for (auto it = m_componentCarrierPhyParams.begin(); it != m_componentCarrierPhyParams.end(); ++it) { Ptr cc = CreateObject(); @@ -752,7 +751,7 @@ LteHelper::InstallSingleEnbDevice(Ptr n) dev->SetAttribute("CellId", UintegerValue(cellId)); dev->SetAttribute("LteEnbComponentCarrierManager", PointerValue(ccmEnbManager)); dev->SetCcMap(ccMap); - std::map>::iterator it = ccMap.begin(); + auto it = ccMap.begin(); dev->SetAttribute("LteEnbRrc", PointerValue(rrc)); dev->SetAttribute("LteHandoverAlgorithm", PointerValue(handoverAlgorithm)); dev->SetAttribute( @@ -848,8 +847,7 @@ LteHelper::InstallSingleUeDevice(Ptr n) << ")"); std::map> ueCcMap; - for (std::map::iterator it = m_componentCarrierPhyParams.begin(); - it != m_componentCarrierPhyParams.end(); + for (auto it = m_componentCarrierPhyParams.begin(); it != m_componentCarrierPhyParams.end(); ++it) { Ptr cc = CreateObject(); @@ -867,9 +865,7 @@ LteHelper::InstallSingleUeDevice(Ptr n) // CC map is not needed anymore m_componentCarrierPhyParams.clear(); - for (std::map>::iterator it = ueCcMap.begin(); - it != ueCcMap.end(); - ++it) + for (auto it = ueCcMap.begin(); it != ueCcMap.end(); ++it) { Ptr dlPhy = CreateObject(); Ptr ulPhy = CreateObject(); @@ -971,9 +967,7 @@ LteHelper::InstallSingleUeDevice(Ptr n) nas->SetAsSapProvider(rrc->GetAsSapProvider()); rrc->SetAsSapUser(nas->GetAsSapUser()); - for (std::map>::iterator it = ueCcMap.begin(); - it != ueCcMap.end(); - ++it) + for (auto it = ueCcMap.begin(); it != ueCcMap.end(); ++it) { rrc->SetLteUeCmacSapProvider(it->second->GetMac()->GetLteUeCmacSapProvider(), it->first); it->second->GetMac()->SetLteUeCmacSapUser(rrc->GetLteUeCmacSapUser(it->first)); @@ -1009,9 +1003,7 @@ LteHelper::InstallSingleUeDevice(Ptr n) // when the default PDP context is created. This is a simplification. dev->SetAddress(Mac64Address::Allocate()); - for (std::map>::iterator it = ueCcMap.begin(); - it != ueCcMap.end(); - ++it) + for (auto it = ueCcMap.begin(); it != ueCcMap.end(); ++it) { Ptr ccPhy = it->second->GetPhy(); ccPhy->SetDevice(dev); @@ -1047,7 +1039,7 @@ void LteHelper::Attach(NetDeviceContainer ueDevices) { NS_LOG_FUNCTION(this); - for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i) + for (auto i = ueDevices.Begin(); i != ueDevices.End(); ++i) { Attach(*i); } @@ -1089,7 +1081,7 @@ void LteHelper::Attach(NetDeviceContainer ueDevices, Ptr enbDevice) { NS_LOG_FUNCTION(this); - for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i) + for (auto i = ueDevices.Begin(); i != ueDevices.End(); ++i) { Attach(*i, enbDevice); } @@ -1130,7 +1122,7 @@ void LteHelper::AttachToClosestEnb(NetDeviceContainer ueDevices, NetDeviceContainer enbDevices) { NS_LOG_FUNCTION(this); - for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i) + for (auto i = ueDevices.Begin(); i != ueDevices.End(); ++i) { AttachToClosestEnb(*i, enbDevices); } @@ -1144,7 +1136,7 @@ LteHelper::AttachToClosestEnb(Ptr ueDevice, NetDeviceContainer enbDev Vector uepos = ueDevice->GetNode()->GetObject()->GetPosition(); double minDistance = std::numeric_limits::infinity(); Ptr closestEnbDevice; - for (NetDeviceContainer::Iterator i = enbDevices.Begin(); i != enbDevices.End(); ++i) + for (auto i = enbDevices.Begin(); i != enbDevices.End(); ++i) { Vector enbpos = (*i)->GetNode()->GetObject()->GetPosition(); double distance = CalculateDistance(uepos, enbpos); @@ -1164,7 +1156,7 @@ LteHelper::ActivateDedicatedEpsBearer(NetDeviceContainer ueDevices, Ptr tft) { NS_LOG_FUNCTION(this); - for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i) + for (auto i = ueDevices.Begin(); i != ueDevices.End(); ++i) { uint8_t bearerId = ActivateDedicatedEpsBearer(*i, bearer, tft); return bearerId; @@ -1324,9 +1316,9 @@ LteHelper::AddX2Interface(NodeContainer enbNodes) NS_ASSERT_MSG(m_epcHelper, "X2 interfaces cannot be set up when the EPC is not used"); - for (NodeContainer::Iterator i = enbNodes.Begin(); i != enbNodes.End(); ++i) + for (auto i = enbNodes.Begin(); i != enbNodes.End(); ++i) { - for (NodeContainer::Iterator j = i + 1; j != enbNodes.End(); ++j) + for (auto j = i + 1; j != enbNodes.End(); ++j) { AddX2Interface(*i, *j); } @@ -1444,7 +1436,7 @@ void LteHelper::ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer) { NS_LOG_FUNCTION(this); - for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i) + for (auto i = ueDevices.Begin(); i != ueDevices.End(); ++i) { ActivateDataRadioBearer(*i, bearer); } @@ -1585,15 +1577,14 @@ LteHelper::AssignStreams(NetDeviceContainer c, int64_t stream) } } Ptr netDevice; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { netDevice = (*i); Ptr lteEnb = DynamicCast(netDevice); if (lteEnb) { std::map> tmpMap = lteEnb->GetCcMap(); - std::map>::iterator it; - it = tmpMap.begin(); + auto it = tmpMap.begin(); Ptr dlPhy = DynamicCast(it->second)->GetPhy()->GetDownlinkSpectrumPhy(); Ptr ulPhy = @@ -1605,8 +1596,7 @@ LteHelper::AssignStreams(NetDeviceContainer c, int64_t stream) if (lteUe) { std::map> tmpMap = lteUe->GetCcMap(); - std::map>::iterator it; - it = tmpMap.begin(); + auto it = tmpMap.begin(); Ptr dlPhy = it->second->GetPhy()->GetDownlinkSpectrumPhy(); Ptr ulPhy = it->second->GetPhy()->GetUplinkSpectrumPhy(); Ptr ueMac = lteUe->GetMac(); diff --git a/src/lte/helper/no-backhaul-epc-helper.cc b/src/lte/helper/no-backhaul-epc-helper.cc index 0c7648bef..e66ef52ce 100644 --- a/src/lte/helper/no-backhaul-epc-helper.cc +++ b/src/lte/helper/no-backhaul-epc-helper.cc @@ -540,7 +540,7 @@ NoBackhaulEpcHelper::AssignUeIpv4Address(NetDeviceContainer ueDevices) Ipv6InterfaceContainer NoBackhaulEpcHelper::AssignUeIpv6Address(NetDeviceContainer ueDevices) { - for (NetDeviceContainer::Iterator iter = ueDevices.Begin(); iter != ueDevices.End(); iter++) + for (auto iter = ueDevices.Begin(); iter != ueDevices.End(); iter++) { Ptr icmpv6 = (*iter)->GetNode()->GetObject(); icmpv6->SetAttribute("DAD", BooleanValue(false)); diff --git a/src/lte/helper/radio-bearer-stats-calculator.cc b/src/lte/helper/radio-bearer-stats-calculator.cc index 55d639cd5..8ac0d00c0 100644 --- a/src/lte/helper/radio-bearer-stats-calculator.cc +++ b/src/lte/helper/radio-bearer-stats-calculator.cc @@ -189,7 +189,7 @@ RadioBearerStatsCalculator::UlRxPdu(uint16_t cellId, m_ulRxPackets[p]++; m_ulRxData[p] += packetSize; - Uint64StatsMap::iterator it = m_ulDelay.find(p); + auto it = m_ulDelay.find(p); if (it == m_ulDelay.end()) { NS_LOG_DEBUG(this << " Creating UL stats calculators for IMSI " << p.m_imsi @@ -220,7 +220,7 @@ RadioBearerStatsCalculator::DlRxPdu(uint16_t cellId, m_dlRxPackets[p]++; m_dlRxData[p] += packetSize; - Uint64StatsMap::iterator it = m_dlDelay.find(p); + auto it = m_dlDelay.find(p); if (it == m_dlDelay.end()) { NS_LOG_DEBUG(this << " Creating DL stats calculators for IMSI " << p.m_imsi @@ -298,7 +298,7 @@ RadioBearerStatsCalculator::WriteUlResults(std::ofstream& outFile) // Get the unique IMSI/LCID pairs list std::vector pairVector; - for (Uint32Map::iterator it = m_ulTxPackets.begin(); it != m_ulTxPackets.end(); ++it) + for (auto it = m_ulTxPackets.begin(); it != m_ulTxPackets.end(); ++it) { if (find(pairVector.begin(), pairVector.end(), (*it).first) == pairVector.end()) { @@ -306,7 +306,7 @@ RadioBearerStatsCalculator::WriteUlResults(std::ofstream& outFile) } } - for (Uint32Map::iterator it = m_ulRxPackets.begin(); it != m_ulRxPackets.end(); ++it) + for (auto it = m_ulRxPackets.begin(); it != m_ulRxPackets.end(); ++it) { if (find(pairVector.begin(), pairVector.end(), (*it).first) == pairVector.end()) { @@ -315,11 +315,10 @@ RadioBearerStatsCalculator::WriteUlResults(std::ofstream& outFile) } Time endTime = m_startTime + m_epochDuration; - for (std::vector::iterator it = pairVector.begin(); it != pairVector.end(); - ++it) + for (auto it = pairVector.begin(); it != pairVector.end(); ++it) { ImsiLcidPair_t p = *it; - FlowIdMap::const_iterator flowIdIt = m_flowId.find(p); + auto flowIdIt = m_flowId.find(p); NS_ASSERT_MSG(flowIdIt != m_flowId.end(), "FlowId (imsi " << p.m_imsi << " lcid " << (uint32_t)p.m_lcId << ") is missing"); @@ -337,12 +336,12 @@ RadioBearerStatsCalculator::WriteUlResults(std::ofstream& outFile) outFile << GetUlRxPackets(p.m_imsi, p.m_lcId) << "\t"; outFile << GetUlRxData(p.m_imsi, p.m_lcId) << "\t"; std::vector stats = GetUlDelayStats(p.m_imsi, p.m_lcId); - for (std::vector::iterator it = stats.begin(); it != stats.end(); ++it) + for (auto it = stats.begin(); it != stats.end(); ++it) { outFile << (*it) * 1e-9 << "\t"; } stats = GetUlPduSizeStats(p.m_imsi, p.m_lcId); - for (std::vector::iterator it = stats.begin(); it != stats.end(); ++it) + for (auto it = stats.begin(); it != stats.end(); ++it) { outFile << (*it) << "\t"; } @@ -359,7 +358,7 @@ RadioBearerStatsCalculator::WriteDlResults(std::ofstream& outFile) // Get the unique IMSI/LCID pairs list std::vector pairVector; - for (Uint32Map::iterator it = m_dlTxPackets.begin(); it != m_dlTxPackets.end(); ++it) + for (auto it = m_dlTxPackets.begin(); it != m_dlTxPackets.end(); ++it) { if (find(pairVector.begin(), pairVector.end(), (*it).first) == pairVector.end()) { @@ -367,7 +366,7 @@ RadioBearerStatsCalculator::WriteDlResults(std::ofstream& outFile) } } - for (Uint32Map::iterator it = m_dlRxPackets.begin(); it != m_dlRxPackets.end(); ++it) + for (auto it = m_dlRxPackets.begin(); it != m_dlRxPackets.end(); ++it) { if (find(pairVector.begin(), pairVector.end(), (*it).first) == pairVector.end()) { @@ -376,11 +375,10 @@ RadioBearerStatsCalculator::WriteDlResults(std::ofstream& outFile) } Time endTime = m_startTime + m_epochDuration; - for (std::vector::iterator pair = pairVector.begin(); pair != pairVector.end(); - ++pair) + for (auto pair = pairVector.begin(); pair != pairVector.end(); ++pair) { ImsiLcidPair_t p = *pair; - FlowIdMap::const_iterator flowIdIt = m_flowId.find(p); + auto flowIdIt = m_flowId.find(p); NS_ASSERT_MSG(flowIdIt != m_flowId.end(), "FlowId (imsi " << p.m_imsi << " lcid " << (uint32_t)p.m_lcId << ") is missing"); @@ -398,12 +396,12 @@ RadioBearerStatsCalculator::WriteDlResults(std::ofstream& outFile) outFile << GetDlRxPackets(p.m_imsi, p.m_lcId) << "\t"; outFile << GetDlRxData(p.m_imsi, p.m_lcId) << "\t"; std::vector stats = GetDlDelayStats(p.m_imsi, p.m_lcId); - for (std::vector::iterator it = stats.begin(); it != stats.end(); ++it) + for (auto it = stats.begin(); it != stats.end(); ++it) { outFile << (*it) * 1e-9 << "\t"; } stats = GetDlPduSizeStats(p.m_imsi, p.m_lcId); - for (std::vector::iterator it = stats.begin(); it != stats.end(); ++it) + for (auto it = stats.begin(); it != stats.end(); ++it) { outFile << (*it) << "\t"; } @@ -492,7 +490,7 @@ RadioBearerStatsCalculator::GetUlDelay(uint64_t imsi, uint8_t lcid) { NS_LOG_FUNCTION(this << imsi << (uint16_t)lcid); ImsiLcidPair_t p(imsi, lcid); - Uint64StatsMap::iterator it = m_ulDelay.find(p); + auto it = m_ulDelay.find(p); if (it == m_ulDelay.end()) { NS_LOG_ERROR("UL delay for " << imsi << " - " << (uint16_t)lcid << " not found"); @@ -507,7 +505,7 @@ RadioBearerStatsCalculator::GetUlDelayStats(uint64_t imsi, uint8_t lcid) NS_LOG_FUNCTION(this << imsi << (uint16_t)lcid); ImsiLcidPair_t p(imsi, lcid); std::vector stats; - Uint64StatsMap::iterator it = m_ulDelay.find(p); + auto it = m_ulDelay.find(p); if (it == m_ulDelay.end()) { stats.push_back(0.0); @@ -529,7 +527,7 @@ RadioBearerStatsCalculator::GetUlPduSizeStats(uint64_t imsi, uint8_t lcid) NS_LOG_FUNCTION(this << imsi << (uint16_t)lcid); ImsiLcidPair_t p(imsi, lcid); std::vector stats; - Uint32StatsMap::iterator it = m_ulPduSize.find(p); + auto it = m_ulPduSize.find(p); if (it == m_ulPduSize.end()) { stats.push_back(0.0); @@ -598,7 +596,7 @@ RadioBearerStatsCalculator::GetDlDelay(uint64_t imsi, uint8_t lcid) { NS_LOG_FUNCTION(this << imsi << (uint16_t)lcid); ImsiLcidPair_t p(imsi, lcid); - Uint64StatsMap::iterator it = m_dlDelay.find(p); + auto it = m_dlDelay.find(p); if (it == m_dlDelay.end()) { NS_LOG_ERROR("DL delay for " << imsi << " not found"); @@ -613,7 +611,7 @@ RadioBearerStatsCalculator::GetDlDelayStats(uint64_t imsi, uint8_t lcid) NS_LOG_FUNCTION(this << imsi << (uint16_t)lcid); ImsiLcidPair_t p(imsi, lcid); std::vector stats; - Uint64StatsMap::iterator it = m_dlDelay.find(p); + auto it = m_dlDelay.find(p); if (it == m_dlDelay.end()) { stats.push_back(0.0); @@ -635,7 +633,7 @@ RadioBearerStatsCalculator::GetDlPduSizeStats(uint64_t imsi, uint8_t lcid) NS_LOG_FUNCTION(this << imsi << (uint16_t)lcid); ImsiLcidPair_t p(imsi, lcid); std::vector stats; - Uint32StatsMap::iterator it = m_dlPduSize.find(p); + auto it = m_dlPduSize.find(p); if (it == m_dlPduSize.end()) { stats.push_back(0.0); diff --git a/src/lte/helper/radio-bearer-stats-connector.cc b/src/lte/helper/radio-bearer-stats-connector.cc index 8087eda10..42d073c23 100644 --- a/src/lte/helper/radio-bearer-stats-connector.cc +++ b/src/lte/helper/radio-bearer-stats-connector.cc @@ -259,7 +259,7 @@ RadioBearerStatsConnector::ConnectTracesSrb0(std::string context, CellIdRnti key; key.cellId = cellId; key.rnti = rnti; - std::map::iterator it = m_ueManagerPathByCellIdRnti.find(key); + auto it = m_ueManagerPathByCellIdRnti.find(key); NS_ASSERT(it != m_ueManagerPathByCellIdRnti.end()); std::string ueManagerPath = it->second; NS_LOG_LOGIC("ueManagerPath = " << ueManagerPath); @@ -290,7 +290,7 @@ RadioBearerStatsConnector::ConnectTracesSrb1(std::string context, CellIdRnti key; key.cellId = cellId; key.rnti = rnti; - std::map::iterator it = m_ueManagerPathByCellIdRnti.find(key); + auto it = m_ueManagerPathByCellIdRnti.find(key); NS_ASSERT(it != m_ueManagerPathByCellIdRnti.end()); std::string ueManagerPath = it->second; NS_LOG_LOGIC("ueManagerPath = " << ueManagerPath); diff --git a/src/lte/helper/radio-environment-map-helper.cc b/src/lte/helper/radio-environment-map-helper.cc index ace923ab1..fbec81832 100644 --- a/src/lte/helper/radio-environment-map-helper.cc +++ b/src/lte/helper/radio-environment-map-helper.cc @@ -306,7 +306,7 @@ void RadioEnvironmentMapHelper::RunOneIteration(double xMin, double xMax, double yMin, double yMax) { NS_LOG_FUNCTION(this << xMin << xMax << yMin << yMax); - std::list::iterator remIt = m_rem.begin(); + auto remIt = m_rem.begin(); double x = 0.0; double y = 0.0; for (x = xMin; x < xMax + 0.5 * m_xStep; x += m_xStep) @@ -342,7 +342,7 @@ RadioEnvironmentMapHelper::PrintAndReset() { NS_LOG_FUNCTION(this); - for (std::list::iterator it = m_rem.begin(); it != m_rem.end(); ++it) + for (auto it = m_rem.begin(); it != m_rem.end(); ++it) { if (!(it->phy->IsActive())) { diff --git a/src/lte/model/a2-a4-rsrq-handover-algorithm.cc b/src/lte/model/a2-a4-rsrq-handover-algorithm.cc index 0b0f93d37..46b0012c4 100644 --- a/src/lte/model/a2-a4-rsrq-handover-algorithm.cc +++ b/src/lte/model/a2-a4-rsrq-handover-algorithm.cc @@ -149,8 +149,7 @@ A2A4RsrqHandoverAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults { if (measResults.haveMeasResultNeighCells && !measResults.measResultListEutra.empty()) { - for (std::list::iterator it = - measResults.measResultListEutra.begin(); + for (auto it = measResults.measResultListEutra.begin(); it != measResults.measResultListEutra.end(); ++it) { @@ -177,8 +176,7 @@ A2A4RsrqHandoverAlgorithm::EvaluateHandover(uint16_t rnti, uint8_t servingCellRs { NS_LOG_FUNCTION(this << rnti << (uint16_t)servingCellRsrq); - MeasurementTable_t::iterator it1; - it1 = m_neighbourCellMeasures.find(rnti); + auto it1 = m_neighbourCellMeasures.find(rnti); if (it1 == m_neighbourCellMeasures.end()) { @@ -191,8 +189,7 @@ A2A4RsrqHandoverAlgorithm::EvaluateHandover(uint16_t rnti, uint8_t servingCellRs NS_LOG_LOGIC("Number of neighbour cells = " << it1->second.size()); uint16_t bestNeighbourCellId = 0; uint8_t bestNeighbourRsrq = 0; - MeasurementRow_t::iterator it2; - for (it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) + for (auto it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) { if ((it2->second->m_rsrq > bestNeighbourRsrq) && IsValidNeighbour(it2->first)) { @@ -239,23 +236,20 @@ void A2A4RsrqHandoverAlgorithm::UpdateNeighbourMeasurements(uint16_t rnti, uint16_t cellId, uint8_t rsrq) { NS_LOG_FUNCTION(this << rnti << cellId << (uint16_t)rsrq); - MeasurementTable_t::iterator it1; - it1 = m_neighbourCellMeasures.find(rnti); + auto it1 = m_neighbourCellMeasures.find(rnti); if (it1 == m_neighbourCellMeasures.end()) { // insert a new UE entry MeasurementRow_t row; - std::pair ret; - ret = m_neighbourCellMeasures.insert(std::pair(rnti, row)); + auto ret = m_neighbourCellMeasures.insert(std::pair(rnti, row)); NS_ASSERT(ret.second); it1 = ret.first; } NS_ASSERT(it1 != m_neighbourCellMeasures.end()); Ptr neighbourCellMeasures; - std::map>::iterator it2; - it2 = it1->second.find(cellId); + auto it2 = it1->second.find(cellId); if (it2 != it1->second.end()) { diff --git a/src/lte/model/a3-rsrp-handover-algorithm.cc b/src/lte/model/a3-rsrp-handover-algorithm.cc index 32e117b62..fb15c6ff4 100644 --- a/src/lte/model/a3-rsrp-handover-algorithm.cc +++ b/src/lte/model/a3-rsrp-handover-algorithm.cc @@ -135,8 +135,7 @@ A3RsrpHandoverAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults me uint16_t bestNeighbourCellId = 0; uint8_t bestNeighbourRsrp = 0; - for (std::list::iterator it = - measResults.measResultListEutra.begin(); + for (auto it = measResults.measResultListEutra.begin(); it != measResults.measResultListEutra.end(); ++it) { diff --git a/src/lte/model/cqa-ff-mac-scheduler.cc b/src/lte/model/cqa-ff-mac-scheduler.cc index d15a254a4..d04b27c47 100644 --- a/src/lte/model/cqa-ff-mac-scheduler.cc +++ b/src/lte/model/cqa-ff-mac-scheduler.cc @@ -248,7 +248,7 @@ CqaFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -300,9 +300,7 @@ CqaFfMacScheduler::DoCschedLcConfigReq( // LTE MAC scheduler specification if (params.m_reconfigureFlag) { - std::vector::const_iterator lcit; - - for (lcit = params.m_logicalChannelConfigList.begin(); + for (auto lcit = params.m_logicalChannelConfigList.begin(); lcit != params.m_logicalChannelConfigList.end(); lcit++) { @@ -322,9 +320,7 @@ CqaFfMacScheduler::DoCschedLcConfigReq( } // else new UE is added else { - std::vector::const_iterator lcit; - - for (lcit = params.m_logicalChannelConfigList.begin(); + for (auto lcit = params.m_logicalChannelConfigList.begin(); lcit != params.m_logicalChannelConfigList.end(); lcit++) { @@ -334,11 +330,9 @@ CqaFfMacScheduler::DoCschedLcConfigReq( } } - std::map::iterator it; - for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -382,9 +376,9 @@ CqaFfMacScheduler::DoCschedLcReleaseReq( const FfMacCschedSapProvider::CschedLcReleaseReqParameters& params) { NS_LOG_FUNCTION(this); - std::vector::const_iterator it; - for (it = params.m_logicalChannelIdentity.begin(); it != params.m_logicalChannelIdentity.end(); + for (auto it = params.m_logicalChannelIdentity.begin(); + it != params.m_logicalChannelIdentity.end(); it++) { LteFlowId_t flowId = LteFlowId_t(params.m_rnti, *it); @@ -404,15 +398,13 @@ CqaFfMacScheduler::DoCschedLcReleaseReq( for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -453,14 +445,12 @@ CqaFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -482,11 +472,9 @@ CqaFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -533,9 +521,8 @@ CqaFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int CqaFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -556,13 +543,12 @@ CqaFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -586,13 +572,12 @@ CqaFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -621,8 +606,7 @@ CqaFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -632,8 +616,7 @@ CqaFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -667,7 +650,6 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( int numberOfRBGs = m_cschedCellConfig.m_dlBandwidth / rbgSize; std::map> allocationMapPerRntiPerLCId; - std::map>::iterator itMap; allocationMapPerRntiPerLCId.clear(); bool (*key_function_pointer_groups)(int, int) = CqaGroupDescComparator; t_map_HOLgroupToUEs map_GBRHOLgroupToUE(key_function_pointer_groups); @@ -681,7 +663,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); rbgMap = m_ffrSapProvider->GetAvailableDlRbg(); - for (std::vector::iterator it = rbgMap.begin(); it != rbgMap.end(); it++) + for (auto it = rbgMap.begin(); it != rbgMap.end(); it++) { if (*it) { @@ -691,9 +673,9 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -709,7 +691,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( uint16_t tmpFfrRbStartOffset = 0; uint16_t index = 0; - for (std::vector::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++) + for (auto it = ulRbMap.begin(); it != ulRbMap.end(); it++) { if (*it) { @@ -740,8 +722,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; rbStart = ffrRbStartOffset; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -805,15 +786,13 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -855,7 +834,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -883,8 +862,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -905,16 +883,14 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1001,8 +977,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -1079,8 +1054,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -1093,15 +1067,14 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -1127,13 +1100,11 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( return; } - std::map::iterator itLogicalChannels; - - for (itLogicalChannels = m_ueLogicalChannelsConfigList.begin(); + for (auto itLogicalChannels = m_ueLogicalChannelsConfigList.begin(); itLogicalChannels != m_ueLogicalChannelsConfigList.end(); itLogicalChannels++) { - std::set::iterator itRnti = rntiAllocated.find(itLogicalChannels->first.m_rnti); + auto itRnti = rntiAllocated.find(itLogicalChannels->first.m_rnti); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability(itLogicalChannels->first.m_rnti))) { @@ -1151,8 +1122,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::map::iterator - itRlcBufferReq = m_rlcBufferReq.find(itLogicalChannels->first); + auto itRlcBufferReq = m_rlcBufferReq.find(itLogicalChannels->first); if (itRlcBufferReq == m_rlcBufferReq.end()) { continue; @@ -1219,17 +1189,12 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( // channels) that belong to the same RNTI std::map sbCqiSum; - for (std::map::iterator - itrbr = m_rlcBufferReq.begin(); - itrbr != m_rlcBufferReq.end(); - itrbr++) + for (auto itrbr = m_rlcBufferReq.begin(); itrbr != m_rlcBufferReq.end(); itrbr++) { LteFlowId_t flowId = itrbr->first; // Prepare data for the scheduling mechanism // check first the channel conditions for this UE, if CQI!=0 - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itrbr).first.m_rnti); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itrbr).first.m_rnti); + auto itCqi = m_a30CqiRxed.find((*itrbr).first.m_rnti); + auto itTxMode = m_uesTxMode.find((*itrbr).first.m_rnti); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itrbr).first.m_rnti); @@ -1270,10 +1235,8 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( uint8_t sum = 0; for (int i = 0; i < numberOfRBGs; i++) { - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itrbr).first.m_rnti); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itrbr).first.m_rnti); + auto itCqi = m_a30CqiRxed.find((*itrbr).first.m_rnti); + auto itTxMode = m_uesTxMode.find((*itrbr).first.m_rnti); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itrbr).first.m_rnti); @@ -1329,8 +1292,8 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( } } - t_it_HOLgroupToUEs itGBRgroups = map_GBRHOLgroupToUE.begin(); - t_it_HOLgroupToUEs itnonGBRgroups = map_nonGBRHOLgroupToUE.begin(); + auto itGBRgroups = map_GBRHOLgroupToUE.begin(); + auto itnonGBRgroups = map_nonGBRHOLgroupToUE.begin(); // while there are more resources available, loop through the users that are grouped by HOL // value @@ -1377,9 +1340,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( // Iterate through the users and calculate which user will use the best of the current // resource block.end() and assign to that user. - for (std::set::iterator it = itCurrentGroup->second.begin(); - it != itCurrentGroup->second.end(); - it++) + for (auto it = itCurrentGroup->second.begin(); it != itCurrentGroup->second.end(); it++) { LteFlowId_t flowId = *it; uint8_t cqi_value = 1; // higher better, maximum is 15 @@ -1390,10 +1351,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( int numberOfRBGAllocatedForThisUser = 0; LogicalChannelConfigListElement_s lc = m_ueLogicalChannelsConfigList.find(flowId)->second; - std::map::iterator itRntiCQIsMap = - m_a30CqiRxed.find(flowId.m_rnti); - - std::map::iterator itStats; + auto itRntiCQIsMap = m_a30CqiRxed.find(flowId.m_rnti); if (!m_ffrSapProvider->IsDlRbgAvailableForUe(currentRB, flowId.m_rnti)) { @@ -1406,7 +1364,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( } currentRBchecked = true; - itStats = m_flowStatsDl.find(flowId.m_rnti); + auto itStats = m_flowStatsDl.find(flowId.m_rnti); double tbr_weight = (*itStats).second.targetThroughput / (*itStats).second.lastAveragedThroughput; if (tbr_weight < 1.0) @@ -1416,9 +1374,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( if (itRntiCQIsMap != m_a30CqiRxed.end()) { - for (std::set::iterator it = availableRBGs.begin(); - it != availableRBGs.end(); - it++) + for (auto it = availableRBGs.begin(); it != availableRBGs.end(); it++) { try { @@ -1459,7 +1415,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( numberOfRBGAllocatedForThisUser = (allocationMapPerRntiPerLCId.find(flowId.m_rnti)->second.size()); - for (std::multimap::iterator itRBG = + for (auto itRBG = allocationMapPerRntiPerLCId.find(flowId.m_rnti)->second.begin(); itRBG != allocationMapPerRntiPerLCId.find(flowId.m_rnti)->second.end(); itRBG++) @@ -1561,7 +1517,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( s.cqi_value_for_lc = UeToCQIValue.find(userWithMaximumMetric)->second; s.resource_block_index = currentRB; - itMap = allocationMapPerRntiPerLCId.find(userWithMaximumMetric.m_rnti); + auto itMap = allocationMapPerRntiPerLCId.find(userWithMaximumMetric.m_rnti); if (itMap == allocationMapPerRntiPerLCId.end()) { @@ -1595,8 +1551,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( } // while there are more groups of users // reset TTI stats of users - std::map::iterator itStats; - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.lastTtiBytesTransmitted = 0; } @@ -1604,7 +1559,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( // 3) Creating the correspondent DCIs (Generate the transmission opportunities by grouping the // RBGs of the same RNTI) // FfMacSchedSapUser::SchedDlConfigIndParameters ret; - itMap = allocationMapPerRntiPerLCId.begin(); + auto itMap = allocationMapPerRntiPerLCId.begin(); std::map m_rnti_per_ratio; while (itMap != allocationMapPerRntiPerLCId.end()) @@ -1629,15 +1584,10 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( double doubleRbgNum = numberOfRBGs; double rrRatio = doubleRBgPerRnti / doubleRbgNum; m_rnti_per_ratio.insert(std::pair((*itMap).first, rrRatio)); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMap).first); uint8_t worstCqi = 15; // assign the worst value of CQI that user experienced on any of its subbands - for (std::multimap::iterator it = - (*itMap).second.begin(); - it != (*itMap).second.end(); - it++) + for (auto it = (*itMap).second.begin(); it != (*itMap).second.end(); it++) { if (it->second.cqi_value_for_lc < worstCqi) { @@ -1652,8 +1602,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( newDci.m_resAlloc = 0; // only allocation type 0 at this stage newDci.m_rbBitmap = 0; // TBD (32 bit bitmap see 7.1.6 of 36.213) uint32_t rbgMask = 0; - std::multimap::iterator itRBGsPerRNTI; - for (itRBGsPerRNTI = (*itMap).second.begin(); itRBGsPerRNTI != (*itMap).second.end(); + for (auto itRBGsPerRNTI = (*itMap).second.begin(); itRBGsPerRNTI != (*itMap).second.end(); itRBGsPerRNTI++) { rbgMask = rbgMask + (0x1 << itRBGsPerRNTI->second.resource_block_index); @@ -1661,9 +1610,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // NOTE: In this first version of CqaFfMacScheduler, it is assumed one flow per user. // create the rlc PDUs -> equally divide resources among active LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1686,8 +1633,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1717,8 +1663,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1726,8 +1671,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1739,8 +1683,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( ret.m_buildDataList.push_back(newEl); // update UE stats - std::map::iterator it; - it = m_flowStatsDl.find((*itMap).first); + auto it = m_flowStatsDl.find((*itMap).first); if (it != m_flowStatsDl.end()) { (*it).second.lastTtiBytesTransmitted = tbSize; @@ -1756,7 +1699,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( // update UEs stats NS_LOG_INFO(this << " Update UEs statistics"); - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { if (allocationMapPerRntiPerLCId.find(itStats->first) != allocationMapPerRntiPerLCId.end()) { @@ -1779,8 +1722,7 @@ CqaFfMacScheduler::DoSchedDlTriggerReq( m_schedSapUser->SchedDlConfigInd(ret); int count_allocated_resource_blocks = 0; - for (std::map>::iterator itMap = - allocationMapPerRntiPerLCId.begin(); + for (auto itMap = allocationMapPerRntiPerLCId.begin(); itMap != allocationMapPerRntiPerLCId.end(); itMap++) { @@ -1811,9 +1753,8 @@ CqaFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1828,17 +1769,15 @@ CqaFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1851,8 +1790,7 @@ CqaFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1866,7 +1804,7 @@ CqaFfMacScheduler::DoSchedDlCqiInfoReq( double CqaFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1919,7 +1857,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( rbMap = m_ffrSapProvider->GetAvailableUlRbg(); - for (std::vector::iterator it = rbMap.begin(); it != rbMap.end(); it++) + for (auto it = rbMap.begin(); it != rbMap.end(); it++) { if (*it) { @@ -1949,8 +1887,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1958,16 +1895,14 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -2027,7 +1962,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -2060,7 +1995,6 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( } int rbAllocated = 0; - std::map::iterator itStats; if (m_nextRntiUl != 0) { for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) @@ -2082,7 +2016,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -2175,7 +2109,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( break; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -2246,15 +2180,13 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -2262,8 +2194,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -2279,7 +2210,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( << (uint16_t)harqId); // update TTI UE stats - itStats = m_flowStatsUl.find((*it).first); + auto itStats = m_flowStatsUl.find((*it).first); if (itStats != m_flowStatsUl.end()) { (*itStats).second.lastTtiBytesTransmitted = uldci.m_tbSize; @@ -2305,7 +2236,7 @@ CqaFfMacScheduler::DoSchedUlTriggerReq( // Update global UE stats // update UEs stats - for (itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) + for (auto itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) { (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTransmitted; // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term @@ -2342,8 +2273,6 @@ CqaFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -2364,7 +2293,7 @@ CqaFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -2410,11 +2339,9 @@ CqaFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -2423,7 +2350,7 @@ CqaFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2453,8 +2380,7 @@ CqaFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2477,8 +2403,7 @@ CqaFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2505,8 +2430,7 @@ CqaFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2526,7 +2450,7 @@ void CqaFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -2534,12 +2458,12 @@ CqaFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -2551,7 +2475,7 @@ CqaFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -2559,12 +2483,12 @@ CqaFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -2580,7 +2504,7 @@ void CqaFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -2588,13 +2512,13 @@ CqaFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -2609,9 +2533,8 @@ CqaFfMacScheduler::RefreshUlCqiMaps() void CqaFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2666,7 +2589,7 @@ void CqaFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/epc-enb-application.cc b/src/lte/model/epc-enb-application.cc index 0b48d5c41..3f9c011b0 100644 --- a/src/lte/model/epc-enb-application.cc +++ b/src/lte/model/epc-enb-application.cc @@ -164,9 +164,7 @@ EpcEnbApplication::DoPathSwitchRequest(EpcEnbS1SapProvider::PathSwitchRequestPar uint16_t gci = params.cellId; std::list erabToBeSwitchedInDownlinkList; - for (std::list::iterator bit = - params.bearersToBeSwitched.begin(); - bit != params.bearersToBeSwitched.end(); + for (auto bit = params.bearersToBeSwitched.begin(); bit != params.bearersToBeSwitched.end(); ++bit) { EpsFlowId_t flowId; @@ -193,12 +191,10 @@ void EpcEnbApplication::DoUeContextRelease(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map>::iterator rntiIt = m_rbidTeidMap.find(rnti); + auto rntiIt = m_rbidTeidMap.find(rnti); if (rntiIt != m_rbidTeidMap.end()) { - for (std::map::iterator bidIt = rntiIt->second.begin(); - bidIt != rntiIt->second.end(); - ++bidIt) + for (auto bidIt = rntiIt->second.begin(); bidIt != rntiIt->second.end(); ++bidIt) { uint32_t teid = bidIt->second; m_teidRbidMap.erase(teid); @@ -218,13 +214,11 @@ EpcEnbApplication::DoInitialContextSetupRequest( NS_LOG_FUNCTION(this); uint64_t imsi = mmeUeS1Id; - std::map::iterator imsiIt = m_imsiRntiMap.find(imsi); + auto imsiIt = m_imsiRntiMap.find(imsi); NS_ASSERT_MSG(imsiIt != m_imsiRntiMap.end(), "unknown IMSI"); uint16_t rnti = imsiIt->second; - for (std::list::iterator erabIt = erabToBeSetupList.begin(); - erabIt != erabToBeSetupList.end(); - ++erabIt) + for (auto erabIt = erabToBeSetupList.begin(); erabIt != erabToBeSetupList.end(); ++erabIt) { // request the RRC to setup a radio bearer EpcEnbS1SapUser::DataRadioBearerSetupRequestParameters params; @@ -256,7 +250,7 @@ EpcEnbApplication::DoPathSwitchRequestAcknowledge( NS_LOG_FUNCTION(this); uint64_t imsi = mmeUeS1Id; - std::map::iterator imsiIt = m_imsiRntiMap.find(imsi); + auto imsiIt = m_imsiRntiMap.find(imsi); NS_ASSERT_MSG(imsiIt != m_imsiRntiMap.end(), "unknown IMSI"); uint16_t rnti = imsiIt->second; EpcEnbS1SapUser::PathSwitchRequestAcknowledgeParameters params; @@ -284,14 +278,14 @@ EpcEnbApplication::RecvFromLteSocket(Ptr socket) uint16_t rnti = tag.GetRnti(); uint8_t bid = tag.GetBid(); NS_LOG_LOGIC("received packet with RNTI=" << (uint32_t)rnti << ", BID=" << (uint32_t)bid); - std::map>::iterator rntiIt = m_rbidTeidMap.find(rnti); + auto rntiIt = m_rbidTeidMap.find(rnti); if (rntiIt == m_rbidTeidMap.end()) { NS_LOG_WARN("UE context not found, discarding packet"); } else { - std::map::iterator bidIt = rntiIt->second.find(bid); + auto bidIt = rntiIt->second.find(bid); NS_ASSERT(bidIt != rntiIt->second.end()); uint32_t teid = bidIt->second; m_rxLteSocketPktTrace(packet->Copy()); @@ -308,7 +302,7 @@ EpcEnbApplication::RecvFromS1uSocket(Ptr socket) GtpuHeader gtpu; packet->RemoveHeader(gtpu); uint32_t teid = gtpu.GetTeid(); - std::map::iterator it = m_teidRbidMap.find(teid); + auto it = m_teidRbidMap.find(teid); if (it == m_teidRbidMap.end()) { NS_LOG_WARN("UE context at cell id " << m_cellId << " not found, discarding packet"); diff --git a/src/lte/model/epc-mme-application.cc b/src/lte/model/epc-mme-application.cc index eb70b4e55..8b8156ae7 100644 --- a/src/lte/model/epc-mme-application.cc +++ b/src/lte/model/epc-mme-application.cc @@ -103,7 +103,7 @@ uint8_t EpcMmeApplication::AddBearer(uint64_t imsi, Ptr tft, EpsBearer bearer) { NS_LOG_FUNCTION(this << imsi); - std::map>::iterator it = m_ueInfoMap.find(imsi); + auto it = m_ueInfoMap.find(imsi); NS_ASSERT_MSG(it != m_ueInfoMap.end(), "could not find any UE with IMSI " << imsi); NS_ASSERT_MSG(it->second->bearerCounter < 11, "too many bearers already! " << it->second->bearerCounter); @@ -124,7 +124,7 @@ EpcMmeApplication::DoInitialUeMessage(uint64_t mmeUeS1Id, uint16_t gci) { NS_LOG_FUNCTION(this << mmeUeS1Id << enbUeS1Id << imsi << gci); - std::map>::iterator it = m_ueInfoMap.find(imsi); + auto it = m_ueInfoMap.find(imsi); NS_ASSERT_MSG(it != m_ueInfoMap.end(), "could not find any UE with IMSI " << imsi); it->second->cellId = gci; @@ -139,7 +139,7 @@ EpcMmeApplication::DoInitialUeMessage(uint64_t mmeUeS1Id, msg.SetSenderCpFteid(mmeS11Fteid); // S11 MME GTP-C F-TEID std::list bearerContexts; - for (std::list::iterator bit = it->second->bearersToBeActivated.begin(); + for (auto bit = it->second->bearersToBeActivated.begin(); bit != it->second->bearersToBeActivated.end(); ++bit) { @@ -180,7 +180,7 @@ EpcMmeApplication::DoPathSwitchRequest( { NS_LOG_FUNCTION(this << mmeUeS1Id << enbUeS1Id << gci); uint64_t imsi = mmeUeS1Id; - std::map>::iterator it = m_ueInfoMap.find(imsi); + auto it = m_ueInfoMap.find(imsi); NS_ASSERT_MSG(it != m_ueInfoMap.end(), "could not find any UE with IMSI " << imsi); NS_LOG_INFO("IMSI " << imsi << " old eNB: " << it->second->cellId << ", new eNB: " << gci); it->second->cellId = gci; @@ -221,7 +221,7 @@ EpcMmeApplication::DoErabReleaseIndication( { NS_LOG_FUNCTION(this << mmeUeS1Id << enbUeS1Id); uint64_t imsi = mmeUeS1Id; - std::map>::iterator it = m_ueInfoMap.find(imsi); + auto it = m_ueInfoMap.find(imsi); NS_ASSERT_MSG(it != m_ueInfoMap.end(), "could not find any UE with IMSI " << imsi); GtpcDeleteBearerCommandMessage msg; @@ -247,7 +247,7 @@ void EpcMmeApplication::RemoveBearer(Ptr ueInfo, uint8_t epsBearerId) { NS_LOG_FUNCTION(this << epsBearerId); - std::list::iterator bit = ueInfo->bearersToBeActivated.begin(); + auto bit = ueInfo->bearersToBeActivated.begin(); while (bit != ueInfo->bearersToBeActivated.end()) { if (bit->bearerId == epsBearerId) @@ -296,13 +296,13 @@ EpcMmeApplication::DoRecvCreateSessionResponse(GtpcHeader& header, Ptr p NS_LOG_FUNCTION(this << header); uint64_t imsi = header.GetTeid(); NS_LOG_DEBUG("TEID/IMSI " << imsi); - std::map>::iterator it = m_ueInfoMap.find(imsi); + auto it = m_ueInfoMap.find(imsi); NS_ASSERT_MSG(it != m_ueInfoMap.end(), "could not find any UE with IMSI " << imsi); uint16_t cellId = it->second->cellId; uint16_t enbUeS1Id = it->second->enbUeS1Id; uint64_t mmeUeS1Id = it->second->mmeUeS1Id; NS_LOG_DEBUG("cellId " << cellId << " mmeUeS1Id " << mmeUeS1Id << " enbUeS1Id " << enbUeS1Id); - std::map>::iterator jt = m_enbInfoMap.find(cellId); + auto jt = m_enbInfoMap.find(cellId); NS_ASSERT_MSG(jt != m_enbInfoMap.end(), "could not find any eNB with CellId " << cellId); GtpcCreateSessionResponseMessage msg; @@ -337,7 +337,7 @@ EpcMmeApplication::DoRecvModifyBearerResponse(GtpcHeader& header, Ptr pa uint64_t imsi = header.GetTeid(); NS_LOG_DEBUG("TEID/IMSI " << imsi); - std::map>::iterator it = m_ueInfoMap.find(imsi); + auto it = m_ueInfoMap.find(imsi); NS_ASSERT_MSG(it != m_ueInfoMap.end(), "could not find any UE with IMSI " << imsi); uint16_t cellId = it->second->cellId; uint16_t enbUeS1Id = it->second->enbUeS1Id; @@ -345,7 +345,7 @@ EpcMmeApplication::DoRecvModifyBearerResponse(GtpcHeader& header, Ptr pa NS_LOG_DEBUG("cellId " << cellId << " mmeUeS1Id " << mmeUeS1Id << " enbUeS1Id " << enbUeS1Id); std::list erabToBeSwitchedInUplinkList; // unused for now - std::map>::iterator jt = m_enbInfoMap.find(cellId); + auto jt = m_enbInfoMap.find(cellId); NS_ASSERT_MSG(jt != m_enbInfoMap.end(), "could not find any eNB with CellId " << cellId); NS_LOG_DEBUG("Send PathSwitchRequestAcknowledge to eNB " << jt->second->s1apSapEnb); @@ -361,7 +361,7 @@ EpcMmeApplication::DoRecvDeleteBearerRequest(GtpcHeader& header, Ptr pac NS_LOG_FUNCTION(this << header); uint64_t imsi = header.GetTeid(); NS_LOG_DEBUG("TEID/IMSI " << imsi); - std::map>::iterator it = m_ueInfoMap.find(imsi); + auto it = m_ueInfoMap.find(imsi); NS_ASSERT_MSG(it != m_ueInfoMap.end(), "could not find any UE with IMSI " << imsi); GtpcDeleteBearerRequestMessage msg; diff --git a/src/lte/model/epc-pgw-application.cc b/src/lte/model/epc-pgw-application.cc index f5805ff84..2038b301c 100644 --- a/src/lte/model/epc-pgw-application.cc +++ b/src/lte/model/epc-pgw-application.cc @@ -58,7 +58,7 @@ void EpcPgwApplication::UeInfo::RemoveBearer(uint8_t bearerId) { NS_LOG_FUNCTION(this << (uint16_t)bearerId); - std::map::iterator it = m_teidByBearerIdMap.find(bearerId); + auto it = m_teidByBearerIdMap.find(bearerId); m_tftClassifier.Delete(it->second); // delete tft m_teidByBearerIdMap.erase(bearerId); } @@ -180,7 +180,7 @@ EpcPgwApplication::RecvFromTunDevice(Ptr packet, NS_LOG_LOGIC("packet addressed to UE " << ueAddr); // find corresponding UeInfo address - std::map>::iterator it = m_ueInfoByAddrMap.find(ueAddr); + auto it = m_ueInfoByAddrMap.find(ueAddr); if (it == m_ueInfoByAddrMap.end()) { NS_LOG_WARN("unknown UE address " << ueAddr); @@ -207,7 +207,7 @@ EpcPgwApplication::RecvFromTunDevice(Ptr packet, NS_LOG_LOGIC("packet addressed to UE " << ueAddr); // find corresponding UeInfo address - std::map>::iterator it = m_ueInfoByAddrMap6.find(ueAddr); + auto it = m_ueInfoByAddrMap6.find(ueAddr); if (it == m_ueInfoByAddrMap6.end()) { NS_LOG_WARN("unknown UE address " << ueAddr); @@ -298,7 +298,7 @@ EpcPgwApplication::DoRecvCreateSessionRequest(Ptr packet) uint16_t cellId = msg.GetUliEcgi(); NS_LOG_DEBUG("cellId " << cellId << " IMSI " << imsi); - std::map>::iterator ueit = m_ueInfoByImsiMap.find(imsi); + auto ueit = m_ueInfoByImsiMap.find(imsi); NS_ASSERT_MSG(ueit != m_ueInfoByImsiMap.end(), "unknown IMSI " << imsi); ueit->second->SetSgwAddr(m_sgwS5Addr); @@ -360,7 +360,7 @@ EpcPgwApplication::DoRecvModifyBearerRequest(Ptr packet) uint16_t cellId = msg.GetUliEcgi(); NS_LOG_DEBUG("cellId " << cellId << " IMSI " << imsi); - std::map>::iterator ueit = m_ueInfoByImsiMap.find(imsi); + auto ueit = m_ueInfoByImsiMap.find(imsi); NS_ASSERT_MSG(ueit != m_ueInfoByImsiMap.end(), "unknown IMSI " << imsi); ueit->second->SetSgwAddr(m_sgwS5Addr); @@ -422,7 +422,7 @@ EpcPgwApplication::DoRecvDeleteBearerResponse(Ptr packet) packet->RemoveHeader(msg); uint64_t imsi = msg.GetTeid(); - std::map>::iterator ueit = m_ueInfoByImsiMap.find(imsi); + auto ueit = m_ueInfoByImsiMap.find(imsi); NS_ASSERT_MSG(ueit != m_ueInfoByImsiMap.end(), "unknown IMSI " << imsi); for (auto& epsBearerId : msg.GetEpsBearerIds()) @@ -498,7 +498,7 @@ void EpcPgwApplication::SetUeAddress(uint64_t imsi, Ipv4Address ueAddr) { NS_LOG_FUNCTION(this << imsi << ueAddr); - std::map>::iterator ueit = m_ueInfoByImsiMap.find(imsi); + auto ueit = m_ueInfoByImsiMap.find(imsi); NS_ASSERT_MSG(ueit != m_ueInfoByImsiMap.end(), "unknown IMSI" << imsi); ueit->second->SetUeAddr(ueAddr); m_ueInfoByAddrMap[ueAddr] = ueit->second; @@ -508,7 +508,7 @@ void EpcPgwApplication::SetUeAddress6(uint64_t imsi, Ipv6Address ueAddr) { NS_LOG_FUNCTION(this << imsi << ueAddr); - std::map>::iterator ueit = m_ueInfoByImsiMap.find(imsi); + auto ueit = m_ueInfoByImsiMap.find(imsi); NS_ASSERT_MSG(ueit != m_ueInfoByImsiMap.end(), "unknown IMSI " << imsi); m_ueInfoByAddrMap6[ueAddr] = ueit->second; ueit->second->SetUeAddr6(ueAddr); diff --git a/src/lte/model/epc-sgw-application.cc b/src/lte/model/epc-sgw-application.cc index c02c2c7db..35009c480 100644 --- a/src/lte/model/epc-sgw-application.cc +++ b/src/lte/model/epc-sgw-application.cc @@ -235,7 +235,7 @@ EpcSgwApplication::DoRecvCreateSessionRequest(Ptr packet) uint16_t cellId = msg.GetUliEcgi(); NS_LOG_DEBUG("cellId " << cellId << " IMSI " << imsi); - std::map::iterator enbit = m_enbInfoByCellId.find(cellId); + auto enbit = m_enbInfoByCellId.find(cellId); NS_ASSERT_MSG(enbit != m_enbInfoByCellId.end(), "unknown CellId " << cellId); Ipv4Address enbAddr = enbit->second.enbAddr; NS_LOG_DEBUG("eNB " << enbAddr); @@ -301,7 +301,7 @@ EpcSgwApplication::DoRecvModifyBearerRequest(Ptr packet) uint16_t cellId = msg.GetUliEcgi(); NS_LOG_DEBUG("cellId " << cellId << " IMSI " << imsi); - std::map::iterator enbit = m_enbInfoByCellId.find(cellId); + auto enbit = m_enbInfoByCellId.find(cellId); NS_ASSERT_MSG(enbit != m_enbInfoByCellId.end(), "unknown CellId " << cellId); Ipv4Address enbAddr = enbit->second.enbAddr; NS_LOG_DEBUG("eNB " << enbAddr); @@ -321,7 +321,7 @@ EpcSgwApplication::DoRecvModifyBearerRequest(Ptr packet) uint32_t teid = bearerContext.fteid.teid; Ipv4Address enbAddr = bearerContext.fteid.addr; NS_LOG_DEBUG("bearerId " << (uint16_t)bearerContext.epsBearerId << " TEID " << teid); - std::map::iterator addrit = m_enbByTeidMap.find(teid); + auto addrit = m_enbByTeidMap.find(teid); NS_ASSERT_MSG(addrit != m_enbByTeidMap.end(), "unknown TEID " << teid); addrit->second = enbAddr; GtpcModifyBearerRequestMessage::BearerContextToBeModified bearerContextOut; diff --git a/src/lte/model/epc-tft-classifier.cc b/src/lte/model/epc-tft-classifier.cc index d0d9b31e2..b527f2fda 100644 --- a/src/lte/model/epc-tft-classifier.cc +++ b/src/lte/model/epc-tft-classifier.cc @@ -187,9 +187,7 @@ EpcTftClassifier::Classify(Ptr p, EpcTft::Direction direction, uint16_t protocol, ipv4Header.GetIdentification()); - std::map, - std::pair>::iterator it = - m_classifiedIpv4Fragments.find(fragmentKey); + auto it = m_classifiedIpv4Fragments.find(fragmentKey); if (it != m_classifiedIpv4Fragments.end()) { diff --git a/src/lte/model/epc-tft.cc b/src/lte/model/epc-tft.cc index efccd9f0b..a04336b30 100644 --- a/src/lte/model/epc-tft.cc +++ b/src/lte/model/epc-tft.cc @@ -265,7 +265,7 @@ EpcTft::Matches(Direction direction, { NS_LOG_FUNCTION(this << direction << remoteAddress << localAddress << std::dec << remotePort << localPort << (uint16_t)typeOfService); - for (std::list::iterator it = m_filters.begin(); it != m_filters.end(); ++it) + for (auto it = m_filters.begin(); it != m_filters.end(); ++it) { if (it->Matches(direction, remoteAddress, @@ -290,7 +290,7 @@ EpcTft::Matches(Direction direction, { NS_LOG_FUNCTION(this << direction << remoteAddress << localAddress << std::dec << remotePort << localPort << (uint16_t)typeOfService); - for (std::list::iterator it = m_filters.begin(); it != m_filters.end(); ++it) + for (auto it = m_filters.begin(); it != m_filters.end(); ++it) { if (it->Matches(direction, remoteAddress, diff --git a/src/lte/model/epc-ue-nas.cc b/src/lte/model/epc-ue-nas.cc index b00ba3246..7101b4361 100644 --- a/src/lte/model/epc-ue-nas.cc +++ b/src/lte/model/epc-ue-nas.cc @@ -206,7 +206,7 @@ EpcUeNas::Send(Ptr packet, uint16_t protocolNumber) case ACTIVE: { uint32_t id = m_tftClassifier.Classify(packet, EpcTft::UPLINK, protocolNumber); NS_ASSERT((id & 0xFFFFFF00) == 0); - uint8_t bid = (uint8_t)(id & 0x000000FF); + auto bid = (uint8_t)(id & 0x000000FF); if (bid == 0) { return false; @@ -295,8 +295,7 @@ EpcUeNas::SwitchToState(State newState) switch (m_state) { case ACTIVE: - for (std::list::iterator it = m_bearersToBeActivatedList.begin(); - it != m_bearersToBeActivatedList.end(); + for (auto it = m_bearersToBeActivatedList.begin(); it != m_bearersToBeActivatedList.end(); m_bearersToBeActivatedList.erase(it++)) { DoActivateEpsBearer(it->bearer, it->tft); diff --git a/src/lte/model/epc-x2-header.cc b/src/lte/model/epc-x2-header.cc index 94e064299..82c53c80a 100644 --- a/src/lte/model/epc-x2-header.cc +++ b/src/lte/model/epc-x2-header.cc @@ -1209,8 +1209,7 @@ EpcX2LoadInformationHeader::Deserialize(Buffer::Iterator start) m_headerLength += 2; for (int k = 0; k < sz2; k++) { - EpcX2Sap::UlInterferenceOverloadIndicationItem item = - (EpcX2Sap::UlInterferenceOverloadIndicationItem)i.ReadU8(); + auto item = (EpcX2Sap::UlInterferenceOverloadIndicationItem)i.ReadU8(); cellInfoItem.ulInterferenceOverloadIndicationList.push_back(item); } m_headerLength += sz2; diff --git a/src/lte/model/fdbet-ff-mac-scheduler.cc b/src/lte/model/fdbet-ff-mac-scheduler.cc index 78de191a5..72b4710d3 100644 --- a/src/lte/model/fdbet-ff-mac-scheduler.cc +++ b/src/lte/model/fdbet-ff-mac-scheduler.cc @@ -159,7 +159,7 @@ FdBetFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -205,10 +205,9 @@ FdBetFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::map::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -235,15 +234,13 @@ FdBetFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -273,14 +270,12 @@ FdBetFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -302,11 +297,9 @@ FdBetFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -353,9 +346,8 @@ FdBetFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int FdBetFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -376,13 +368,12 @@ FdBetFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -406,13 +397,12 @@ FdBetFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -441,8 +431,7 @@ FdBetFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -452,8 +441,7 @@ FdBetFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -493,9 +481,9 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -504,8 +492,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -569,15 +556,13 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -619,7 +604,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -647,8 +632,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -669,16 +653,14 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -765,8 +747,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -843,8 +824,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -857,15 +837,14 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -891,15 +870,13 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( return; } - std::map::iterator itFlow; std::map estAveThr; // store expected average throughput for UE - std::map::iterator itMax = estAveThr.end(); - std::map::iterator it; + auto itMax = estAveThr.end(); std::map rbgPerRntiLog; // record the number of RBG assigned to UE double metricMax = 0.0; - for (itFlow = m_flowStatsDl.begin(); itFlow != m_flowStatsDl.end(); itFlow++) + for (auto itFlow = m_flowStatsDl.begin(); itFlow != m_flowStatsDl.end(); itFlow++) { - std::set::iterator itRnti = rntiAllocated.find((*itFlow).first); + auto itRnti = rntiAllocated.find((*itFlow).first); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*itFlow).first))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -915,10 +892,8 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( } // check first what are channel conditions for this UE, if CQI!=0 - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*itFlow).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itFlow).first); + auto itCqi = m_p10CqiRxed.find((*itFlow).first); + auto itTxMode = m_uesTxMode.find((*itFlow).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itFlow).first); @@ -951,7 +926,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( if (!estAveThr.empty()) { // Find UE with largest priority metric - for (it = estAveThr.begin(); it != estAveThr.end(); it++) + for (auto it = estAveThr.begin(); it != estAveThr.end(); it++) { double metric = 1 / (*it).second; if (metric > metricMax) @@ -970,9 +945,8 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( if (!rbgMap.at(i)) { // allocate one RBG to current UE - std::map>::iterator itMap; std::vector tempMap; - itMap = allocationMap.find((*itMax).first); + auto itMap = allocationMap.find((*itMax).first); if (itMap == allocationMap.end()) { tempMap.push_back(i); @@ -985,10 +959,8 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( } // calculate expected throughput for current UE - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*itMax).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMax).first); + auto itCqi = m_p10CqiRxed.find((*itMax).first); + auto itTxMode = m_uesTxMode.find((*itMax).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMax).first); @@ -1007,10 +979,8 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( } } - std::map::iterator itRbgPerRntiLog; - itRbgPerRntiLog = rbgPerRntiLog.find((*itMax).first); - std::map::iterator itPastAveThr; - itPastAveThr = m_flowStatsDl.find((*itMax).first); + auto itRbgPerRntiLog = rbgPerRntiLog.find((*itMax).first); + auto itPastAveThr = m_flowStatsDl.find((*itMax).first); uint32_t bytesTxed = 0; for (uint8_t j = 0; j < nLayer; j++) { @@ -1030,7 +1000,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( // find new UE with largest priority metric metricMax = 0.0; - for (it = estAveThr.begin(); it != estAveThr.end(); it++) + for (auto it = estAveThr.begin(); it != estAveThr.end(); it++) { double metric = 1 / (*it).second; if (metric > metricMax) @@ -1051,15 +1021,14 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( } // end if estAveThr // reset TTI stats of users - std::map::iterator itStats; - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.lastTtiBytesTrasmitted = 0; } // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -1078,10 +1047,8 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_p10CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1117,9 +1084,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1141,8 +1106,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1171,8 +1135,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1180,8 +1143,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1193,8 +1155,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( ret.m_buildDataList.push_back(newEl); // update UE stats - std::map::iterator it; - it = m_flowStatsDl.find((*itMap).first); + auto it = m_flowStatsDl.find((*itMap).first); if (it != m_flowStatsDl.end()) { (*it).second.lastTtiBytesTrasmitted = bytesTxed; @@ -1211,7 +1172,7 @@ FdBetFfMacScheduler::DoSchedDlTriggerReq( // update UEs stats NS_LOG_INFO(this << " Update UEs statistics"); - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted; // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term @@ -1248,9 +1209,8 @@ FdBetFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1265,17 +1225,15 @@ FdBetFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1288,8 +1246,7 @@ FdBetFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1303,7 +1260,7 @@ FdBetFfMacScheduler::DoSchedDlCqiInfoReq( double FdBetFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1370,8 +1327,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1379,16 +1335,14 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1446,7 +1400,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1476,7 +1430,6 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( } int rbAllocated = 0; - std::map::iterator itStats; if (m_nextRntiUl != 0) { for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) @@ -1498,7 +1451,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1583,7 +1536,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( return; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1654,15 +1607,13 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1670,8 +1621,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1687,7 +1637,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( << (uint16_t)harqId); // update TTI UE stats - itStats = m_flowStatsUl.find((*it).first); + auto itStats = m_flowStatsUl.find((*it).first); if (itStats != m_flowStatsUl.end()) { (*itStats).second.lastTtiBytesTrasmitted = uldci.m_tbSize; @@ -1713,7 +1663,7 @@ FdBetFfMacScheduler::DoSchedUlTriggerReq( // Update global UE stats // update UEs stats - for (itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) + for (auto itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) { (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted; // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term @@ -1750,8 +1700,6 @@ FdBetFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1772,7 +1720,7 @@ FdBetFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1818,11 +1766,9 @@ FdBetFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -1831,7 +1777,7 @@ FdBetFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1861,8 +1807,7 @@ FdBetFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1883,8 +1828,7 @@ FdBetFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1911,8 +1855,7 @@ FdBetFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1932,7 +1875,7 @@ void FdBetFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -1940,12 +1883,12 @@ FdBetFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -1957,7 +1900,7 @@ FdBetFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -1965,12 +1908,12 @@ FdBetFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -1986,7 +1929,7 @@ void FdBetFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -1994,13 +1937,13 @@ FdBetFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -2015,9 +1958,8 @@ FdBetFfMacScheduler::RefreshUlCqiMaps() void FdBetFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2072,7 +2014,7 @@ void FdBetFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/fdmt-ff-mac-scheduler.cc b/src/lte/model/fdmt-ff-mac-scheduler.cc index 65bed846c..e87a04b85 100644 --- a/src/lte/model/fdmt-ff-mac-scheduler.cc +++ b/src/lte/model/fdmt-ff-mac-scheduler.cc @@ -158,7 +158,7 @@ FdMtFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -204,10 +204,9 @@ FdMtFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::set::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -224,15 +223,13 @@ FdMtFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -262,14 +259,12 @@ FdMtFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -291,11 +286,9 @@ FdMtFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -342,9 +335,8 @@ FdMtFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int FdMtFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -365,13 +357,12 @@ FdMtFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -395,13 +386,12 @@ FdMtFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -430,8 +420,7 @@ FdMtFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -441,8 +430,7 @@ FdMtFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -482,9 +470,9 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -493,8 +481,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -558,15 +545,13 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -608,7 +593,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -636,8 +621,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -658,16 +642,14 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -754,8 +736,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -832,8 +813,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -846,15 +826,14 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -885,12 +864,11 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( NS_LOG_INFO(this << " ALLOCATION for RBG " << i << " of " << rbgNum); if (!rbgMap.at(i)) { - std::set::iterator it; - std::set::iterator itMax = m_flowStatsDl.end(); + auto itMax = m_flowStatsDl.end(); double rcqiMax = 0.0; - for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) + for (auto it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it)); + auto itRnti = rntiAllocated.find((*it)); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it)))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -905,10 +883,8 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*it)); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it)); + auto itCqi = m_a30CqiRxed.find((*it)); + auto itTxMode = m_uesTxMode.find((*it)); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it)); @@ -975,8 +951,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( else { rbgMap.at(i) = true; - std::map>::iterator itMap; - itMap = allocationMap.find((*itMax)); + auto itMap = allocationMap.find((*itMax)); if (itMap == allocationMap.end()) { // insert new element @@ -996,7 +971,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -1015,10 +990,8 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_a30CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1101,9 +1074,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1125,8 +1096,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1155,8 +1125,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1164,8 +1133,7 @@ FdMtFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1205,9 +1173,8 @@ FdMtFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1222,17 +1189,15 @@ FdMtFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1245,8 +1210,7 @@ FdMtFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1260,7 +1224,7 @@ FdMtFfMacScheduler::DoSchedDlCqiInfoReq( double FdMtFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1327,8 +1291,7 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1336,16 +1299,14 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1403,7 +1364,7 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1454,7 +1415,7 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1539,7 +1500,7 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( return; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1610,15 +1571,13 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1626,8 +1585,7 @@ FdMtFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1681,8 +1639,6 @@ FdMtFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1703,7 +1659,7 @@ FdMtFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1749,11 +1705,9 @@ FdMtFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -1762,7 +1716,7 @@ FdMtFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1792,8 +1746,7 @@ FdMtFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1814,8 +1767,7 @@ FdMtFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1842,8 +1794,7 @@ FdMtFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1863,7 +1814,7 @@ void FdMtFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -1871,12 +1822,12 @@ FdMtFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -1888,7 +1839,7 @@ FdMtFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -1896,12 +1847,12 @@ FdMtFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -1917,7 +1868,7 @@ void FdMtFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -1925,13 +1876,13 @@ FdMtFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -1946,9 +1897,8 @@ FdMtFfMacScheduler::RefreshUlCqiMaps() void FdMtFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2003,7 +1953,7 @@ void FdMtFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/fdtbfq-ff-mac-scheduler.cc b/src/lte/model/fdtbfq-ff-mac-scheduler.cc index d70b55815..7684b4170 100644 --- a/src/lte/model/fdtbfq-ff-mac-scheduler.cc +++ b/src/lte/model/fdtbfq-ff-mac-scheduler.cc @@ -184,7 +184,7 @@ FdTbfqFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -230,10 +230,9 @@ FdTbfqFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::map::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -289,15 +288,13 @@ FdTbfqFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -327,14 +324,12 @@ FdTbfqFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -356,11 +351,9 @@ FdTbfqFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -407,9 +400,8 @@ FdTbfqFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int FdTbfqFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -430,13 +422,12 @@ FdTbfqFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -460,13 +451,12 @@ FdTbfqFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -495,8 +485,7 @@ FdTbfqFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -506,8 +495,7 @@ FdTbfqFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -547,7 +535,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); rbgMap = m_ffrSapProvider->GetAvailableDlRbg(); - for (std::vector::iterator it = rbgMap.begin(); it != rbgMap.end(); it++) + for (auto it = rbgMap.begin(); it != rbgMap.end(); it++) { if (*it) { @@ -558,8 +546,8 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( FfMacSchedSapUser::SchedDlConfigIndParameters ret; // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -575,7 +563,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( uint16_t tmpFfrRbStartOffset = 0; uint16_t index = 0; - for (std::vector::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++) + for (auto it = ulRbMap.begin(); it != ulRbMap.end(); it++) { if (*it) { @@ -606,8 +594,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; rbStart = ffrRbStartOffset; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -671,15 +658,13 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -721,7 +706,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -749,8 +734,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -771,16 +755,14 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -867,8 +849,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -945,8 +926,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -959,15 +939,14 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -994,8 +973,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( } // update token pool, counter and bank size - std::map::iterator itStats; - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { if ((*itStats).second.tokenGenerationRate / 1000 + (*itStats).second.tokenPoolSize > (*itStats).second.maxTokenPoolSize) @@ -1021,12 +999,12 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( { // select UE with largest metric std::map::iterator it; - std::map::iterator itMax = m_flowStatsDl.end(); + auto itMax = m_flowStatsDl.end(); double metricMax = 0.0; bool firstRnti = true; for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it).first))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -1041,10 +1019,8 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( continue; } // check first the channel conditions for this UE, if CQI!=0 - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_a30CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1078,8 +1054,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::set::iterator rnti; - rnti = allocatedRnti.find((*it).first); + auto rnti = allocatedRnti.find((*it).first); if (rnti != allocatedRnti.end()) // already allocated RBGs to this UE { continue; @@ -1139,9 +1114,8 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( // calculate rlc buffer size uint32_t rlcBufSize = 0; uint8_t lcid = 0; - std::map::iterator - itRlcBuf; - for (itRlcBuf = m_rlcBufferReq.begin(); itRlcBuf != m_rlcBufferReq.end(); itRlcBuf++) + for (auto itRlcBuf = m_rlcBufferReq.begin(); itRlcBuf != m_rlcBufferReq.end(); + itRlcBuf++) { if ((*itRlcBuf).first.m_rnti == (*itMax).first) { @@ -1149,7 +1123,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( } } LteFlowId_t flow((*itMax).first, lcid); - itRlcBuf = m_rlcBufferReq.find(flow); + auto itRlcBuf = m_rlcBufferReq.find(flow); if (itRlcBuf != m_rlcBufferReq.end()) { rlcBufSize = (*itRlcBuf).second.m_rlcTransmissionQueueSize + @@ -1172,10 +1146,8 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( { totalRbg++; - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMax).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMax).first); + auto itCqi = m_a30CqiRxed.find((*itMax).first); + auto itTxMode = m_uesTxMode.find((*itMax).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1187,8 +1159,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( rbgIndex = rbgNum; for (int k = 0; k < rbgNum; k++) { - std::set::iterator rbg; - rbg = allocatedRbg.find(k); + auto rbg = allocatedRbg.find(k); if (rbg != allocatedRbg.end()) // RBGs are already allocated to this UE { continue; @@ -1265,8 +1236,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( } // assign this RBG to UE - std::map>::iterator itMap; - itMap = allocationMap.find((*itMax).first); + auto itMap = allocationMap.find((*itMax).first); uint16_t RbgPerRnti; if (itMap == allocationMap.end()) { @@ -1352,8 +1322,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( { NS_LOG_DEBUG("budget: " << budget << " bytesTxed: " << bytesTxed << " at " << Simulator::Now().As(Time::MS)); - std::map>::iterator itMap; - itMap = allocationMap.find((*itMax).first); + auto itMap = allocationMap.find((*itMax).first); (*itMap).second.pop_back(); allocatedRbg.erase(rbgIndex); bytesTxed = bytesTxedTmp; // recovery bytesTxed @@ -1394,7 +1363,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { NS_LOG_DEBUG("Preparing DCI for RNTI " << (*itMap).first); @@ -1414,10 +1383,8 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_a30CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1500,9 +1467,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1524,8 +1489,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1554,8 +1518,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1563,8 +1526,7 @@ FdTbfqFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1605,9 +1567,8 @@ FdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1622,17 +1583,15 @@ FdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1645,8 +1604,7 @@ FdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1660,7 +1618,7 @@ FdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( double FdTbfqFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1713,7 +1671,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( rbMap = m_ffrSapProvider->GetAvailableUlRbg(); - for (std::vector::iterator it = rbMap.begin(); it != rbMap.end(); it++) + for (auto it = rbMap.begin(); it != rbMap.end(); it++) { if (*it) { @@ -1743,8 +1701,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1752,16 +1709,14 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1820,7 +1775,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1853,7 +1808,6 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( } int rbAllocated = 0; - std::map::iterator itStats; if (m_nextRntiUl != 0) { for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) @@ -1875,7 +1829,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1968,7 +1922,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( break; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -2039,15 +1993,13 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -2055,8 +2007,7 @@ FdTbfqFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -2110,8 +2061,6 @@ FdTbfqFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -2132,7 +2081,7 @@ FdTbfqFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -2178,11 +2127,9 @@ FdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -2191,7 +2138,7 @@ FdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2221,8 +2168,7 @@ FdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2243,8 +2189,7 @@ FdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2271,8 +2216,7 @@ FdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2292,7 +2236,7 @@ void FdTbfqFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -2300,12 +2244,12 @@ FdTbfqFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -2317,7 +2261,7 @@ FdTbfqFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -2325,12 +2269,12 @@ FdTbfqFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -2346,7 +2290,7 @@ void FdTbfqFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -2354,13 +2298,13 @@ FdTbfqFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -2375,9 +2319,8 @@ FdTbfqFfMacScheduler::RefreshUlCqiMaps() void FdTbfqFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2432,7 +2375,7 @@ void FdTbfqFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/lte-amc.cc b/src/lte/model/lte-amc.cc index eb161a7c3..4e5cfddff 100644 --- a/src/lte/model/lte-amc.cc +++ b/src/lte/model/lte-amc.cc @@ -554,11 +554,10 @@ LteAmc::CreateCqiFeedbacks(const SpectrumValue& sinr, uint8_t rbgSize) NS_LOG_FUNCTION(this); std::vector cqi; - Values::const_iterator it; if (m_amcModel == PiroEW2010) { - for (it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) + for (auto it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) { double sinr_ = (*it); if (sinr_ == 0.0) @@ -594,7 +593,7 @@ LteAmc::CreateCqiFeedbacks(const SpectrumValue& sinr, uint8_t rbgSize) NS_ASSERT_MSG(rbgSize > 0, " LteAmc-Vienna: RBG size must be greater than 0"); std::vector rbgMap; int rbId = 0; - for (it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) + for (auto it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) { rbgMap.push_back(rbId++); if ((rbId % rbgSize == 0) || ((it + 1) == sinr.ConstValuesEnd())) diff --git a/src/lte/model/lte-anr.cc b/src/lte/model/lte-anr.cc index 7424386c6..b74d1adc2 100644 --- a/src/lte/model/lte-anr.cc +++ b/src/lte/model/lte-anr.cc @@ -97,7 +97,7 @@ LteAnr::RemoveNeighbourRelation(uint16_t cellId) { NS_LOG_FUNCTION(this << m_servingCellId << cellId); - NeighbourRelationTable_t::iterator it = m_neighbourRelationTable.find(cellId); + auto it = m_neighbourRelationTable.find(cellId); if (it != m_neighbourRelationTable.end()) { NS_FATAL_ERROR("Cell ID " << cellId << " cannot be found in NRT"); @@ -157,8 +157,7 @@ LteAnr::DoReportUeMeas(LteRrcSap::MeasResults measResults) { if (measResults.haveMeasResultNeighCells && !(measResults.measResultListEutra.empty())) { - for (std::list::iterator it = - measResults.measResultListEutra.begin(); + for (auto it = measResults.measResultListEutra.begin(); it != measResults.measResultListEutra.end(); ++it) { @@ -167,8 +166,7 @@ LteAnr::DoReportUeMeas(LteRrcSap::MeasResults measResults) "RSRQ measure missing for cellId " << it->physCellId); // Update Neighbour Relation Table - NeighbourRelationTable_t::iterator itNrt = - m_neighbourRelationTable.find(it->physCellId); + auto itNrt = m_neighbourRelationTable.find(it->physCellId); if (itNrt != m_neighbourRelationTable.end()) { // Update neighbour relation entry @@ -243,7 +241,7 @@ LteAnr::DoGetNoX2(uint16_t cellId) const const LteAnr::NeighbourRelation_t* LteAnr::Find(uint16_t cellId) const { - NeighbourRelationTable_t::const_iterator it = m_neighbourRelationTable.find(cellId); + auto it = m_neighbourRelationTable.find(cellId); if (it == m_neighbourRelationTable.end()) { NS_FATAL_ERROR("Cell ID " << cellId << " cannot be found in NRT"); diff --git a/src/lte/model/lte-chunk-processor.cc b/src/lte/model/lte-chunk-processor.cc index cd7adfe99..ef0f4da6f 100644 --- a/src/lte/model/lte-chunk-processor.cc +++ b/src/lte/model/lte-chunk-processor.cc @@ -72,8 +72,8 @@ LteChunkProcessor::End() NS_LOG_FUNCTION(this); if (m_totDuration.GetSeconds() > 0) { - std::vector::iterator it; - for (it = m_lteChunkProcessorCallbacks.begin(); it != m_lteChunkProcessorCallbacks.end(); + for (auto it = m_lteChunkProcessorCallbacks.begin(); + it != m_lteChunkProcessorCallbacks.end(); it++) { (*it)((*m_sumValues) / m_totDuration.GetSeconds()); diff --git a/src/lte/model/lte-common.cc b/src/lte/model/lte-common.cc index c3903ce67..c5de4717e 100644 --- a/src/lte/model/lte-common.cc +++ b/src/lte/model/lte-common.cc @@ -143,7 +143,7 @@ LteFfConverter::double2fpS11dot3(double val) { val = -4096; } - int16_t valFp = (int16_t)(val * 8); + auto valFp = (int16_t)(val * 8); return (valFp); } @@ -361,7 +361,7 @@ EutranMeasurementMapping::IeValue2ActualQQualMin(int8_t qQualMinIeValue) << " for Q-QualMin IE value"); } - double actual = static_cast(qQualMinIeValue); + auto actual = static_cast(qQualMinIeValue); NS_ASSERT(actual >= -34.0); NS_ASSERT(actual <= -3.0); return actual; diff --git a/src/lte/model/lte-enb-component-carrier-manager.cc b/src/lte/model/lte-enb-component-carrier-manager.cc index 51b05deb2..9b116a233 100644 --- a/src/lte/model/lte-enb-component-carrier-manager.cc +++ b/src/lte/model/lte-enb-component-carrier-manager.cc @@ -84,8 +84,7 @@ LteEnbComponentCarrierManager::SetMacSapProvider(uint8_t componentCarrierId, Lte { NS_LOG_FUNCTION(this); bool res = false; - std::map::iterator it = - m_macSapProvidersMap.find(componentCarrierId); + auto it = m_macSapProvidersMap.find(componentCarrierId); if ((uint16_t)componentCarrierId > m_noOfComponentCarriers) { NS_FATAL_ERROR("Inconsistent componentCarrierId or you didn't call " @@ -110,8 +109,7 @@ LteEnbComponentCarrierManager::SetCcmMacSapProviders(uint8_t componentCarrierId, { NS_LOG_FUNCTION(this); bool res = false; - std::map::iterator it = - m_ccmMacSapProviderMap.find(componentCarrierId); + auto it = m_ccmMacSapProviderMap.find(componentCarrierId); if (it == m_ccmMacSapProviderMap.end()) { diff --git a/src/lte/model/lte-enb-mac.cc b/src/lte/model/lte-enb-mac.cc index 63f9bf32b..7685d4099 100644 --- a/src/lte/model/lte-enb-mac.cc +++ b/src/lte/model/lte-enb-mac.cc @@ -499,8 +499,7 @@ LteEnbMac::DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo) // process received RACH preambles and notify the scheduler FfMacSchedSapProvider::SchedDlRachInfoReqParameters rachInfoReqParams; NS_ASSERT(subframeNo > 0 && subframeNo <= 10); // subframe in 1..10 - for (std::map::const_iterator it = m_receivedRachPreambleCount.begin(); - it != m_receivedRachPreambleCount.end(); + for (auto it = m_receivedRachPreambleCount.begin(); it != m_receivedRachPreambleCount.end(); ++it) { NS_LOG_INFO(this << " preambleId " << (uint32_t)it->first << ": " << it->second @@ -515,8 +514,7 @@ LteEnbMac::DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo) else { uint16_t rnti; - std::map::iterator jt = - m_allocatedNcRaPreambleMap.find(it->first); + auto jt = m_allocatedNcRaPreambleMap.find(it->first); if (jt != m_allocatedNcRaPreambleMap.end()) { rnti = jt->second.rnti; @@ -716,10 +714,9 @@ LteEnbMac::DoReceivePhyPdu(Ptr p) // store info of the packet received - // std::map ::iterator it; // u_int rnti = tag.GetRnti (); - // u_int lcid = tag.GetLcid (); - // it = m_ulInfoListElements.find (tag.GetRnti ()); + // u_int lcid = tag.GetLcid (); + // auto it = m_ulInfoListElements.find (tag.GetRnti ()); // if (it == m_ulInfoListElements.end ()) // { // // new RNTI @@ -749,10 +746,9 @@ LteEnbMac::DoReceivePhyPdu(Ptr p) // forward the packet to the correspondent RLC uint16_t rnti = tag.GetRnti(); uint8_t lcid = tag.GetLcid(); - std::map>::iterator rntiIt = - m_rlcAttached.find(rnti); + auto rntiIt = m_rlcAttached.find(rnti); NS_ASSERT_MSG(rntiIt != m_rlcAttached.end(), "could not find RNTI" << rnti); - std::map::iterator lcidIt = rntiIt->second.find(lcid); + auto lcidIt = rntiIt->second.find(lcid); // NS_ASSERT_MSG (lcidIt != rntiIt->second.end (), "could not find LCID" << lcid); LteMacSapUser::ReceivePduParameters rxPduParams; @@ -789,7 +785,7 @@ LteEnbMac::DoAddUe(uint16_t rnti) { NS_LOG_FUNCTION(this << " rnti=" << rnti); std::map empty; - std::pair>::iterator, bool> ret = + auto ret = m_rlcAttached.insert(std::pair>(rnti, empty)); NS_ASSERT_MSG(ret.second, "element already present, RNTI already existed"); @@ -833,13 +829,12 @@ LteEnbMac::DoRemoveUe(uint16_t rnti) NS_LOG_DEBUG("start checking for unprocessed preamble for rnti: " << rnti); // remove unprocessed preamble received for RACH during handover - std::map::iterator jt = m_allocatedNcRaPreambleMap.begin(); + auto jt = m_allocatedNcRaPreambleMap.begin(); while (jt != m_allocatedNcRaPreambleMap.end()) { if (jt->second.rnti == rnti) { - std::map::const_iterator it = - m_receivedRachPreambleCount.find(jt->first); + auto it = m_receivedRachPreambleCount.find(jt->first); if (it != m_receivedRachPreambleCount.end()) { m_receivedRachPreambleCount.erase(it->first); @@ -852,7 +847,7 @@ LteEnbMac::DoRemoveUe(uint16_t rnti) } } - std::vector::iterator itCeRxd = m_ulCeReceived.begin(); + auto itCeRxd = m_ulCeReceived.begin(); while (itCeRxd != m_ulCeReceived.end()) { if (itCeRxd->m_rnti == rnti) @@ -871,14 +866,11 @@ LteEnbMac::DoAddLc(LteEnbCmacSapProvider::LcInfo lcinfo, LteMacSapUser* msu) { NS_LOG_FUNCTION(this << lcinfo.rnti << (uint16_t)lcinfo.lcId); - std::map::iterator it; - LteFlowId_t flow(lcinfo.rnti, lcinfo.lcId); - std::map>::iterator rntiIt = - m_rlcAttached.find(lcinfo.rnti); + auto rntiIt = m_rlcAttached.find(lcinfo.rnti); NS_ASSERT_MSG(rntiIt != m_rlcAttached.end(), "RNTI not found"); - std::map::iterator lcidIt = rntiIt->second.find(lcinfo.lcId); + auto lcidIt = rntiIt->second.find(lcinfo.lcId); if (lcidIt == rntiIt->second.end()) { rntiIt->second.insert(std::pair(lcinfo.lcId, msu)); @@ -928,8 +920,7 @@ LteEnbMac::DoReleaseLc(uint16_t rnti, uint8_t lcid) NS_LOG_FUNCTION(this); // Find user based on rnti and then erase lcid stored against the same - std::map>::iterator rntiIt = - m_rlcAttached.find(rnti); + auto rntiIt = m_rlcAttached.find(rnti); rntiIt->second.erase(lcid); FfMacCschedSapProvider::CschedLcReleaseReqParameters params; @@ -969,8 +960,7 @@ LteEnbMac::DoAllocateNcRaPreamble(uint16_t rnti) uint8_t preambleId; for (preambleId = m_numberOfRaPreambles; preambleId < 64; ++preambleId) { - std::map::iterator it = - m_allocatedNcRaPreambleMap.find(preambleId); + auto it = m_allocatedNcRaPreambleMap.find(preambleId); /** * Allocate preamble only if its free. The non-contention preamble * assigned to UE during handover or PDCCH order is valid only until the @@ -1036,8 +1026,7 @@ LteEnbMac::DoTransmitPdu(LteMacSapProvider::TransmitPduParameters params) params.pdu->AddPacketTag(tag); params.componentCarrierId = m_componentCarrierId; // Store pkt in HARQ buffer - std::map::iterator it = - m_miDlHarqProcessesPackets.find(params.rnti); + auto it = m_miDlHarqProcessesPackets.find(params.rnti); NS_ASSERT(it != m_miDlHarqProcessesPackets.end()); NS_LOG_DEBUG(this << " LAYER " << (uint16_t)tag.GetLayer() << " HARQ ID " << (uint16_t)params.harqProcessId); @@ -1072,7 +1061,6 @@ LteEnbMac::DoSchedDlConfigInd(FfMacSchedSapUser::SchedDlConfigIndParameters ind) NS_LOG_FUNCTION(this); // Create DL PHY PDU Ptr pb = CreateObject(); - std::map::iterator it; LteMacSapUser::TxOpportunityParameters txOpParams; for (std::size_t i = 0; i < ind.m_buildDataList.size(); i++) @@ -1082,8 +1070,7 @@ LteEnbMac::DoSchedDlConfigInd(FfMacSchedSapUser::SchedDlConfigIndParameters ind) if (ind.m_buildDataList.at(i).m_dci.m_ndi.at(layer) == 1) { // new data -> force emptying correspondent harq pkt buffer - std::map::iterator it = - m_miDlHarqProcessesPackets.find(ind.m_buildDataList.at(i).m_rnti); + auto it = m_miDlHarqProcessesPackets.find(ind.m_buildDataList.at(i).m_rnti); NS_ASSERT(it != m_miDlHarqProcessesPackets.end()); for (std::size_t lcId = 0; lcId < (*it).second.size(); lcId++) { @@ -1102,10 +1089,9 @@ LteEnbMac::DoSchedDlConfigInd(FfMacSchedSapUser::SchedDlConfigIndParameters ind) uint16_t rnti = ind.m_buildDataList.at(i).m_rnti; uint8_t lcid = ind.m_buildDataList.at(i).m_rlcPduList.at(j).at(k).m_logicalChannelIdentity; - std::map>::iterator rntiIt = - m_rlcAttached.find(rnti); + auto rntiIt = m_rlcAttached.find(rnti); NS_ASSERT_MSG(rntiIt != m_rlcAttached.end(), "could not find RNTI" << rnti); - std::map::iterator lcidIt = rntiIt->second.find(lcid); + auto lcidIt = rntiIt->second.find(lcid); NS_ASSERT_MSG(lcidIt != rntiIt->second.end(), "could not find LCID" << (uint32_t)lcid << " carrier id:" << (uint16_t)m_componentCarrierId); @@ -1124,13 +1110,11 @@ LteEnbMac::DoSchedDlConfigInd(FfMacSchedSapUser::SchedDlConfigIndParameters ind) if (ind.m_buildDataList.at(i).m_dci.m_tbsSize.at(k) > 0) { // HARQ retransmission -> retrieve TB from HARQ buffer - std::map::iterator it = - m_miDlHarqProcessesPackets.find(ind.m_buildDataList.at(i).m_rnti); + auto it = m_miDlHarqProcessesPackets.find(ind.m_buildDataList.at(i).m_rnti); NS_ASSERT(it != m_miDlHarqProcessesPackets.end()); Ptr pb = (*it).second.at(k).at(ind.m_buildDataList.at(i).m_dci.m_harqProcess); - for (std::list>::const_iterator j = pb->Begin(); j != pb->End(); - ++j) + for (auto j = pb->Begin(); j != pb->End(); ++j) { Ptr pkt = (*j)->Copy(); m_enbPhySapProvider->SendMacPdu(pkt); @@ -1198,8 +1182,7 @@ LteEnbMac::DoSchedDlConfigInd(FfMacSchedSapUser::SchedDlConfigIndParameters ind) rarMsg->SetRaRnti(raRnti); for (unsigned int i = 0; i < ind.m_buildRarList.size(); i++) { - std::map::iterator itRapId = - m_rapIdRntiMap.find(ind.m_buildRarList.at(i).m_rnti); + auto itRapId = m_rapIdRntiMap.find(ind.m_buildRarList.at(i).m_rnti); if (itRapId == m_rapIdRntiMap.end()) { NS_FATAL_ERROR("Unable to find rapId of RNTI " << ind.m_buildRarList.at(i).m_rnti); @@ -1309,8 +1292,7 @@ LteEnbMac::DoDlInfoListElementHarqFeedback(DlInfoListElement_s params) { NS_LOG_FUNCTION(this); // Update HARQ buffer - std::map::iterator it = - m_miDlHarqProcessesPackets.find(params.m_rnti); + auto it = m_miDlHarqProcessesPackets.find(params.m_rnti); NS_ASSERT(it != m_miDlHarqProcessesPackets.end()); for (std::size_t layer = 0; layer < params.m_harqStatus.size(); layer++) { diff --git a/src/lte/model/lte-enb-phy.cc b/src/lte/model/lte-enb-phy.cc index bb07f2b7a..d2538b6ae 100644 --- a/src/lte/model/lte-enb-phy.cc +++ b/src/lte/model/lte-enb-phy.cc @@ -378,8 +378,7 @@ bool LteEnbPhy::AddUePhy(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::set::iterator it; - it = m_ueAttached.find(rnti); + auto it = m_ueAttached.find(rnti); if (it == m_ueAttached.end()) { m_ueAttached.insert(rnti); @@ -396,8 +395,7 @@ bool LteEnbPhy::DeleteUePhy(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::set::iterator it; - it = m_ueAttached.find(rnti); + auto it = m_ueAttached.find(rnti); if (it == m_ueAttached.end()) { NS_LOG_ERROR("UE not attached"); @@ -461,7 +459,7 @@ LteEnbPhy::GeneratePowerAllocationMap(uint16_t rnti, int rbId) NS_LOG_FUNCTION(this); double rbgTxPower = m_txPower; - std::map::iterator it = m_paMap.find(rnti); + auto it = m_paMap.find(rnti); if (it != m_paMap.end()) { rbgTxPower = m_txPower + it->second; @@ -525,8 +523,7 @@ void LteEnbPhy::ReceiveLteControlMessageList(std::list> msgList) { NS_LOG_FUNCTION(this); - std::list>::iterator it; - for (it = msgList.begin(); it != msgList.end(); it++) + for (auto it = msgList.begin(); it != msgList.end(); it++) { switch ((*it)->GetMessageType()) { @@ -626,12 +623,10 @@ LteEnbPhy::StartSubFrame() // update info on TB to be received std::list uldcilist = DequeueUlDci(); - std::list::iterator dciIt = uldcilist.begin(); NS_LOG_DEBUG(this << " eNB Expected TBs " << uldcilist.size()); - for (dciIt = uldcilist.begin(); dciIt != uldcilist.end(); dciIt++) + for (auto dciIt = uldcilist.begin(); dciIt != uldcilist.end(); dciIt++) { - std::set::iterator it2; - it2 = m_ueAttached.find((*dciIt).GetDci().m_rnti); + auto it2 = m_ueAttached.find((*dciIt).GetDci().m_rnti); if (it2 == m_ueAttached.end()) { @@ -674,8 +669,7 @@ LteEnbPhy::StartSubFrame() m_dlPowerAllocationMap.clear(); if (!ctrlMsg.empty()) { - std::list>::iterator it; - it = ctrlMsg.begin(); + auto it = ctrlMsg.begin(); while (it != ctrlMsg.end()) { Ptr msg = (*it); @@ -726,10 +720,7 @@ LteEnbPhy::StartSubFrame() else if (msg->GetMessageType() == LteControlMessage::RAR) { Ptr rarMsg = DynamicCast(msg); - for (std::list::const_iterator it = - rarMsg->RarListBegin(); - it != rarMsg->RarListEnd(); - ++it) + for (auto it = rarMsg->RarListBegin(); it != rarMsg->RarListEnd(); ++it) { if (it->rarPayload.m_grant.m_ulDelay) { @@ -870,10 +861,9 @@ FfMacSchedSapProvider::SchedUlCqiInfoReqParameters LteEnbPhy::CreatePuschCqiReport(const SpectrumValue& sinr) { NS_LOG_FUNCTION(this << sinr); - Values::const_iterator it; FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ulcqi; ulcqi.m_ulCqi.m_type = UlCqi_s::PUSCH; - for (it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) + for (auto it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) { double sinrdb = 10 * std::log10((*it)); // NS_LOG_DEBUG ("ULCQI RB " << i << " value " << sinrdb); @@ -936,7 +926,7 @@ LteEnbPhy::DoRemoveUe(uint16_t rnti) NS_ASSERT_MSG(success, "DeleteUePhy() failed"); // remove also P_A value - std::map::iterator it = m_paMap.find(rnti); + auto it = m_paMap.find(rnti); if (it != m_paMap.end()) { m_paMap.erase(it); @@ -945,7 +935,7 @@ LteEnbPhy::DoRemoveUe(uint16_t rnti) // additional data to be removed m_uplinkSpectrumPhy->RemoveExpectedTb(rnti); // remove srs info to avoid trace errors - std::map::iterator sit = m_srsSampleCounterMap.find(rnti); + auto sit = m_srsSampleCounterMap.find(rnti); if (sit != m_srsSampleCounterMap.end()) { m_srsSampleCounterMap.erase(rnti); @@ -955,7 +945,7 @@ LteEnbPhy::DoRemoveUe(uint16_t rnti) for (auto& ctrlMessageList : m_controlMessagesQueue) { - std::list>::iterator ctrlMsgListIt = ctrlMessageList.begin(); + auto ctrlMsgListIt = ctrlMessageList.begin(); while (ctrlMsgListIt != ctrlMessageList.end()) { Ptr msg = (*ctrlMsgListIt); @@ -1000,7 +990,7 @@ LteEnbPhy::DoSetPa(uint16_t rnti, double pa) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_paMap.find(rnti); + auto it = m_paMap.find(rnti); if (it == m_paMap.end()) { @@ -1016,12 +1006,11 @@ FfMacSchedSapProvider::SchedUlCqiInfoReqParameters LteEnbPhy::CreateSrsCqiReport(const SpectrumValue& sinr) { NS_LOG_FUNCTION(this << sinr); - Values::const_iterator it; FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ulcqi; ulcqi.m_ulCqi.m_type = UlCqi_s::SRS; int i = 0; double srsSum = 0.0; - for (it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) + for (auto it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) { double sinrdb = 10 * log10((*it)); // NS_LOG_DEBUG ("ULCQI RB " << i << " value " << sinrdb); @@ -1048,7 +1037,7 @@ void LteEnbPhy::CreateSrsReport(uint16_t rnti, double srs) { NS_LOG_FUNCTION(this << rnti << srs); - std::map::iterator it = m_srsSampleCounterMap.find(rnti); + auto it = m_srsSampleCounterMap.find(rnti); if (it == m_srsSampleCounterMap.end()) { // create new entry @@ -1119,7 +1108,7 @@ LteEnbPhy::DoSetSrsConfigurationIndex(uint16_t rnti, uint16_t srcCi) NS_LOG_DEBUG(this << " ENB SRS P " << m_srsPeriodicity << " RNTI " << rnti << " offset " << GetSrsSubframeOffset(srcCi) << " CI " << srcCi); - std::map::iterator it = m_srsCounter.find(rnti); + auto it = m_srsCounter.find(rnti); if (it != m_srsCounter.end()) { (*it).second = GetSrsSubframeOffset(srcCi) + 1; diff --git a/src/lte/model/lte-enb-rrc.cc b/src/lte/model/lte-enb-rrc.cc index e11c1cff3..364e1b7b3 100644 --- a/src/lte/model/lte-enb-rrc.cc +++ b/src/lte/model/lte-enb-rrc.cc @@ -320,9 +320,7 @@ UeManager::DoDispose() { delete m_drbPdcpSapUser; // delete eventual X2-U TEIDs - for (std::map>::iterator it = m_drbMap.begin(); - it != m_drbMap.end(); - ++it) + for (auto it = m_drbMap.begin(); it != m_drbMap.end(); ++it) { m_rrc->m_x2uTeidInfoMap.erase(it->second->m_gtpTeid); } @@ -425,9 +423,8 @@ UeManager::SetupDataRadioBearer(EpsBearer bearer, LteEnbRrc::X2uTeidInfo x2uTeidInfo; x2uTeidInfo.rnti = m_rnti; x2uTeidInfo.drbid = drbid; - std::pair::iterator, bool> ret = - m_rrc->m_x2uTeidInfoMap.insert( - std::pair(gtpTeid, x2uTeidInfo)); + auto ret = m_rrc->m_x2uTeidInfoMap.insert( + std::pair(gtpTeid, x2uTeidInfo)); NS_ASSERT_MSG(ret.second == true, "overwriting a pre-existing entry in m_x2uTeidInfoMap"); } @@ -478,7 +475,7 @@ UeManager::SetupDataRadioBearer(EpsBearer bearer, // lcinfo.gbrDl = bearer.gbrQosInfo.gbrDl; // use a for cycle to send the AddLc to the appropriate Mac Sap // if the sap is not initialized the appropriated method has to be called - std::vector::iterator itLcOnCcMapping = lcOnCcMapping.begin(); + auto itLcOnCcMapping = lcOnCcMapping.begin(); NS_ASSERT_MSG(itLcOnCcMapping != lcOnCcMapping.end(), "Problem"); for (itLcOnCcMapping = lcOnCcMapping.begin(); itLcOnCcMapping != lcOnCcMapping.end(); ++itLcOnCcMapping) @@ -523,9 +520,7 @@ void UeManager::RecordDataRadioBearersToBeStarted() { NS_LOG_FUNCTION(this << (uint32_t)m_rnti); - for (std::map>::iterator it = m_drbMap.begin(); - it != m_drbMap.end(); - ++it) + for (auto it = m_drbMap.begin(); it != m_drbMap.end(); ++it) { m_drbsToBeStarted.push_back(it->first); } @@ -535,11 +530,9 @@ void UeManager::StartDataRadioBearers() { NS_LOG_FUNCTION(this << (uint32_t)m_rnti); - for (std::list::iterator drbIdIt = m_drbsToBeStarted.begin(); - drbIdIt != m_drbsToBeStarted.end(); - ++drbIdIt) + for (auto drbIdIt = m_drbsToBeStarted.begin(); drbIdIt != m_drbsToBeStarted.end(); ++drbIdIt) { - std::map>::iterator drbIt = m_drbMap.find(*drbIdIt); + auto drbIt = m_drbMap.find(*drbIdIt); NS_ASSERT(drbIt != m_drbMap.end()); drbIt->second->m_rlc->Initialize(); if (drbIt->second->m_pdcp) @@ -555,7 +548,7 @@ UeManager::ReleaseDataRadioBearer(uint8_t drbid) { NS_LOG_FUNCTION(this << (uint32_t)m_rnti << (uint32_t)drbid); uint8_t lcid = Drbid2Lcid(drbid); - std::map>::iterator it = m_drbMap.find(drbid); + auto it = m_drbMap.find(drbid); NS_ASSERT_MSG(it != m_drbMap.end(), "request to remove radio bearer with unknown drbid " << drbid); @@ -565,7 +558,7 @@ UeManager::ReleaseDataRadioBearer(uint8_t drbid) m_drbMap.erase(it); std::vector ccToRelease = m_rrc->m_ccmRrcSapProvider->ReleaseDataRadioBearer(m_rnti, lcid); - std::vector::iterator itCcToRelease = ccToRelease.begin(); + auto itCcToRelease = ccToRelease.begin(); NS_ASSERT_MSG(itCcToRelease != ccToRelease.end(), "request to remove radio bearer with unknown drbid (ComponentCarrierManager)"); for (itCcToRelease = ccToRelease.begin(); itCcToRelease != ccToRelease.end(); ++itCcToRelease) @@ -856,9 +849,7 @@ UeManager::RecvHandoverRequestAck(EpcX2SapUser::HandoverRequestAckParams params) sst.newEnbUeX2apId = params.newEnbUeX2apId; sst.sourceCellId = params.sourceCellId; sst.targetCellId = params.targetCellId; - for (std::map>::iterator drbIt = m_drbMap.begin(); - drbIt != m_drbMap.end(); - ++drbIt) + for (auto drbIt = m_drbMap.begin(); drbIt != m_drbMap.end(); ++drbIt) { // SN status transfer is only for AM RLC if (drbIt->second->m_rlc->GetObject()) @@ -939,7 +930,7 @@ UeManager::SendPacket(uint8_t bid, Ptr p) params.lcid = Bid2Lcid(bid); uint8_t drbid = Bid2Drbid(bid); // Transmit PDCP sdu only if DRB ID found in drbMap - std::map>::iterator it = m_drbMap.find(drbid); + auto it = m_drbMap.find(drbid); if (it != m_drbMap.end()) { Ptr bearerInfo = GetDataRadioBearerInfo(drbid); @@ -1002,9 +993,7 @@ UeManager::GetErabList() { NS_LOG_FUNCTION(this); std::vector ret; - for (std::map>::iterator it = m_drbMap.begin(); - it != m_drbMap.end(); - ++it) + for (auto it = m_drbMap.begin(); it != m_drbMap.end(); ++it) { EpcX2Sap::ErabToBeSetupItem etbsi; etbsi.erabId = it->second->m_epsBearerIdentity; @@ -1079,8 +1068,7 @@ void UeManager::RecvSnStatusTransfer(EpcX2SapUser::SnStatusTransferParams params) { NS_LOG_FUNCTION(this); - for (std::vector::iterator erabIt = - params.erabsSubjectToStatusTransferList.begin(); + for (auto erabIt = params.erabsSubjectToStatusTransferList.begin(); erabIt != params.erabsSubjectToStatusTransferList.end(); ++erabIt) { @@ -1088,7 +1076,7 @@ UeManager::RecvSnStatusTransfer(EpcX2SapUser::SnStatusTransferParams params) // status.txSn = erabIt->dlPdcpSn; // status.rxSn = erabIt->ulPdcpSn; // uint8_t drbId = Bid2Drbid (erabIt->erabId); - // std::map >::iterator drbIt = m_drbMap.find (drbId); + // auto drbIt = m_drbMap.find (drbId); // NS_ASSERT_MSG (drbIt != m_drbMap.end (), "could not find DRBID " << (uint32_t) drbId); // drbIt->second->m_pdcp->SetStatus (status); } @@ -1293,9 +1281,7 @@ UeManager::RecvRrcConnectionReconfigurationCompleted( params.cellId = m_rrc->ComponentCarrierToCellId(m_componentCarrierId); params.mmeUeS1Id = m_imsi; SwitchToState(HANDOVER_PATH_SWITCH); - for (std::map>::iterator it = m_drbMap.begin(); - it != m_drbMap.end(); - ++it) + for (auto it = m_drbMap.begin(); it != m_drbMap.end(); ++it) { EpcEnbS1SapProvider::BearerToBeSwitched b; b.epsBearerId = it->second->m_epsBearerIdentity; @@ -1362,8 +1348,7 @@ UeManager::RecvMeasurementReport(LteRrcSap::MeasurementReport msg) << (uint16_t)msg.measResults.measResultPCell.rsrpResult << " RSRQ " << (uint16_t)msg.measResults.measResultPCell.rsrqResult); - for (std::list::iterator it = - msg.measResults.measResultListEutra.begin(); + for (auto it = msg.measResults.measResultListEutra.begin(); it != msg.measResults.measResultListEutra.end(); ++it) { @@ -1586,7 +1571,7 @@ UeManager::GetDataRadioBearerInfo(uint8_t drbid) { NS_LOG_FUNCTION(this << (uint32_t)drbid); NS_ASSERT(0 != drbid); - std::map>::iterator it = m_drbMap.find(drbid); + auto it = m_drbMap.find(drbid); NS_ABORT_IF(it == m_drbMap.end()); return it->second; } @@ -1595,7 +1580,7 @@ void UeManager::RemoveDataRadioBearerInfo(uint8_t drbid) { NS_LOG_FUNCTION(this << (uint32_t)drbid); - std::map>::iterator it = m_drbMap.find(drbid); + auto it = m_drbMap.find(drbid); NS_ASSERT_MSG(it != m_drbMap.end(), "request to remove radio bearer with unknown drbid " << drbid); m_drbMap.erase(it); @@ -1642,9 +1627,7 @@ UeManager::BuildRadioResourceConfigDedicated() rrcd.srbToAddModList.push_back(stam); } - for (std::map>::iterator it = m_drbMap.begin(); - it != m_drbMap.end(); - ++it) + for (auto it = m_drbMap.begin(); it != m_drbMap.end(); ++it) { LteRrcSap::DrbToAddMod dtam; dtam.epsBearerIdentity = it->second->m_epsBearerIdentity; @@ -2351,7 +2334,7 @@ bool LteEnbRrc::HasUeManager(uint16_t rnti) const { NS_LOG_FUNCTION(this << (uint32_t)rnti); - std::map>::const_iterator it = m_ueMap.find(rnti); + auto it = m_ueMap.find(rnti); return (it != m_ueMap.end()); } @@ -2360,7 +2343,7 @@ LteEnbRrc::GetUeManager(uint16_t rnti) { NS_LOG_FUNCTION(this << (uint32_t)rnti); NS_ASSERT(0 != rnti); - std::map>::iterator it = m_ueMap.find(rnti); + auto it = m_ueMap.find(rnti); NS_ASSERT_MSG(it != m_ueMap.end(), "UE manager for RNTI " << rnti << " not found"); return it->second; } @@ -2916,9 +2899,7 @@ LteEnbRrc::DoRecvHandoverRequest(EpcX2SapUser::HandoverRequestParams req) ackParams.sourceCellId = req.sourceCellId; ackParams.targetCellId = req.targetCellId; - for (std::vector::iterator it = req.bearers.begin(); - it != req.bearers.end(); - ++it) + for (auto it = req.bearers.begin(); it != req.bearers.end(); ++it) { ueManager->SetupDataRadioBearer(it->erabLevelQosParameters, it->erabId, @@ -3083,7 +3064,7 @@ LteEnbRrc::DoRecvUeData(EpcX2SapUser::UeDataParams params) NS_LOG_LOGIC("ueData = " << params.ueData); NS_LOG_LOGIC("ueData size = " << params.ueData->GetSize()); - std::map::iterator teidInfoIt = m_x2uTeidInfoMap.find(params.gtpTeid); + auto teidInfoIt = m_x2uTeidInfoMap.find(params.gtpTeid); if (teidInfoIt != m_x2uTeidInfoMap.end()) { GetUeManager(teidInfoIt->second.rnti)->SendData(teidInfoIt->second.drbid, params.ueData); @@ -3276,7 +3257,7 @@ void LteEnbRrc::RemoveUe(uint16_t rnti) { NS_LOG_FUNCTION(this << (uint32_t)rnti); - std::map>::iterator it = m_ueMap.find(rnti); + auto it = m_ueMap.find(rnti); NS_ASSERT_MSG(it != m_ueMap.end(), "request to remove UE info with unknown rnti " << rnti); uint64_t imsi = it->second->GetImsi(); uint16_t srsCi = (*it).second->GetSrsConfigurationIndex(); @@ -3438,7 +3419,7 @@ LteEnbRrc::GetNewSrsConfigurationIndex() else { // find a CI from the available ones - std::set::reverse_iterator rit = m_ueSrsConfigurationIndexSet.rbegin(); + auto rit = m_ueSrsConfigurationIndexSet.rbegin(); NS_ASSERT(rit != m_ueSrsConfigurationIndexSet.rend()); NS_LOG_DEBUG(this << " lower bound " << (*rit) << " of " << g_srsCiHigh[m_srsCurrentPeriodicityId]); @@ -3455,7 +3436,7 @@ LteEnbRrc::GetNewSrsConfigurationIndex() srcCi < g_srsCiHigh[m_srsCurrentPeriodicityId]; srcCi++) { - std::set::iterator it = m_ueSrsConfigurationIndexSet.find(srcCi); + auto it = m_ueSrsConfigurationIndexSet.find(srcCi); if (it == m_ueSrsConfigurationIndexSet.end()) { m_lastAllocatedConfigurationIndex = srcCi; @@ -3472,7 +3453,7 @@ void LteEnbRrc::RemoveSrsConfigurationIndex(uint16_t srcCi) { NS_LOG_FUNCTION(this << srcCi); - std::set::iterator it = m_ueSrsConfigurationIndexSet.find(srcCi); + auto it = m_ueSrsConfigurationIndexSet.find(srcCi); NS_ASSERT_MSG(it != m_ueSrsConfigurationIndexSet.end(), "request to remove unknown SRS CI " << srcCi); m_ueSrsConfigurationIndexSet.erase(it); diff --git a/src/lte/model/lte-ffr-distributed-algorithm.cc b/src/lte/model/lte-ffr-distributed-algorithm.cc index fc2b39b2f..85bea3eb1 100644 --- a/src/lte/model/lte-ffr-distributed-algorithm.cc +++ b/src/lte/model/lte-ffr-distributed-algorithm.cc @@ -247,7 +247,7 @@ LteFfrDistributedAlgorithm::DoIsDlRbgAvailableForUe(int rbgId, uint16_t rnti) bool edgeRbg = m_dlEdgeRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -288,7 +288,7 @@ LteFfrDistributedAlgorithm::DoIsUlRbgAvailableForUe(int rbId, uint16_t rnti) bool edgeRbg = m_ulEdgeRbgMap[rbId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -348,7 +348,7 @@ LteFfrDistributedAlgorithm::DoGetTpc(uint16_t rnti) //------------------------------------------------ // here Absolute mode is used - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { return 1; @@ -397,7 +397,7 @@ LteFfrDistributedAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults if (measResults.measId == m_rsrqMeasId) { // check if it is center or edge UE - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -431,7 +431,7 @@ LteFfrDistributedAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults } else if (measResults.measId == m_rsrpMeasId) { - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -444,8 +444,7 @@ LteFfrDistributedAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults if (measResults.haveMeasResultNeighCells && !measResults.measResultListEutra.empty()) { - for (std::list::iterator it = - measResults.measResultListEutra.begin(); + for (auto it = measResults.measResultListEutra.begin(); it != measResults.measResultListEutra.end(); ++it) { @@ -456,9 +455,7 @@ LteFfrDistributedAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults UpdateNeighbourMeasurements(rnti, it->physCellId, it->rsrpResult, it->rsrqResult); bool found = false; - for (std::vector::iterator ncIt = m_neighborCell.begin(); - ncIt != m_neighborCell.end(); - ncIt++) + for (auto ncIt = m_neighborCell.begin(); ncIt != m_neighborCell.end(); ncIt++) { if ((*ncIt) == it->physCellId) { @@ -499,14 +496,11 @@ LteFfrDistributedAlgorithm::Calculate() m_ulEdgeRbgMap.clear(); m_ulEdgeRbgMap.resize(m_ulBandwidth, false); - MeasurementTable_t::iterator it1; - MeasurementRow_t::iterator it2; Ptr servingCellMeasures; Ptr neighbourCellMeasures; uint32_t edgeUeNum = 0; - std::map::iterator areaIt; - for (areaIt = m_ues.begin(); areaIt != m_ues.end(); areaIt++) + for (auto areaIt = m_ues.begin(); areaIt != m_ues.end(); areaIt++) { if (areaIt->second == EdgeArea) { @@ -516,9 +510,9 @@ LteFfrDistributedAlgorithm::Calculate() if (edgeUeNum != 0) { - for (it1 = m_ueMeasures.begin(); it1 != m_ueMeasures.end(); it1++) + for (auto it1 = m_ueMeasures.begin(); it1 != m_ueMeasures.end(); it1++) { - std::map::iterator areaIt = m_ues.find(it1->first); + auto areaIt = m_ues.find(it1->first); if (areaIt->second != EdgeArea) { continue; @@ -527,7 +521,7 @@ LteFfrDistributedAlgorithm::Calculate() servingCellMeasures = nullptr; neighbourCellMeasures = nullptr; - it2 = it1->second.find(m_cellId); + auto it2 = it1->second.find(m_cellId); if (it2 != it1->second.end()) { servingCellMeasures = it2->second; @@ -573,13 +567,12 @@ LteFfrDistributedAlgorithm::Calculate() metricA[i] = 0; } - std::map::iterator cellIt; - for (cellIt = m_cellWeightMap.begin(); cellIt != m_cellWeightMap.end(); cellIt++) + for (auto cellIt = m_cellWeightMap.begin(); cellIt != m_cellWeightMap.end(); cellIt++) { NS_LOG_INFO("CellId: " << m_cellId << " NeighborCellId: " << cellIt->first << " Weight: " << cellIt->second); - std::map>::iterator rntpIt = m_rntp.find(cellIt->first); + auto rntpIt = m_rntp.find(cellIt->first); if (rntpIt == m_rntp.end()) { continue; @@ -596,15 +589,12 @@ LteFfrDistributedAlgorithm::Calculate() std::vector sortedRbgByMetric; std::multimap sortedMetricA; - for (std::map::const_iterator it = metricA.begin(); it != metricA.end(); - ++it) + for (auto it = metricA.begin(); it != metricA.end(); ++it) { sortedMetricA.insert(std::pair(it->second, it->first)); } - for (std::multimap::const_iterator it = sortedMetricA.begin(); - it != sortedMetricA.end(); - ++it) + for (auto it = sortedMetricA.begin(); it != sortedMetricA.end(); ++it) { sortedRbgByMetric.push_back(it->second); } @@ -625,9 +615,7 @@ LteFfrDistributedAlgorithm::Calculate() } } - for (std::vector::iterator ncIt = m_neighborCell.begin(); - ncIt != m_neighborCell.end(); - ncIt++) + for (auto ncIt = m_neighborCell.begin(); ncIt != m_neighborCell.end(); ncIt++) { SendLoadInformation((*ncIt)); } @@ -674,7 +662,7 @@ LteFfrDistributedAlgorithm::DoRecvLoadInformation(EpcX2Sap::LoadInformationParam } uint16_t neighborCellId = params.cellInformationList[0].sourceCellId; - std::map>::iterator it = m_rntp.find(neighborCellId); + auto it = m_rntp.find(neighborCellId); if (it != m_rntp.end()) { it->second = params.cellInformationList[0].relativeNarrowbandTxBand.rntpPerPrbList; @@ -695,22 +683,19 @@ LteFfrDistributedAlgorithm::UpdateNeighbourMeasurements(uint16_t rnti, { NS_LOG_FUNCTION(this << rnti << cellId << (uint16_t)rsrq); - MeasurementTable_t::iterator it1; - it1 = m_ueMeasures.find(rnti); + auto it1 = m_ueMeasures.find(rnti); if (it1 == m_ueMeasures.end()) { // insert a new UE entry MeasurementRow_t row; - std::pair ret; - ret = m_ueMeasures.insert(std::pair(rnti, row)); + auto ret = m_ueMeasures.insert(std::pair(rnti, row)); NS_ASSERT(ret.second); it1 = ret.first; } NS_ASSERT(it1 != m_ueMeasures.end()); - std::map>::iterator it2; - it2 = it1->second.find(cellId); + auto it2 = it1->second.find(cellId); if (it2 != it1->second.end()) { diff --git a/src/lte/model/lte-ffr-enhanced-algorithm.cc b/src/lte/model/lte-ffr-enhanced-algorithm.cc index 90afde1b6..95b77bde7 100644 --- a/src/lte/model/lte-ffr-enhanced-algorithm.cc +++ b/src/lte/model/lte-ffr-enhanced-algorithm.cc @@ -478,8 +478,7 @@ LteFfrEnhancedAlgorithm::DoGetAvailableDlRbg() std::vector rbgMap = m_dlRbgMap; - std::map>::iterator it; - for (it = m_dlRbgAvailableforUe.begin(); it != m_dlRbgAvailableforUe.end(); it++) + for (auto it = m_dlRbgAvailableforUe.begin(); it != m_dlRbgAvailableforUe.end(); it++) { NS_LOG_INFO("RNTI : " << it->first); std::vector rbgAvailableMap = it->second; @@ -506,7 +505,7 @@ LteFfrEnhancedAlgorithm::DoIsDlRbgAvailableForUe(int rbgId, uint16_t rnti) bool isPrimarySegmentRbg = m_dlPrimarySegmentRbgMap[rbgId]; bool isSecondarySegmentRbg = m_dlSecondarySegmentRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -541,7 +540,7 @@ LteFfrEnhancedAlgorithm::DoIsDlRbgAvailableForUe(int rbgId, uint16_t rnti) { // check if RB can be used by UE based on CQI information NS_LOG_INFO("SECONDARY SEGMENT RNTI: " << rnti << " rbgId: " << rbgId); - std::map>::iterator it = m_dlRbgAvailableforUe.find(rnti); + auto it = m_dlRbgAvailableforUe.find(rnti); if (it != m_dlRbgAvailableforUe.end()) { NS_LOG_INFO("RNTI: " << rnti << " rbgId: " << rbgId @@ -574,8 +573,7 @@ LteFfrEnhancedAlgorithm::DoGetAvailableUlRbg() std::vector rbgMap = m_ulRbgMap; - std::map>::iterator it; - for (it = m_ulRbAvailableforUe.begin(); it != m_ulRbAvailableforUe.end(); it++) + for (auto it = m_ulRbAvailableforUe.begin(); it != m_ulRbAvailableforUe.end(); it++) { NS_LOG_INFO("RNTI : " << it->first); std::vector rbAvailableMap = it->second; @@ -607,7 +605,7 @@ LteFfrEnhancedAlgorithm::DoIsUlRbgAvailableForUe(int rbgId, uint16_t rnti) bool isPrimarySegmentRbg = m_ulPrimarySegmentRbgMap[rbgId]; bool isSecondarySegmentRbg = m_ulSecondarySegmentRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -641,7 +639,7 @@ LteFfrEnhancedAlgorithm::DoIsUlRbgAvailableForUe(int rbgId, uint16_t rnti) { // check if RB can be used by UE based on CQI information NS_LOG_INFO("UL SECONDARY SEGMENT RNTI: " << rnti << " rbgId: " << rbgId); - std::map>::iterator it = m_ulRbAvailableforUe.find(rnti); + auto it = m_ulRbAvailableforUe.find(rnti); if (it != m_ulRbAvailableforUe.end()) { NS_LOG_INFO("RNTI: " << rnti << " rbgId: " << rbgId @@ -670,10 +668,9 @@ LteFfrEnhancedAlgorithm::DoReportDlCqiInfo( { NS_LOG_INFO("subband CQI reporting high layer configured"); // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - std::map::iterator ueIt = m_ues.find(rnti); + auto ueIt = m_ues.find(rnti); if (ueIt != m_ues.end()) { if (ueIt->second != CenterArea) @@ -686,7 +683,7 @@ LteFfrEnhancedAlgorithm::DoReportDlCqiInfo( continue; } - it = m_dlCqi.find(rnti); + auto it = m_dlCqi.find(rnti); if (it == m_dlCqi.end()) { // create the new entry @@ -708,8 +705,7 @@ LteFfrEnhancedAlgorithm::DoReportDlCqiInfo( uint32_t rbgSize = GetRbgSize(m_dlBandwidth); m_dlRbgAvailableforUe.clear(); - std::map::iterator it; - for (it = m_dlCqi.begin(); it != m_dlCqi.end(); it++) + for (auto it = m_dlCqi.begin(); it != m_dlCqi.end(); it++) { uint16_t rnti = it->first; std::vector rbgAvailableMap; @@ -741,9 +737,7 @@ LteFfrEnhancedAlgorithm::DoReportDlCqiInfo( } m_ulRbAvailableforUe.clear(); - for (std::map>::iterator it = m_dlRbgAvailableforUe.begin(); - it != m_dlRbgAvailableforUe.end(); - it++) + for (auto it = m_dlRbgAvailableforUe.begin(); it != m_dlRbgAvailableforUe.end(); it++) { uint16_t rnti = it->first; std::vector dlRbgAvailableMap = it->second; @@ -796,7 +790,7 @@ LteFfrEnhancedAlgorithm::EstimateUlSinr(uint16_t rnti, uint16_t rb, std::map> ulCqiMap) { - std::map>::iterator itCqi = ulCqiMap.find(rnti); + auto itCqi = ulCqiMap.find(rnti); if (itCqi == ulCqiMap.end()) { // no cqi info about this UE @@ -844,7 +838,7 @@ LteFfrEnhancedAlgorithm::DoGetTpc(uint16_t rnti) //------------------------------------------------ // here Absolute mode is used - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { return 1; @@ -903,7 +897,7 @@ LteFfrEnhancedAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults me } else { - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); diff --git a/src/lte/model/lte-ffr-soft-algorithm.cc b/src/lte/model/lte-ffr-soft-algorithm.cc index a38ae488c..06e7c7344 100644 --- a/src/lte/model/lte-ffr-soft-algorithm.cc +++ b/src/lte/model/lte-ffr-soft-algorithm.cc @@ -424,7 +424,7 @@ LteFfrSoftAlgorithm::DoIsDlRbgAvailableForUe(int rbgId, uint16_t rnti) bool isMediumRbg = m_dlMediumRbgMap[rbgId]; bool isEdgeRbg = m_dlEdgeRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -485,7 +485,7 @@ LteFfrSoftAlgorithm::DoIsUlRbgAvailableForUe(int rbgId, uint16_t rnti) bool isMediumRbg = m_ulMediumRbgMap[rbgId]; bool isEdgeRbg = m_ulEdgeRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -563,7 +563,7 @@ LteFfrSoftAlgorithm::DoGetTpc(uint16_t rnti) //------------------------------------------------ // here Absolute mode is used - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { return 1; @@ -662,7 +662,7 @@ LteFfrSoftAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults measRe } else { - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); diff --git a/src/lte/model/lte-fr-soft-algorithm.cc b/src/lte/model/lte-fr-soft-algorithm.cc index c38e1e886..82b855202 100644 --- a/src/lte/model/lte-fr-soft-algorithm.cc +++ b/src/lte/model/lte-fr-soft-algorithm.cc @@ -359,7 +359,7 @@ LteFrSoftAlgorithm::DoIsDlRbgAvailableForUe(int rbgId, uint16_t rnti) bool edgeRbg = m_dlEdgeRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -405,7 +405,7 @@ LteFrSoftAlgorithm::DoIsUlRbgAvailableForUe(int rbgId, uint16_t rnti) bool edgeRbg = m_ulEdgeRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -470,7 +470,7 @@ LteFrSoftAlgorithm::DoGetTpc(uint16_t rnti) //------------------------------------------------ // here Absolute mode is used - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { return 1; @@ -536,7 +536,7 @@ LteFrSoftAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults measRes } else { - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); diff --git a/src/lte/model/lte-fr-strict-algorithm.cc b/src/lte/model/lte-fr-strict-algorithm.cc index d09a12c07..5ca8da0c7 100644 --- a/src/lte/model/lte-fr-strict-algorithm.cc +++ b/src/lte/model/lte-fr-strict-algorithm.cc @@ -397,7 +397,7 @@ LteFrStrictAlgorithm::DoIsDlRbgAvailableForUe(int rbgId, uint16_t rnti) bool edgeRbg = m_dlEdgeRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -438,7 +438,7 @@ LteFrStrictAlgorithm::DoIsUlRbgAvailableForUe(int rbgId, uint16_t rnti) bool edgeRbg = m_ulEdgeRbgMap[rbgId]; - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); @@ -498,7 +498,7 @@ LteFrStrictAlgorithm::DoGetTpc(uint16_t rnti) //------------------------------------------------ // here Absolute mode is used - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { return 1; @@ -548,7 +548,7 @@ LteFrStrictAlgorithm::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults measR } else { - std::map::iterator it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { m_ues.insert(std::pair(rnti, AreaUnset)); diff --git a/src/lte/model/lte-harq-phy.cc b/src/lte/model/lte-harq-phy.cc index 921a75bd1..df5580603 100644 --- a/src/lte/model/lte-harq-phy.cc +++ b/src/lte/model/lte-harq-phy.cc @@ -53,8 +53,7 @@ LteHarqPhy::SubframeIndication(uint32_t frameNo, uint32_t subframeNo) NS_LOG_FUNCTION(this); // left shift UL HARQ buffers - std::map>::iterator it; - for (it = m_miUlHarqProcessesInfoMap.begin(); it != m_miUlHarqProcessesInfoMap.end(); it++) + for (auto it = m_miUlHarqProcessesInfoMap.begin(); it != m_miUlHarqProcessesInfoMap.end(); it++) { (*it).second.erase((*it).second.begin()); HarqProcessInfoList_t h; @@ -87,8 +86,7 @@ LteHarqPhy::GetAccumulatedMiUl(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map>::iterator it; - it = m_miUlHarqProcessesInfoMap.find(rnti); + auto it = m_miUlHarqProcessesInfoMap.find(rnti); NS_ASSERT_MSG(it != m_miUlHarqProcessesInfoMap.end(), " Does not find MI for RNTI"); HarqProcessInfoList_t list = (*it).second.at(0); double mi = 0.0; @@ -103,8 +101,7 @@ HarqProcessInfoList_t LteHarqPhy::GetHarqProcessInfoUl(uint16_t rnti, uint8_t harqProcId) { NS_LOG_FUNCTION(this << rnti << (uint16_t)harqProcId); - std::map>::iterator it; - it = m_miUlHarqProcessesInfoMap.find(rnti); + auto it = m_miUlHarqProcessesInfoMap.find(rnti); if (it == m_miUlHarqProcessesInfoMap.end()) { // new entry @@ -157,8 +154,7 @@ LteHarqPhy::UpdateUlHarqProcessStatus(uint16_t rnti, uint16_t codeBytes) { NS_LOG_FUNCTION(this << rnti << mi); - std::map>::iterator it; - it = m_miUlHarqProcessesInfoMap.find(rnti); + auto it = m_miUlHarqProcessesInfoMap.find(rnti); if (it == m_miUlHarqProcessesInfoMap.end()) { // new entry @@ -199,8 +195,7 @@ void LteHarqPhy::ResetUlHarqProcessStatus(uint16_t rnti, uint8_t id) { NS_LOG_FUNCTION(this << rnti << (uint16_t)id); - std::map>::iterator it; - it = m_miUlHarqProcessesInfoMap.find(rnti); + auto it = m_miUlHarqProcessesInfoMap.find(rnti); if (it == m_miUlHarqProcessesInfoMap.end()) { // new entry diff --git a/src/lte/model/lte-interference.cc b/src/lte/model/lte-interference.cc index 8e332ebe8..f7dd0c846 100644 --- a/src/lte/model/lte-interference.cc +++ b/src/lte/model/lte-interference.cc @@ -72,24 +72,17 @@ LteInterference::StartRx(Ptr rxPsd) m_rxSignal = rxPsd->Copy(); m_lastChangeTime = Now(); m_receiving = true; - for (std::list>::const_iterator it = - m_rsPowerChunkProcessorList.begin(); - it != m_rsPowerChunkProcessorList.end(); + for (auto it = m_rsPowerChunkProcessorList.begin(); it != m_rsPowerChunkProcessorList.end(); ++it) { (*it)->Start(); } - for (std::list>::const_iterator it = - m_interfChunkProcessorList.begin(); - it != m_interfChunkProcessorList.end(); + for (auto it = m_interfChunkProcessorList.begin(); it != m_interfChunkProcessorList.end(); ++it) { (*it)->Start(); } - for (std::list>::const_iterator it = - m_sinrChunkProcessorList.begin(); - it != m_sinrChunkProcessorList.end(); - ++it) + for (auto it = m_sinrChunkProcessorList.begin(); it != m_sinrChunkProcessorList.end(); ++it) { (*it)->Start(); } @@ -117,24 +110,17 @@ LteInterference::EndRx() { ConditionallyEvaluateChunk(); m_receiving = false; - for (std::list>::const_iterator it = - m_rsPowerChunkProcessorList.begin(); - it != m_rsPowerChunkProcessorList.end(); + for (auto it = m_rsPowerChunkProcessorList.begin(); it != m_rsPowerChunkProcessorList.end(); ++it) { (*it)->End(); } - for (std::list>::const_iterator it = - m_interfChunkProcessorList.begin(); - it != m_interfChunkProcessorList.end(); + for (auto it = m_interfChunkProcessorList.begin(); it != m_interfChunkProcessorList.end(); ++it) { (*it)->End(); } - for (std::list>::const_iterator it = - m_sinrChunkProcessorList.begin(); - it != m_sinrChunkProcessorList.end(); - ++it) + for (auto it = m_sinrChunkProcessorList.begin(); it != m_sinrChunkProcessorList.end(); ++it) { (*it)->End(); } @@ -201,23 +187,16 @@ LteInterference::ConditionallyEvaluateChunk() SpectrumValue sinr = (*m_rxSignal) / interf; Time duration = Now() - m_lastChangeTime; - for (std::list>::const_iterator it = - m_sinrChunkProcessorList.begin(); - it != m_sinrChunkProcessorList.end(); - ++it) + for (auto it = m_sinrChunkProcessorList.begin(); it != m_sinrChunkProcessorList.end(); ++it) { (*it)->EvaluateChunk(sinr, duration); } - for (std::list>::const_iterator it = - m_interfChunkProcessorList.begin(); - it != m_interfChunkProcessorList.end(); + for (auto it = m_interfChunkProcessorList.begin(); it != m_interfChunkProcessorList.end(); ++it) { (*it)->EvaluateChunk(interf, duration); } - for (std::list>::const_iterator it = - m_rsPowerChunkProcessorList.begin(); - it != m_rsPowerChunkProcessorList.end(); + for (auto it = m_rsPowerChunkProcessorList.begin(); it != m_rsPowerChunkProcessorList.end(); ++it) { (*it)->EvaluateChunk(*m_rxSignal, duration); diff --git a/src/lte/model/lte-mi-error-model.cc b/src/lte/model/lte-mi-error-model.cc index 946042da0..d0c562ffb 100644 --- a/src/lte/model/lte-mi-error-model.cc +++ b/src/lte/model/lte-mi-error-model.cc @@ -1042,7 +1042,7 @@ LteMiErrorModel::GetPcfichPdcchError(const SpectrumValue& sinr) NS_LOG_FUNCTION(sinr); double MI; double MIsum = 0.0; - Values::const_iterator sinrIt = sinr.ConstValuesBegin(); + auto sinrIt = sinr.ConstValuesBegin(); uint16_t rb = 0; NS_ASSERT(sinrIt != sinr.ConstValuesEnd()); while (sinrIt != sinr.ConstValuesEnd()) diff --git a/src/lte/model/lte-rlc-am-header.cc b/src/lte/model/lte-rlc-am-header.cc index 56a476ee6..b6408ca10 100644 --- a/src/lte/model/lte-rlc-am-header.cc +++ b/src/lte/model/lte-rlc-am-header.cc @@ -248,8 +248,7 @@ LteRlcAmHeader::IsNackPresent(SequenceNumber10 nack) NS_LOG_FUNCTION(this); NS_ASSERT_MSG(m_dataControlBit == CONTROL_PDU && m_controlPduType == LteRlcAmHeader::STATUS_PDU, "method allowed only for STATUS PDUs"); - for (std::list::iterator nackIt = m_nackSnList.begin(); nackIt != m_nackSnList.end(); - ++nackIt) + for (auto nackIt = m_nackSnList.begin(); nackIt != m_nackSnList.end(); ++nackIt) { if ((*nackIt) == nack.GetValue()) { @@ -301,9 +300,9 @@ LteRlcAmHeader::GetInstanceTypeId() const void LteRlcAmHeader::Print(std::ostream& os) const { - std::list::const_iterator it1 = m_extensionBits.begin(); - std::list::const_iterator it2 = m_lengthIndicators.begin(); - std::list::const_iterator it3 = m_nackSnList.begin(); + auto it1 = m_extensionBits.begin(); + auto it2 = m_lengthIndicators.begin(); + auto it3 = m_nackSnList.begin(); os << "Len=" << m_headerLength; os << " D/C=" << (uint16_t)m_dataControlBit; @@ -362,9 +361,9 @@ LteRlcAmHeader::Serialize(Buffer::Iterator start) const { Buffer::Iterator i = start; - std::list::const_iterator it1 = m_extensionBits.begin(); - std::list::const_iterator it2 = m_lengthIndicators.begin(); - std::list::const_iterator it3 = m_nackSnList.begin(); + auto it1 = m_extensionBits.begin(); + auto it2 = m_lengthIndicators.begin(); + auto it3 = m_nackSnList.begin(); if (m_dataControlBit == DATA_PDU) { diff --git a/src/lte/model/lte-rlc-am.cc b/src/lte/model/lte-rlc-am.cc index d4e8ffc14..03c190e7a 100644 --- a/src/lte/model/lte-rlc-am.cc +++ b/src/lte/model/lte-rlc-am.cc @@ -238,7 +238,6 @@ LteRlcAm::DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParam << m_vrMs.GetValue()); SequenceNumber10 sn; sn.SetModulusBase(m_vrR); - std::map::iterator pduIt; for (sn = m_vrR; sn < m_vrMs; sn++) { NS_LOG_LOGIC("SN = " << sn); @@ -247,7 +246,7 @@ LteRlcAm::DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParam NS_LOG_LOGIC("Can't fit more NACKs in STATUS PDU"); break; } - pduIt = m_rxonBuffer.find(sn.GetValue()); + auto pduIt = m_rxonBuffer.find(sn.GetValue()); if (pduIt == m_rxonBuffer.end() || (!(pduIt->second.m_pduComplete))) { NS_LOG_LOGIC("adding NACK_SN " << sn.GetValue()); @@ -258,7 +257,7 @@ LteRlcAm::DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParam // 3GPP TS 36.322 section 6.2.2.1.4 ACK SN // find the SN of the next not received RLC Data PDU // which is not reported as missing in the STATUS PDU. - pduIt = m_rxonBuffer.find(sn.GetValue()); + auto pduIt = m_rxonBuffer.find(sn.GetValue()); while ((sn < m_vrMs) && (pduIt != m_rxonBuffer.end()) && (pduIt->second.m_pduComplete)) { NS_LOG_LOGIC("SN = " << sn << " < " << m_vrMs << " = " << (sn < m_vrMs)); @@ -660,8 +659,7 @@ LteRlcAm::DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParam // Calculate FramingInfo flag according the status of the SDUs in the DataField uint8_t framingInfo = 0; - std::vector>::iterator it; - it = dataField.begin(); + auto it = dataField.begin(); // FIRST SEGMENT LteRlcSduStatusTag tag; @@ -926,7 +924,7 @@ LteRlcAm::DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) // - discard the duplicate byte segments. // note: re-segmentation of AMD PDU is currently not supported, // so we just check that the segment was not received before - std::map::iterator it = m_rxonBuffer.find(seqNumber.GetValue()); + auto it = m_rxonBuffer.find(seqNumber.GetValue()); if (it != m_rxonBuffer.end()) { NS_ASSERT(!it->second.m_byteSegments.empty()); @@ -959,7 +957,7 @@ LteRlcAm::DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) // - update VR(MS) to the SN of the first AMD PDU with SN > current VR(MS) for // which not all byte segments have been received; - std::map::iterator it = m_rxonBuffer.find(m_vrMs.GetValue()); + auto it = m_rxonBuffer.find(m_vrMs.GetValue()); if (it != m_rxonBuffer.end() && it->second.m_pduComplete) { int firstVrMs = m_vrMs.GetValue(); @@ -986,7 +984,7 @@ LteRlcAm::DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) if (seqNumber == m_vrR) { - std::map::iterator it = m_rxonBuffer.find(seqNumber.GetValue()); + auto it = m_rxonBuffer.find(seqNumber.GetValue()); if (it != m_rxonBuffer.end() && it->second.m_pduComplete) { it = m_rxonBuffer.find(m_vrR.GetValue()); @@ -1243,15 +1241,19 @@ LteRlcAm::ReassembleAndDeliver(Ptr packet) } } while (extensionBit == 1); - std::list>::iterator it; - // Current reassembling state if (m_reassemblingState == WAITING_S0_FULL) + { NS_LOG_LOGIC("Reassembling State = 'WAITING_S0_FULL'"); + } else if (m_reassemblingState == WAITING_SI_SF) + { NS_LOG_LOGIC("Reassembling State = 'WAITING_SI_SF'"); + } else + { NS_LOG_LOGIC("Reassembling State = Unknown state"); + } // Received framing Info NS_LOG_LOGIC("Framing Info = " << (uint16_t)framingInfo); @@ -1271,7 +1273,7 @@ LteRlcAm::ReassembleAndDeliver(Ptr packet) /** * Deliver one or multiple PDUs */ - for (it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) + for (auto it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) { m_rlcSapUser->ReceivePdcpPdu(*it); } @@ -1401,7 +1403,7 @@ LteRlcAm::ReassembleAndDeliver(Ptr packet) /** * Deliver one or multiple PDUs */ - for (it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) + for (auto it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) { m_rlcSapUser->ReceivePdcpPdu(*it); } @@ -1702,7 +1704,7 @@ LteRlcAm::ExpireReorderingTimer() m_vrMs = m_vrX; int firstVrMs = m_vrMs.GetValue(); - std::map::iterator it = m_rxonBuffer.find(m_vrMs.GetValue()); + auto it = m_rxonBuffer.find(m_vrMs.GetValue()); while (it != m_rxonBuffer.end() && it->second.m_pduComplete) { m_vrMs++; diff --git a/src/lte/model/lte-rlc-header.cc b/src/lte/model/lte-rlc-header.cc index 5ed1b6f65..c79828ef6 100644 --- a/src/lte/model/lte-rlc-header.cc +++ b/src/lte/model/lte-rlc-header.cc @@ -127,8 +127,8 @@ LteRlcHeader::GetInstanceTypeId() const void LteRlcHeader::Print(std::ostream& os) const { - std::list::const_iterator it1 = m_extensionBits.begin(); - std::list::const_iterator it2 = m_lengthIndicators.begin(); + auto it1 = m_extensionBits.begin(); + auto it2 = m_lengthIndicators.begin(); os << "Len=" << m_headerLength; os << " FI=" << (uint16_t)m_framingInfo; @@ -168,8 +168,8 @@ LteRlcHeader::Serialize(Buffer::Iterator start) const { Buffer::Iterator i = start; - std::list::const_iterator it1 = m_extensionBits.begin(); - std::list::const_iterator it2 = m_lengthIndicators.begin(); + auto it1 = m_extensionBits.begin(); + auto it2 = m_lengthIndicators.begin(); i.WriteU8(((m_framingInfo << 3) & 0x18) | (((*it1) << 2) & 0x04) | ((m_sequenceNumber.GetValue() >> 8) & 0x0003)); diff --git a/src/lte/model/lte-rlc-um.cc b/src/lte/model/lte-rlc-um.cc index e25debe22..e14a105bd 100644 --- a/src/lte/model/lte-rlc-um.cc +++ b/src/lte/model/lte-rlc-um.cc @@ -364,8 +364,7 @@ LteRlcUm::DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParam rlcHeader.SetSequenceNumber(m_sequenceNumber++); // Build RLC PDU with DataField and Header - std::vector>::iterator it; - it = dataField.begin(); + auto it = dataField.begin(); uint8_t framingInfo = 0; @@ -557,11 +556,10 @@ LteRlcUm::DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) { NS_LOG_LOGIC("Reception buffer contains SN = " << m_vrUr); - std::map>::iterator it; uint16_t newVrUr; SequenceNumber10 oldVrUr = m_vrUr; - it = m_rxBuffer.find(m_vrUr.GetValue()); + auto it = m_rxBuffer.find(m_vrUr.GetValue()); newVrUr = (it->first) + 1; while (m_rxBuffer.count(newVrUr) > 0) { @@ -693,15 +691,19 @@ LteRlcUm::ReassembleAndDeliver(Ptr packet) } } while (extensionBit == 1); - std::list>::iterator it; - // Current reassembling state if (m_reassemblingState == WAITING_S0_FULL) + { NS_LOG_LOGIC("Reassembling State = 'WAITING_S0_FULL'"); + } else if (m_reassemblingState == WAITING_SI_SF) + { NS_LOG_LOGIC("Reassembling State = 'WAITING_SI_SF'"); + } else + { NS_LOG_LOGIC("Reassembling State = Unknown state"); + } // Received framing Info NS_LOG_LOGIC("Framing Info = " << (uint16_t)framingInfo); @@ -720,7 +722,7 @@ LteRlcUm::ReassembleAndDeliver(Ptr packet) /** * Deliver one or multiple PDUs */ - for (it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) + for (auto it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) { m_rlcSapUser->ReceivePdcpPdu(*it); } @@ -900,7 +902,7 @@ LteRlcUm::ReassembleAndDeliver(Ptr packet) /** * Deliver one or multiple PDUs */ - for (it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) + for (auto it = m_sdusBuffer.begin(); it != m_sdusBuffer.end(); it++) { m_rlcSapUser->ReceivePdcpPdu(*it); } @@ -1119,8 +1121,7 @@ LteRlcUm::ReassembleOutsideWindow() { NS_LOG_LOGIC("Reassemble Outside Window"); - std::map>::iterator it; - it = m_rxBuffer.begin(); + auto it = m_rxBuffer.begin(); while ((it != m_rxBuffer.end()) && !IsInsideReorderingWindow(SequenceNumber10(it->first))) { @@ -1129,7 +1130,7 @@ LteRlcUm::ReassembleOutsideWindow() // Reassemble RLC SDUs and deliver the PDCP PDU to upper layer ReassembleAndDeliver(it->second); - std::map>::iterator it_tmp = it; + auto it_tmp = it; ++it; m_rxBuffer.erase(it_tmp); } @@ -1145,15 +1146,13 @@ LteRlcUm::ReassembleSnInterval(SequenceNumber10 lowSeqNumber, SequenceNumber10 h { NS_LOG_LOGIC("Reassemble SN between " << lowSeqNumber << " and " << highSeqNumber); - std::map>::iterator it; - SequenceNumber10 reassembleSn = lowSeqNumber; NS_LOG_LOGIC("reassembleSN = " << reassembleSn); NS_LOG_LOGIC("highSeqNumber = " << highSeqNumber); while (reassembleSn < highSeqNumber) { NS_LOG_LOGIC("reassembleSn < highSeqNumber"); - it = m_rxBuffer.find(reassembleSn.GetValue()); + auto it = m_rxBuffer.find(reassembleSn.GetValue()); NS_LOG_LOGIC("it->first = " << it->first); NS_LOG_LOGIC("it->second = " << it->second); if (it != m_rxBuffer.end()) @@ -1214,10 +1213,9 @@ LteRlcUm::ExpireReorderingTimer() // - start t-Reordering; // - set VR(UX) to VR(UH). - std::map>::iterator it; SequenceNumber10 newVrUr = m_vrUx; - while ((it = m_rxBuffer.find(newVrUr.GetValue())) != m_rxBuffer.end()) + while (m_rxBuffer.find(newVrUr.GetValue()) != m_rxBuffer.end()) { newVrUr++; } diff --git a/src/lte/model/lte-rrc-header.cc b/src/lte/model/lte-rrc-header.cc index 4b28ff7c8..73bf1202f 100644 --- a/src/lte/model/lte-rrc-header.cc +++ b/src/lte/model/lte-rrc-header.cc @@ -138,7 +138,7 @@ RrcAsn1Header::SerializeDrbToAddModList(std::list drbToA SerializeSequenceOf(drbToAddModList.size(), MAX_DRB, 1); // Serialize the elements in the sequence-of list - std::list::iterator it = drbToAddModList.begin(); + auto it = drbToAddModList.begin(); for (; it != drbToAddModList.end(); it++) { // Serialize DRB-ToAddMod sequence @@ -226,7 +226,7 @@ RrcAsn1Header::SerializeSrbToAddModList(std::list srbToA SerializeSequenceOf(srbToAddModList.size(), 2, 1); // Serialize the elements in the sequence-of list - std::list::iterator it = srbToAddModList.begin(); + auto it = srbToAddModList.begin(); for (; it != srbToAddModList.end(); it++) { // Serialize SRB-ToAddMod sequence @@ -464,7 +464,7 @@ RrcAsn1Header::SerializeRadioResourceConfigDedicated( if (isDrbToReleaseListPresent) { SerializeSequenceOf(radioResourceConfigDedicated.drbToReleaseList.size(), MAX_DRB, 1); - std::list::iterator it = radioResourceConfigDedicated.drbToReleaseList.begin(); + auto it = radioResourceConfigDedicated.drbToReleaseList.begin(); for (; it != radioResourceConfigDedicated.drbToReleaseList.end(); it++) { // DRB-Identity ::= INTEGER (1..32) @@ -718,8 +718,7 @@ RrcAsn1Header::SerializeMeasResults(LteRrcSap::MeasResults measResults) const SerializeSequenceOf(measResults.measResultListEutra.size(), MAX_CELL_REPORT, 1); // serialize MeasResultEutra elements in the list - std::list::iterator it; - for (it = measResults.measResultListEutra.begin(); + for (auto it = measResults.measResultListEutra.begin(); it != measResults.measResultListEutra.end(); it++) { @@ -745,8 +744,7 @@ RrcAsn1Header::SerializeMeasResults(LteRrcSap::MeasResults measResults) const if (!it->cgiInfo.plmnIdentityList.empty()) { SerializeSequenceOf(it->cgiInfo.plmnIdentityList.size(), 5, 1); - std::list::iterator it2; - for (it2 = it->cgiInfo.plmnIdentityList.begin(); + for (auto it2 = it->cgiInfo.plmnIdentityList.begin(); it2 != it->cgiInfo.plmnIdentityList.end(); it2++) { @@ -1141,7 +1139,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!measConfig.measObjectToRemoveList.empty()) { SerializeSequenceOf(measConfig.measObjectToRemoveList.size(), MAX_OBJECT_ID, 1); - for (std::list::iterator it = measConfig.measObjectToRemoveList.begin(); + for (auto it = measConfig.measObjectToRemoveList.begin(); it != measConfig.measObjectToRemoveList.end(); it++) { @@ -1152,8 +1150,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!measConfig.measObjectToAddModList.empty()) { SerializeSequenceOf(measConfig.measObjectToAddModList.size(), MAX_OBJECT_ID, 1); - for (std::list::iterator it = - measConfig.measObjectToAddModList.begin(); + for (auto it = measConfig.measObjectToAddModList.begin(); it != measConfig.measObjectToAddModList.end(); it++) { @@ -1183,8 +1180,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!it->measObjectEutra.cellsToRemoveList.empty()) { SerializeSequenceOf(it->measObjectEutra.cellsToRemoveList.size(), MAX_CELL_MEAS, 1); - for (std::list::iterator it2 = - it->measObjectEutra.cellsToRemoveList.begin(); + for (auto it2 = it->measObjectEutra.cellsToRemoveList.begin(); it2 != it->measObjectEutra.cellsToRemoveList.end(); it2++) { @@ -1195,8 +1191,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!it->measObjectEutra.cellsToAddModList.empty()) { SerializeSequenceOf(it->measObjectEutra.cellsToAddModList.size(), MAX_CELL_MEAS, 1); - for (std::list::iterator it2 = - it->measObjectEutra.cellsToAddModList.begin(); + for (auto it2 = it->measObjectEutra.cellsToAddModList.begin(); it2 != it->measObjectEutra.cellsToAddModList.end(); it2++) { @@ -1218,8 +1213,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const SerializeSequenceOf(it->measObjectEutra.blackCellsToRemoveList.size(), MAX_CELL_MEAS, 1); - for (std::list::iterator it2 = - it->measObjectEutra.blackCellsToRemoveList.begin(); + for (auto it2 = it->measObjectEutra.blackCellsToRemoveList.begin(); it2 != it->measObjectEutra.blackCellsToRemoveList.end(); it2++) { @@ -1232,8 +1226,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const SerializeSequenceOf(it->measObjectEutra.blackCellsToAddModList.size(), MAX_CELL_MEAS, 1); - for (std::list::iterator it2 = - it->measObjectEutra.blackCellsToAddModList.begin(); + for (auto it2 = it->measObjectEutra.blackCellsToAddModList.begin(); it2 != it->measObjectEutra.blackCellsToAddModList.end(); it2++) { @@ -1242,7 +1235,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const // Serialize PhysCellIdRange // range optional - std::bitset<1> rangePresent = std::bitset<1>(it2->physCellIdRange.haveRange); + std::bitset<1> rangePresent(it2->physCellIdRange.haveRange); SerializeSequence(rangePresent, false); SerializeInteger(it2->physCellIdRange.start, 0, 503); if (it2->physCellIdRange.haveRange) @@ -1308,7 +1301,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!measConfig.reportConfigToRemoveList.empty()) { SerializeSequenceOf(measConfig.reportConfigToRemoveList.size(), MAX_REPORT_CONFIG_ID, 1); - for (std::list::iterator it = measConfig.reportConfigToRemoveList.begin(); + for (auto it = measConfig.reportConfigToRemoveList.begin(); it != measConfig.reportConfigToRemoveList.end(); it++) { @@ -1319,8 +1312,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!measConfig.reportConfigToAddModList.empty()) { SerializeSequenceOf(measConfig.reportConfigToAddModList.size(), MAX_REPORT_CONFIG_ID, 1); - for (std::list::iterator it = - measConfig.reportConfigToAddModList.begin(); + for (auto it = measConfig.reportConfigToAddModList.begin(); it != measConfig.reportConfigToAddModList.end(); it++) { @@ -1545,7 +1537,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!measConfig.measIdToRemoveList.empty()) { SerializeSequenceOf(measConfig.measIdToRemoveList.size(), MAX_MEAS_ID, 1); - for (std::list::iterator it = measConfig.measIdToRemoveList.begin(); + for (auto it = measConfig.measIdToRemoveList.begin(); it != measConfig.measIdToRemoveList.end(); it++) { @@ -1556,8 +1548,7 @@ RrcAsn1Header::SerializeMeasConfig(LteRrcSap::MeasConfig measConfig) const if (!measConfig.measIdToAddModList.empty()) { SerializeSequenceOf(measConfig.measIdToAddModList.size(), MAX_MEAS_ID, 1); - for (std::list::iterator it = - measConfig.measIdToAddModList.begin(); + for (auto it = measConfig.measIdToAddModList.begin(); it != measConfig.measIdToAddModList.end(); it++) { @@ -3067,8 +3058,7 @@ RrcAsn1Header::Print(std::ostream& os, LteRrcSap::RadioResourceConfigDedicated radioResourceConfigDedicated) const { os << " srbToAddModList: " << std::endl; - std::list::iterator it = - radioResourceConfigDedicated.srbToAddModList.begin(); + auto it = radioResourceConfigDedicated.srbToAddModList.begin(); for (; it != radioResourceConfigDedicated.srbToAddModList.end(); it++) { os << " srbIdentity: " << (int)it->srbIdentity << std::endl; @@ -3084,8 +3074,7 @@ RrcAsn1Header::Print(std::ostream& os, os << std::endl; os << " drbToAddModList: " << std::endl; - std::list::iterator it2 = - radioResourceConfigDedicated.drbToAddModList.begin(); + auto it2 = radioResourceConfigDedicated.drbToAddModList.begin(); for (; it2 != radioResourceConfigDedicated.drbToAddModList.end(); it2++) { os << " epsBearerIdentity: " << (int)it2->epsBearerIdentity << std::endl; @@ -3104,7 +3093,7 @@ RrcAsn1Header::Print(std::ostream& os, os << std::endl; os << " drbToReleaseList: "; - std::list::iterator it3 = radioResourceConfigDedicated.drbToReleaseList.begin(); + auto it3 = radioResourceConfigDedicated.drbToReleaseList.begin(); for (; it3 != radioResourceConfigDedicated.drbToReleaseList.end(); it3++) { os << (int)*it3 << ", "; @@ -5600,7 +5589,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const { os << " measObjectToRemoveList: "; std::list auxList = m_measConfig.measObjectToRemoveList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << (int)*it << ", "; @@ -5611,7 +5600,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const { os << " reportConfigToRemoveList: "; std::list auxList = m_measConfig.reportConfigToRemoveList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << (int)*it << ", "; @@ -5622,7 +5611,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const { os << " measIdToRemoveList: "; std::list auxList = m_measConfig.measIdToRemoveList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << (int)*it << ", "; @@ -5634,7 +5623,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const { os << " measObjectToAddMod: " << std::endl; std::list auxList = m_measConfig.measObjectToAddModList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << " measObjectId: " << (int)it->measObjectId << std::endl; @@ -5651,7 +5640,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const { os << " cellsToRemoveList: "; std::list auxList = it->measObjectEutra.cellsToRemoveList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << (int)*it << ", "; @@ -5663,7 +5652,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const { os << " blackCellsToRemoveList: "; std::list auxList = it->measObjectEutra.blackCellsToRemoveList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << (int)*it << ", "; @@ -5676,7 +5665,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const os << " cellsToAddModList: " << std::endl; std::list auxList = it->measObjectEutra.cellsToAddModList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << " cellIndex: " << (int)it->cellIndex << std::endl; @@ -5692,7 +5681,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const os << " blackCellsToAddModList: " << std::endl; std::list auxList = it->measObjectEutra.blackCellsToAddModList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << " cellIndex: " << (int)it->cellIndex << std::endl; @@ -5719,7 +5708,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const os << " reportConfigToAddModList: " << std::endl; std::list auxList = m_measConfig.reportConfigToAddModList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << " reportConfigId: " << (int)it->reportConfigId << std::endl; @@ -5777,7 +5766,7 @@ RrcConnectionReconfigurationHeader::Print(std::ostream& os) const { os << " measIdToAddModList: " << std::endl; std::list auxList = m_measConfig.measIdToAddModList; - std::list::iterator it = auxList.begin(); + auto it = auxList.begin(); for (; it != auxList.end(); it++) { os << " measId: " << (int)it->measId << std::endl; @@ -7061,7 +7050,7 @@ MeasurementReportHeader::Print(std::ostream& os) const { std::list measResultListEutra = m_measurementReport.measResults.measResultListEutra; - std::list::iterator it = measResultListEutra.begin(); + auto it = measResultListEutra.begin(); for (; it != measResultListEutra.end(); it++) { os << " physCellId =" << (int)it->physCellId << std::endl; @@ -7075,7 +7064,7 @@ MeasurementReportHeader::Print(std::ostream& os) const << std::endl; if (!it->cgiInfo.plmnIdentityList.empty()) { - for (std::list::iterator it2 = it->cgiInfo.plmnIdentityList.begin(); + for (auto it2 = it->cgiInfo.plmnIdentityList.begin(); it2 != it->cgiInfo.plmnIdentityList.end(); it2++) { diff --git a/src/lte/model/lte-rrc-protocol-ideal.cc b/src/lte/model/lte-rrc-protocol-ideal.cc index 7a11813d3..0c304b3e7 100644 --- a/src/lte/model/lte-rrc-protocol-ideal.cc +++ b/src/lte/model/lte-rrc-protocol-ideal.cc @@ -206,9 +206,9 @@ LteUeRrcProtocolIdeal::SetEnbRrcSapProvider() // walk list of all nodes to get the peer eNB Ptr enbDev; - NodeList::Iterator listEnd = NodeList::End(); + auto listEnd = NodeList::End(); bool found = false; - for (NodeList::Iterator i = NodeList::Begin(); (i != listEnd) && (!found); ++i) + for (auto i = NodeList::Begin(); (i != listEnd) && (!found); ++i) { Ptr node = *i; int nDevs = node->GetNDevices(); @@ -288,8 +288,7 @@ LteEnbRrcProtocolIdeal::SetCellId(uint16_t cellId) LteUeRrcSapProvider* LteEnbRrcProtocolIdeal::GetUeRrcSapProvider(uint16_t rnti) { - std::map::const_iterator it; - it = m_enbRrcSapProviderMap.find(rnti); + auto it = m_enbRrcSapProviderMap.find(rnti); NS_ASSERT_MSG(it != m_enbRrcSapProviderMap.end(), "could not find RNTI = " << rnti); return it->second; } @@ -297,8 +296,7 @@ LteEnbRrcProtocolIdeal::GetUeRrcSapProvider(uint16_t rnti) void LteEnbRrcProtocolIdeal::SetUeRrcSapProvider(uint16_t rnti, LteUeRrcSapProvider* p) { - std::map::iterator it; - it = m_enbRrcSapProviderMap.find(rnti); + auto it = m_enbRrcSapProviderMap.find(rnti); // assign UE RRC only if the RNTI is found at eNB if (it != m_enbRrcSapProviderMap.end()) { @@ -359,7 +357,7 @@ LteEnbRrcProtocolIdeal::DoSendSystemInformation(uint16_t cellId, LteRrcSap::Syst NS_LOG_FUNCTION(this << cellId); // walk list of all nodes to get UEs with this cellId Ptr ueRrc; - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr node = *i; int nDevs = node->GetNDevices(); @@ -576,8 +574,7 @@ LteEnbRrcProtocolIdeal::DoDecodeHandoverPreparationInformation(Ptr p) p->RemoveHeader(h); uint32_t msgId = h.GetMsgId(); NS_LOG_INFO(" decoding msgId = " << msgId); - std::map::iterator it = - g_handoverPreparationInfoMsgMap.find(msgId); + auto it = g_handoverPreparationInfoMsgMap.find(msgId); NS_ASSERT_MSG(it != g_handoverPreparationInfoMsgMap.end(), "msgId " << msgId << " not found"); LteRrcSap::HandoverPreparationInfo msg = it->second; g_handoverPreparationInfoMsgMap.erase(it); @@ -699,8 +696,7 @@ LteEnbRrcProtocolIdeal::DoDecodeHandoverCommand(Ptr p) p->RemoveHeader(h); uint32_t msgId = h.GetMsgId(); NS_LOG_INFO(" decoding msgId = " << msgId); - std::map::iterator it = - g_handoverCommandMsgMap.find(msgId); + auto it = g_handoverCommandMsgMap.find(msgId); NS_ASSERT_MSG(it != g_handoverCommandMsgMap.end(), "msgId " << msgId << " not found"); LteRrcSap::RrcConnectionReconfiguration msg = it->second; g_handoverCommandMsgMap.erase(it); diff --git a/src/lte/model/lte-rrc-protocol-real.cc b/src/lte/model/lte-rrc-protocol-real.cc index 13d67cd2c..962978777 100644 --- a/src/lte/model/lte-rrc-protocol-real.cc +++ b/src/lte/model/lte-rrc-protocol-real.cc @@ -269,9 +269,9 @@ LteUeRrcProtocolReal::SetEnbRrcSapProvider() // walk list of all nodes to get the peer eNB Ptr enbDev; - NodeList::Iterator listEnd = NodeList::End(); + auto listEnd = NodeList::End(); bool found = false; - for (NodeList::Iterator i = NodeList::Begin(); (i != listEnd) && (!found); ++i) + for (auto i = NodeList::Begin(); (i != listEnd) && (!found); ++i) { Ptr node = *i; int nDevs = node->GetNDevices(); @@ -400,8 +400,7 @@ LteEnbRrcProtocolReal::DoDispose() { NS_LOG_FUNCTION(this); delete m_enbRrcSapUser; - for (std::map::iterator it = - m_completeSetupUeParametersMap.begin(); + for (auto it = m_completeSetupUeParametersMap.begin(); it != m_completeSetupUeParametersMap.end(); ++it) { @@ -442,8 +441,7 @@ LteEnbRrcProtocolReal::SetCellId(uint16_t cellId) LteUeRrcSapProvider* LteEnbRrcProtocolReal::GetUeRrcSapProvider(uint16_t rnti) { - std::map::const_iterator it; - it = m_enbRrcSapProviderMap.find(rnti); + auto it = m_enbRrcSapProviderMap.find(rnti); NS_ASSERT_MSG(it != m_enbRrcSapProviderMap.end(), "could not find RNTI = " << rnti); return it->second; } @@ -451,8 +449,7 @@ LteEnbRrcProtocolReal::GetUeRrcSapProvider(uint16_t rnti) void LteEnbRrcProtocolReal::SetUeRrcSapProvider(uint16_t rnti, LteUeRrcSapProvider* p) { - std::map::iterator it; - it = m_enbRrcSapProviderMap.find(rnti); + auto it = m_enbRrcSapProviderMap.find(rnti); // assign UE RRC only if the RNTI is found at eNB if (it != m_enbRrcSapProviderMap.end()) { @@ -503,8 +500,7 @@ LteEnbRrcProtocolReal::DoSetupUe(uint16_t rnti, LteEnbRrcSapUser::SetupUeParamet m_setupUeParametersMap[rnti] = params; LteEnbRrcSapProvider::CompleteSetupUeParameters completeSetupUeParameters; - std::map::iterator csupIt = - m_completeSetupUeParametersMap.find(rnti); + auto csupIt = m_completeSetupUeParametersMap.find(rnti); if (csupIt == m_completeSetupUeParametersMap.end()) { // Create LteRlcSapUser, LtePdcpSapUser @@ -527,8 +523,7 @@ void LteEnbRrcProtocolReal::DoRemoveUe(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = - m_completeSetupUeParametersMap.find(rnti); + auto it = m_completeSetupUeParametersMap.find(rnti); NS_ASSERT(it != m_completeSetupUeParametersMap.end()); delete it->second.srb0SapUser; delete it->second.srb1SapUser; @@ -543,7 +538,7 @@ LteEnbRrcProtocolReal::DoSendSystemInformation(uint16_t cellId, LteRrcSap::Syste NS_LOG_FUNCTION(this << cellId); // walk list of all nodes to get UEs with this cellId Ptr ueRrc; - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr node = *i; int nDevs = node->GetNDevices(); diff --git a/src/lte/model/lte-spectrum-phy.cc b/src/lte/model/lte-spectrum-phy.cc index 680969b6b..4aba82900 100644 --- a/src/lte/model/lte-spectrum-phy.cc +++ b/src/lte/model/lte-spectrum-phy.cc @@ -911,11 +911,10 @@ LteSpectrumPhy::AddExpectedTb(uint16_t rnti, TbId_t tbId; tbId.m_rnti = rnti; tbId.m_layer = layer; - expectedTbs_t::iterator it; - it = m_expectedTbs.find(tbId); + auto it = m_expectedTbs.find(tbId); if (it != m_expectedTbs.end()) { - // might be a TB of an unreceived packet (due to high progpalosses) + // might be a TB of an unreceived packet (due to high propagation losses) m_expectedTbs.erase(it); } // insert new entry @@ -933,8 +932,7 @@ LteSpectrumPhy::RemoveExpectedTb(uint16_t rnti) for (uint8_t i = 0; i < 2; i++) { tbId.m_layer = i; - expectedTbs_t::iterator it; - it = m_expectedTbs.find(tbId); + auto it = m_expectedTbs.find(tbId); if (it != m_expectedTbs.end()) { m_expectedTbs.erase(it); @@ -955,7 +953,7 @@ LteSpectrumPhy::EndRxData() m_interferenceData->EndRx(); NS_LOG_DEBUG(this << " No. of burts " << m_rxPacketBurstList.size()); NS_LOG_DEBUG(this << " Expected TBs " << m_expectedTbs.size()); - expectedTbs_t::iterator itTb = m_expectedTbs.begin(); + auto itTb = m_expectedTbs.begin(); // apply transmission mode gain NS_LOG_DEBUG(this << " txMode " << (uint16_t)m_transmissionMode << " gain " @@ -1029,11 +1027,9 @@ LteSpectrumPhy::EndRxData() itTb++; } std::map harqDlInfoMap; - for (std::list>::const_iterator i = m_rxPacketBurstList.begin(); - i != m_rxPacketBurstList.end(); - ++i) + for (auto i = m_rxPacketBurstList.begin(); i != m_rxPacketBurstList.end(); ++i) { - for (std::list>::const_iterator j = (*i)->Begin(); j != (*i)->End(); ++j) + for (auto j = (*i)->Begin(); j != (*i)->End(); ++j) { // retrieve TB info of this packet LteRadioBearerTag tag; @@ -1094,8 +1090,7 @@ LteSpectrumPhy::EndRxData() } else { - std::map::iterator itHarq = - harqDlInfoMap.find(tbId.m_rnti); + auto itHarq = harqDlInfoMap.find(tbId.m_rnti); if (itHarq == harqDlInfoMap.end()) { DlInfoListElement_s harqDlInfo; @@ -1170,8 +1165,7 @@ LteSpectrumPhy::EndRxData() } // send DL HARQ feedback to LtePhy - std::map::iterator itHarq; - for (itHarq = harqDlInfoMap.begin(); itHarq != harqDlInfoMap.end(); itHarq++) + for (auto itHarq = harqDlInfoMap.begin(); itHarq != harqDlInfoMap.end(); itHarq++) { if (!m_ltePhyDlHarqFeedbackCallback.IsNull()) { diff --git a/src/lte/model/lte-spectrum-value-helper.cc b/src/lte/model/lte-spectrum-value-helper.cc index dbf37242e..366f0e1c1 100644 --- a/src/lte/model/lte-spectrum-value-helper.cc +++ b/src/lte/model/lte-spectrum-value-helper.cc @@ -43,7 +43,7 @@ namespace std ostream& operator<<(ostream& os, const vector& v) { - vector::const_iterator it = v.begin(); + auto it = v.begin(); while (it != v.end()) { os << *it << " "; @@ -252,7 +252,7 @@ LteSpectrumValueHelper::GetSpectrumModel(uint32_t earfcn, uint16_t txBandwidthCo NS_LOG_FUNCTION(earfcn << txBandwidthConfiguration); Ptr ret; LteSpectrumModelId key(earfcn, txBandwidthConfiguration); - std::map>::iterator it = g_lteSpectrumModelMap.find(key); + auto it = g_lteSpectrumModelMap.find(key); if (it != g_lteSpectrumModelMap.end()) { ret = it->second; @@ -297,7 +297,7 @@ LteSpectrumValueHelper::CreateTxPowerSpectralDensity(uint32_t earfcn, double txPowerDensity = (powerTxW / (txBandwidthConfiguration * 180000)); - for (std::vector::iterator it = activeRbs.begin(); it != activeRbs.end(); it++) + for (auto it = activeRbs.begin(); it != activeRbs.end(); it++) { int rbId = (*it); (*txPsd)[rbId] = txPowerDensity; @@ -323,11 +323,11 @@ LteSpectrumValueHelper::CreateTxPowerSpectralDensity(uint32_t earfcn, // powerTx is expressed in dBm. We must convert it into natural unit. double basicPowerTxW = std::pow(10., (powerTx - 30) / 10); - for (std::vector::iterator it = activeRbs.begin(); it != activeRbs.end(); it++) + for (auto it = activeRbs.begin(); it != activeRbs.end(); it++) { int rbId = (*it); - std::map::iterator powerIt = powerTxMap.find(rbId); + auto powerIt = powerTxMap.find(rbId); double txPowerDensity; @@ -365,7 +365,7 @@ LteSpectrumValueHelper::CreateUlTxPowerSpectralDensity(uint16_t earfcn, double txPowerDensity = (powerTxW / (activeRbs.size() * 180000)); - for (std::vector::iterator it = activeRbs.begin(); it != activeRbs.end(); it++) + for (auto it = activeRbs.begin(); it != activeRbs.end(); it++) { int rbId = (*it); (*txPsd)[rbId] = txPowerDensity; diff --git a/src/lte/model/lte-ue-component-carrier-manager.cc b/src/lte/model/lte-ue-component-carrier-manager.cc index 7cfc28b95..94db8f7f5 100644 --- a/src/lte/model/lte-ue-component-carrier-manager.cc +++ b/src/lte/model/lte-ue-component-carrier-manager.cc @@ -77,8 +77,7 @@ LteUeComponentCarrierManager::SetComponentCarrierMacSapProviders(uint8_t compone { NS_LOG_FUNCTION(this); bool result = false; - std::map::iterator it; - it = m_macSapProvidersMap.find(componentCarrierId); + auto it = m_macSapProvidersMap.find(componentCarrierId); if (componentCarrierId > m_noOfComponentCarriers) { NS_FATAL_ERROR("Inconsistent componentCarrierId or you didn't call " diff --git a/src/lte/model/lte-ue-mac.cc b/src/lte/model/lte-ue-mac.cc index 5518f3dec..93131db99 100644 --- a/src/lte/model/lte-ue-mac.cc +++ b/src/lte/model/lte-ue-mac.cc @@ -333,9 +333,7 @@ LteUeMac::DoReportBufferStatus(LteMacSapProvider::ReportBufferStatusParameters p { NS_LOG_FUNCTION(this << (uint32_t)params.lcid); - std::map::iterator it; - - it = m_ulBsrReceived.find(params.lcid); + auto it = m_ulBsrReceived.find(params.lcid); if (it != m_ulBsrReceived.end()) { // update entry @@ -371,13 +369,11 @@ LteUeMac::SendReportBufferStatus() bsr.m_macCeType = MacCeListElement_s::BSR; // BSR is reported for each LCG - std::map::iterator it; std::vector queue(4, 0); // one value per each of the 4 LCGs, initialized to 0 - for (it = m_ulBsrReceived.begin(); it != m_ulBsrReceived.end(); it++) + for (auto it = m_ulBsrReceived.begin(); it != m_ulBsrReceived.end(); it++) { uint8_t lcid = it->first; - std::map::iterator lcInfoMapIt; - lcInfoMapIt = m_lcInfoMap.find(lcid); + auto lcInfoMapIt = m_lcInfoMap.find(lcid); NS_ASSERT(lcInfoMapIt != m_lcInfoMap.end()); NS_ASSERT_MSG((lcid != 0) || (((*it).second.txQueueSize == 0) && ((*it).second.retxQueueSize == 0) && @@ -462,10 +458,9 @@ LteUeMac::RecvRaResponse(BuildRarListElement_s raResponse) // trigger tx opportunity for Message 3 over LC 0 // this is needed since Message 3's UL GRANT is in the RAR, not in UL-DCIs const uint8_t lc0Lcid = 0; - std::map::iterator lc0InfoIt = m_lcInfoMap.find(lc0Lcid); + auto lc0InfoIt = m_lcInfoMap.find(lc0Lcid); NS_ASSERT(lc0InfoIt != m_lcInfoMap.end()); - std::map::iterator lc0BsrIt = - m_ulBsrReceived.find(lc0Lcid); + auto lc0BsrIt = m_ulBsrReceived.find(lc0Lcid); if ((lc0BsrIt != m_ulBsrReceived.end()) && (lc0BsrIt->second.txQueueSize > 0)) { NS_ASSERT_MSG(raResponse.m_grant.m_tbSize > lc0BsrIt->second.txQueueSize, @@ -596,7 +591,7 @@ void LteUeMac::DoReset() { NS_LOG_FUNCTION(this); - std::map::iterator it = m_lcInfoMap.begin(); + auto it = m_lcInfoMap.begin(); while (it != m_lcInfoMap.end()) { // don't delete CCCH) @@ -633,7 +628,7 @@ LteUeMac::DoReceivePhyPdu(Ptr p) if (tag.GetRnti() == m_rnti) { // packet is for the current user - std::map::const_iterator it = m_lcInfoMap.find(tag.GetLcid()); + auto it = m_lcInfoMap.find(tag.GetLcid()); if (it != m_lcInfoMap.end()) { LteMacSapUser::ReceivePduParameters rxPduParams; @@ -663,10 +658,9 @@ LteUeMac::DoReceiveLteControlMessage(Ptr msg) Ptr pb = CreateObject(); m_miUlHarqProcessesPacket.at(m_harqProcessId) = pb; // Retrieve data from RLC - std::map::iterator itBsr; uint16_t activeLcs = 0; uint32_t statusPduMinSize = 0; - for (itBsr = m_ulBsrReceived.begin(); itBsr != m_ulBsrReceived.end(); itBsr++) + for (auto itBsr = m_ulBsrReceived.begin(); itBsr != m_ulBsrReceived.end(); itBsr++) { if (((*itBsr).second.statusPduSize > 0) || ((*itBsr).second.retxQueueSize > 0) || ((*itBsr).second.txQueueSize > 0)) @@ -688,7 +682,6 @@ LteUeMac::DoReceiveLteControlMessage(Ptr msg) NS_LOG_ERROR(this << " No active flows for this UL-DCI"); return; } - std::map::iterator it; uint32_t bytesPerActiveLc = dci.m_tbSize / activeLcs; bool statusPduPriority = false; if ((statusPduMinSize != 0) && (bytesPerActiveLc < statusPduMinSize)) @@ -709,9 +702,9 @@ LteUeMac::DoReceiveLteControlMessage(Ptr msg) LteMacSapUser::TxOpportunityParameters txOpParams; - for (it = m_lcInfoMap.begin(); it != m_lcInfoMap.end(); it++) + for (auto it = m_lcInfoMap.begin(); it != m_lcInfoMap.end(); it++) { - itBsr = m_ulBsrReceived.find((*it).first); + auto itBsr = m_ulBsrReceived.find((*it).first); NS_LOG_DEBUG(this << " Processing LC " << (uint32_t)(*it).first << " bytesPerActiveLc " << bytesPerActiveLc); if ((itBsr != m_ulBsrReceived.end()) && @@ -849,7 +842,7 @@ LteUeMac::DoReceiveLteControlMessage(Ptr msg) // HARQ retransmission -> retrieve data from HARQ buffer NS_LOG_DEBUG(this << " UE MAC RETX HARQ " << (uint16_t)m_harqProcessId); Ptr pb = m_miUlHarqProcessesPacket.at(m_harqProcessId); - for (std::list>::const_iterator j = pb->Begin(); j != pb->End(); ++j) + for (auto j = pb->Begin(); j != pb->End(); ++j) { Ptr pkt = (*j)->Copy(); m_uePhySapProvider->SendMacPdu(pkt); @@ -867,10 +860,7 @@ LteUeMac::DoReceiveLteControlMessage(Ptr msg) << (uint32_t)m_raRnti); if (raRnti == m_raRnti) // RAR corresponds to TX subframe of preamble { - for (std::list::const_iterator it = - rarMsg->RarListBegin(); - it != rarMsg->RarListEnd(); - ++it) + for (auto it = rarMsg->RarListBegin(); it != rarMsg->RarListEnd(); ++it) { if (it->rapId == m_raPreambleId) // RAR is for me { diff --git a/src/lte/model/lte-ue-net-device.cc b/src/lte/model/lte-ue-net-device.cc index eb21cf1d2..213b36a66 100644 --- a/src/lte/model/lte-ue-net-device.cc +++ b/src/lte/model/lte-ue-net-device.cc @@ -267,8 +267,7 @@ LteUeNetDevice::DoInitialize() m_isConstructed = true; UpdateConfig(); - std::map>::iterator it; - for (it = m_ccMap.begin(); it != m_ccMap.end(); ++it) + for (auto it = m_ccMap.begin(); it != m_ccMap.end(); ++it) { it->second->GetPhy()->Initialize(); it->second->GetMac()->Initialize(); diff --git a/src/lte/model/lte-ue-phy.cc b/src/lte/model/lte-ue-phy.cc index 9aa484b99..9daff28b1 100644 --- a/src/lte/model/lte-ue-phy.cc +++ b/src/lte/model/lte-ue-phy.cc @@ -609,8 +609,8 @@ LteUePhy::GenerateCqiRsrpRsrq(const SpectrumValue& sinr) // RSRP evaluated as averaged received power among RBs double sum = 0.0; uint8_t rbNum = 0; - Values::const_iterator it; - for (it = m_rsReceivedPower.ConstValuesBegin(); it != m_rsReceivedPower.ConstValuesEnd(); + for (auto it = m_rsReceivedPower.ConstValuesBegin(); + it != m_rsReceivedPower.ConstValuesEnd(); it++) { // convert PSD [W/Hz] to linear power [W] for the single RE @@ -648,14 +648,14 @@ LteUePhy::GenerateCqiRsrpRsrq(const SpectrumValue& sinr) // measure instantaneous RSRQ now NS_ASSERT_MSG(m_rsInterferencePowerUpdated, " RS interference power info obsolete"); - std::list::iterator itPss = m_pssList.begin(); + auto itPss = m_pssList.begin(); while (itPss != m_pssList.end()) { uint16_t rbNum = 0; double rssiSum = 0.0; - Values::const_iterator itIntN = m_rsInterferencePower.ConstValuesBegin(); - Values::const_iterator itPj = m_rsReceivedPower.ConstValuesBegin(); + auto itIntN = m_rsInterferencePower.ConstValuesBegin(); + auto itPj = m_rsReceivedPower.ConstValuesBegin(); for (itPj = m_rsReceivedPower.ConstValuesBegin(); itPj != m_rsReceivedPower.ConstValuesEnd(); itIntN++, itPj++) @@ -675,8 +675,7 @@ LteUePhy::GenerateCqiRsrpRsrq(const SpectrumValue& sinr) NS_LOG_INFO(this << " PSS RNTI " << m_rnti << " cellId " << m_cellId << " has RSRQ " << rsrq_dB << " and RBnum " << rbNum); // store measurements - std::map::iterator itMeasMap; - itMeasMap = m_ueMeasurementsMap.find((*itPss).cellId); + auto itMeasMap = m_ueMeasurementsMap.find((*itPss).cellId); if (itMeasMap != m_ueMeasurementsMap.end()) { (*itMeasMap).second.rsrqSum += rsrq_dB; @@ -706,9 +705,8 @@ LteUePhy::ComputeAvgSinr(const SpectrumValue& sinr) // averaged SINR among RBs double sum = 0.0; uint8_t rbNum = 0; - Values::const_iterator it; - for (it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) + for (auto it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++) { sum += (*it); rbNum++; @@ -818,8 +816,8 @@ LteUePhy::ReportRsReceivedPower(const SpectrumValue& power) if (m_enableUplinkPowerControl) { double sum = 0; - Values::const_iterator it; - for (it = m_rsReceivedPower.ConstValuesBegin(); it != m_rsReceivedPower.ConstValuesEnd(); + for (auto it = m_rsReceivedPower.ConstValuesBegin(); + it != m_rsReceivedPower.ConstValuesEnd(); it++) { double powerTxW = ((*it) * 180000); @@ -940,8 +938,7 @@ LteUePhy::ReportUeMeasurements() LteUeCphySapUser::UeMeasurementsParameters ret; - std::map::iterator it; - for (it = m_ueMeasurementsMap.begin(); it != m_ueMeasurementsMap.end(); it++) + for (auto it = m_ueMeasurementsMap.begin(); it != m_ueMeasurementsMap.end(); it++) { double avg_rsrp = (*it).second.rsrpSum / (double)(*it).second.rsrpNum; double avg_rsrq = (*it).second.rsrqSum / (double)(*it).second.rsrqNum; @@ -1029,10 +1026,9 @@ LteUePhy::ReceiveLteControlMessageList(std::list> msgList { NS_LOG_FUNCTION(this); - std::list>::iterator it; NS_LOG_DEBUG(this << " I am rnti = " << m_rnti << " and I received msgs " << (uint16_t)msgList.size()); - for (it = msgList.begin(); it != msgList.end(); it++) + for (auto it = msgList.begin(); it != msgList.end(); it++) { Ptr msg = (*it); @@ -1135,10 +1131,7 @@ LteUePhy::ReceiveLteControlMessageList(std::list> msgList Ptr rarMsg = DynamicCast(msg); if (rarMsg->GetRaRnti() == m_raRnti) { - for (std::list::const_iterator it = - rarMsg->RarListBegin(); - it != rarMsg->RarListEnd(); - ++it) + for (auto it = rarMsg->RarListBegin(); it != rarMsg->RarListEnd(); ++it) { if (it->rapId != m_raPreambleId) { @@ -1195,8 +1188,7 @@ LteUePhy::ReceivePss(uint16_t cellId, Ptr p) double sum = 0.0; uint16_t nRB = 0; - Values::const_iterator itPi; - for (itPi = p->ConstValuesBegin(); itPi != p->ConstValuesEnd(); itPi++) + for (auto itPi = p->ConstValuesBegin(); itPi != p->ConstValuesEnd(); itPi++) { // convert PSD [W/Hz] to linear power [W] for the single RE double powerTxW = ((*itPi) * 180000.0) / 12.0; @@ -1211,8 +1203,7 @@ LteUePhy::ReceivePss(uint16_t cellId, Ptr p) // note that m_pssReceptionThreshold does not apply here // store measurements - std::map::iterator itMeasMap = - m_ueMeasurementsMap.find(cellId); + auto itMeasMap = m_ueMeasurementsMap.find(cellId); if (itMeasMap == m_ueMeasurementsMap.end()) { // insert new entry diff --git a/src/lte/model/lte-ue-rrc.cc b/src/lte/model/lte-ue-rrc.cc index 4e600a86a..ae7ebe879 100644 --- a/src/lte/model/lte-ue-rrc.cc +++ b/src/lte/model/lte-ue-rrc.cc @@ -591,7 +591,7 @@ LteUeRrc::DoSendData(Ptr packet, uint8_t bid) if (drbid != 0) { - std::map>::iterator it = m_drbMap.find(drbid); + auto it = m_drbMap.find(drbid); NS_ASSERT_MSG(it != m_drbMap.end(), "could not find bearer with drbid == " << drbid); LtePdcpSapProvider::TransmitPdcpSduParameters params; @@ -681,8 +681,7 @@ LteUeRrc::DoNotifyRandomAccessSuccessful() m_rrcSapUser->SendRrcConnectionReconfigurationCompleted(msg); // 3GPP TS 36.331 section 5.5.6.1 Measurements related actions upon handover - std::map::iterator measIdIt; - for (measIdIt = m_varMeasConfig.measIdList.begin(); + for (auto measIdIt = m_varMeasConfig.measIdList.begin(); measIdIt != m_varMeasConfig.measIdList.end(); ++measIdIt) { @@ -917,8 +916,7 @@ LteUeRrc::DoReportUeMeasurements(LteUeCphySapUser::UeMeasurementsParameters para // layer 3 filtering does not apply in IDLE mode bool useLayer3Filtering = (m_state == CONNECTED_NORMALLY); bool triggering = true; - std::vector::iterator newMeasIt; - for (newMeasIt = params.m_ueMeasurementsList.begin(); + for (auto newMeasIt = params.m_ueMeasurementsList.begin(); newMeasIt != params.m_ueMeasurementsList.end(); ++newMeasIt) { @@ -943,8 +941,7 @@ LteUeRrc::DoReportUeMeasurements(LteUeCphySapUser::UeMeasurementsParameters para { if (triggering) { - std::map::iterator measIdIt; - for (measIdIt = m_varMeasConfig.measIdList.begin(); + for (auto measIdIt = m_varMeasConfig.measIdList.begin(); measIdIt != m_varMeasConfig.measIdList.end(); ++measIdIt) { @@ -1248,8 +1245,7 @@ LteUeRrc::SynchronizeToStrongestCell() double maxRsrp = -std::numeric_limits::infinity(); double minRsrp = -140.0; // Minimum RSRP in dBm a UE can report - std::map::iterator it; - for (it = m_storedMeasValues.begin(); it != m_storedMeasValues.end(); it++) + for (auto it = m_storedMeasValues.begin(); it != m_storedMeasValues.end(); it++) { /* * This block attempts to find a cell with strongest RSRP and has not @@ -1257,8 +1253,7 @@ LteUeRrc::SynchronizeToStrongestCell() */ if (maxRsrp < it->second.rsrp && it->second.rsrp > minRsrp) { - std::set::const_iterator itCell; - itCell = m_acceptableCell.find(it->first); + auto itCell = m_acceptableCell.find(it->first); if (itCell == m_acceptableCell.end()) { maxRsrpCellId = it->first; @@ -1294,7 +1289,7 @@ LteUeRrc::EvaluateCellForSelection() bool isSuitableCell = false; bool isAcceptableCell = false; - std::map::iterator storedMeasIt = m_storedMeasValues.find(cellId); + auto storedMeasIt = m_storedMeasValues.find(cellId); double qRxLevMeas = storedMeasIt->second.rsrp; double qRxLevMin = EutranMeasurementMapping::IeValue2ActualQRxLevMin(m_lastSib1.cellSelectionInfo.qRxLevMin); @@ -1437,7 +1432,7 @@ LteUeRrc::ApplyRadioResourceConfigDedicated(LteRrcSap::RadioResourceConfigDedica m_cphySapProvider.at(0)->SetPa(paDouble); } - std::list::const_iterator stamIt = rrcd.srbToAddModList.begin(); + auto stamIt = rrcd.srbToAddModList.begin(); if (stamIt != rrcd.srbToAddModList.end()) { if (!m_srb1) @@ -1498,8 +1493,7 @@ LteUeRrc::ApplyRadioResourceConfigDedicated(LteRrcSap::RadioResourceConfigDedica } } - std::list::const_iterator dtamIt; - for (dtamIt = rrcd.drbToAddModList.begin(); dtamIt != rrcd.drbToAddModList.end(); ++dtamIt) + for (auto dtamIt = rrcd.drbToAddModList.begin(); dtamIt != rrcd.drbToAddModList.end(); ++dtamIt) { NS_LOG_INFO(this << " IMSI " << m_imsi << " adding/modifying DRBID " << (uint32_t)dtamIt->drbIdentity << " LC " @@ -1507,8 +1501,7 @@ LteUeRrc::ApplyRadioResourceConfigDedicated(LteRrcSap::RadioResourceConfigDedica NS_ASSERT_MSG(dtamIt->logicalChannelIdentity > 2, "LCID value " << dtamIt->logicalChannelIdentity << " is reserved for SRBs"); - std::map>::iterator drbMapIt = - m_drbMap.find(dtamIt->drbIdentity); + auto drbMapIt = m_drbMap.find(dtamIt->drbIdentity); if (drbMapIt == m_drbMap.end()) { NS_LOG_INFO("New Data Radio Bearer"); @@ -1585,8 +1578,7 @@ LteUeRrc::ApplyRadioResourceConfigDedicated(LteRrcSap::RadioResourceConfigDedica rlc->GetLteMacSapUser()); NS_LOG_DEBUG("Size of lcOnCcMapping vector " << lcOnCcMapping.size()); - std::vector::iterator itLcOnCcMapping = - lcOnCcMapping.begin(); + auto itLcOnCcMapping = lcOnCcMapping.begin(); NS_ASSERT_MSG(itLcOnCcMapping != lcOnCcMapping.end(), "Component carrier manager failed to add LC for data radio bearer"); @@ -1617,12 +1609,12 @@ LteUeRrc::ApplyRadioResourceConfigDedicated(LteRrcSap::RadioResourceConfigDedica } } - std::list::iterator dtdmIt; - for (dtdmIt = rrcd.drbToReleaseList.begin(); dtdmIt != rrcd.drbToReleaseList.end(); ++dtdmIt) + for (auto dtdmIt = rrcd.drbToReleaseList.begin(); dtdmIt != rrcd.drbToReleaseList.end(); + ++dtdmIt) { uint8_t drbid = *dtdmIt; NS_LOG_INFO(this << " IMSI " << m_imsi << " releasing DRB " << (uint32_t)drbid); - std::map>::iterator it = m_drbMap.find(drbid); + auto it = m_drbMap.find(drbid); NS_ASSERT_MSG(it != m_drbMap.end(), "could not find bearer with given lcid"); m_drbMap.erase(it); m_bid2DrbidMap.erase(drbid); @@ -1642,15 +1634,12 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) // perform the actions specified in 3GPP TS 36.331 section 5.5.2.1 // 3GPP TS 36.331 section 5.5.2.4 Measurement object removal - for (std::list::iterator it = mc.measObjectToRemoveList.begin(); - it != mc.measObjectToRemoveList.end(); - ++it) + for (auto it = mc.measObjectToRemoveList.begin(); it != mc.measObjectToRemoveList.end(); ++it) { uint8_t measObjectId = *it; NS_LOG_LOGIC(this << " deleting measObjectId " << (uint32_t)measObjectId); m_varMeasConfig.measObjectList.erase(measObjectId); - std::map::iterator measIdIt = - m_varMeasConfig.measIdList.begin(); + auto measIdIt = m_varMeasConfig.measIdList.begin(); while (measIdIt != m_varMeasConfig.measIdList.end()) { if (measIdIt->second.measObjectId == measObjectId) @@ -1672,9 +1661,7 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) } // 3GPP TS 36.331 section 5.5.2.5 Measurement object addition/ modification - for (std::list::iterator it = mc.measObjectToAddModList.begin(); - it != mc.measObjectToAddModList.end(); - ++it) + for (auto it = mc.measObjectToAddModList.begin(); it != mc.measObjectToAddModList.end(); ++it) { // simplifying assumptions NS_ASSERT_MSG(it->measObjectEutra.cellsToRemoveList.empty(), @@ -1689,14 +1676,12 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) "cellForWhichToReportCGI is not supported"); uint8_t measObjectId = it->measObjectId; - std::map::iterator measObjectIt = - m_varMeasConfig.measObjectList.find(measObjectId); + auto measObjectIt = m_varMeasConfig.measObjectList.find(measObjectId); if (measObjectIt != m_varMeasConfig.measObjectList.end()) { NS_LOG_LOGIC("measObjectId " << (uint32_t)measObjectId << " exists, updating entry"); measObjectIt->second = *it; - for (std::map::iterator measIdIt = - m_varMeasConfig.measIdList.begin(); + for (auto measIdIt = m_varMeasConfig.measIdList.begin(); measIdIt != m_varMeasConfig.measIdList.end(); ++measIdIt) { @@ -1717,15 +1702,13 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) } // 3GPP TS 36.331 section 5.5.2.6 Reporting configuration removal - for (std::list::iterator it = mc.reportConfigToRemoveList.begin(); - it != mc.reportConfigToRemoveList.end(); + for (auto it = mc.reportConfigToRemoveList.begin(); it != mc.reportConfigToRemoveList.end(); ++it) { uint8_t reportConfigId = *it; NS_LOG_LOGIC(this << " deleting reportConfigId " << (uint32_t)reportConfigId); m_varMeasConfig.reportConfigList.erase(reportConfigId); - std::map::iterator measIdIt = - m_varMeasConfig.measIdList.begin(); + auto measIdIt = m_varMeasConfig.measIdList.begin(); while (measIdIt != m_varMeasConfig.measIdList.end()) { if (measIdIt->second.reportConfigId == reportConfigId) @@ -1747,9 +1730,7 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) } // 3GPP TS 36.331 section 5.5.2.7 Reporting configuration addition/ modification - for (std::list::iterator it = - mc.reportConfigToAddModList.begin(); - it != mc.reportConfigToAddModList.end(); + for (auto it = mc.reportConfigToAddModList.begin(); it != mc.reportConfigToAddModList.end(); ++it) { // simplifying assumptions @@ -1757,15 +1738,13 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) "only trigger type EVENT is supported"); uint8_t reportConfigId = it->reportConfigId; - std::map::iterator reportConfigIt = - m_varMeasConfig.reportConfigList.find(reportConfigId); + auto reportConfigIt = m_varMeasConfig.reportConfigList.find(reportConfigId); if (reportConfigIt != m_varMeasConfig.reportConfigList.end()) { NS_LOG_LOGIC("reportConfigId " << (uint32_t)reportConfigId << " exists, updating entry"); m_varMeasConfig.reportConfigList[reportConfigId] = *it; - for (std::map::iterator measIdIt = - m_varMeasConfig.measIdList.begin(); + for (auto measIdIt = m_varMeasConfig.measIdList.begin(); measIdIt != m_varMeasConfig.measIdList.end(); ++measIdIt) { @@ -1805,8 +1784,7 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) NS_LOG_LOGIC(this << " new filter coefficients: aRsrp=" << m_varMeasConfig.aRsrp << ", aRsrq=" << m_varMeasConfig.aRsrq); - for (std::map::iterator measIdIt = - m_varMeasConfig.measIdList.begin(); + for (auto measIdIt = m_varMeasConfig.measIdList.begin(); measIdIt != m_varMeasConfig.measIdList.end(); ++measIdIt) { @@ -1815,9 +1793,7 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) } // 3GPP TS 36.331 section 5.5.2.2 Measurement identity removal - for (std::list::iterator it = mc.measIdToRemoveList.begin(); - it != mc.measIdToRemoveList.end(); - ++it) + for (auto it = mc.measIdToRemoveList.begin(); it != mc.measIdToRemoveList.end(); ++it) { uint8_t measId = *it; NS_LOG_LOGIC(this << " deleting measId " << (uint32_t)measId); @@ -1830,9 +1806,7 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) } // 3GPP TS 36.331 section 5.5.2.3 Measurement identity addition/ modification - for (std::list::iterator it = mc.measIdToAddModList.begin(); - it != mc.measIdToAddModList.end(); - ++it) + for (auto it = mc.measIdToAddModList.begin(); it != mc.measIdToAddModList.end(); ++it) { NS_LOG_LOGIC(this << " measId " << (uint32_t)it->measId << " (measObjectId=" << (uint32_t)it->measObjectId @@ -1842,8 +1816,7 @@ LteUeRrc::ApplyMeasConfig(LteRrcSap::MeasConfig mc) NS_ASSERT(m_varMeasConfig.reportConfigList.find(it->reportConfigId) != m_varMeasConfig.reportConfigList.end()); m_varMeasConfig.measIdList[it->measId] = *it; // side effect: create new entry if not exists - std::map::iterator measReportIt = - m_varMeasReportList.find(it->measId); + auto measReportIt = m_varMeasReportList.find(it->measId); if (measReportIt != m_varMeasReportList.end()) { measReportIt->second.periodicReportTimer.Cancel(); @@ -1884,7 +1857,7 @@ LteUeRrc::SaveUeMeasurements(uint16_t cellId, { NS_LOG_FUNCTION(this << cellId << +componentCarrierId << rsrp << rsrq << useLayer3Filtering); - std::map::iterator storedMeasIt = m_storedMeasValues.find(cellId); + auto storedMeasIt = m_storedMeasValues.find(cellId); if (storedMeasIt != m_storedMeasValues.end()) { @@ -1921,8 +1894,7 @@ LteUeRrc::SaveUeMeasurements(uint16_t cellId, v.carrierFreq = m_cphySapProvider.at(componentCarrierId)->GetDlEarfcn(); std::pair val(cellId, v); - std::pair::iterator, bool> ret = - m_storedMeasValues.insert(val); + auto ret = m_storedMeasValues.insert(val); NS_ASSERT_MSG(ret.second == true, "element already existed"); storedMeasIt = ret.first; } @@ -1939,22 +1911,19 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) { NS_LOG_FUNCTION(this << (uint16_t)measId); - std::map::iterator measIdIt = - m_varMeasConfig.measIdList.find(measId); + auto measIdIt = m_varMeasConfig.measIdList.find(measId); NS_ASSERT(measIdIt != m_varMeasConfig.measIdList.end()); NS_ASSERT(measIdIt->first == measIdIt->second.measId); - std::map::iterator reportConfigIt = - m_varMeasConfig.reportConfigList.find(measIdIt->second.reportConfigId); + auto reportConfigIt = m_varMeasConfig.reportConfigList.find(measIdIt->second.reportConfigId); NS_ASSERT(reportConfigIt != m_varMeasConfig.reportConfigList.end()); LteRrcSap::ReportConfigEutra& reportConfigEutra = reportConfigIt->second.reportConfigEutra; - std::map::iterator measObjectIt = - m_varMeasConfig.measObjectList.find(measIdIt->second.measObjectId); + auto measObjectIt = m_varMeasConfig.measObjectList.find(measIdIt->second.measObjectId); NS_ASSERT(measObjectIt != m_varMeasConfig.measObjectList.end()); LteRrcSap::MeasObjectEutra& measObjectEutra = measObjectIt->second.measObjectEutra; - std::map::iterator measReportIt = m_varMeasReportList.find(measId); + auto measReportIt = m_varMeasReportList.find(measId); bool isMeasIdInReportList = (measReportIt != m_varMeasReportList.end()); // we don't check the purpose field, as it is only included for @@ -2202,7 +2171,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) break; } - for (std::map::iterator storedMeasIt = m_storedMeasValues.begin(); + for (auto storedMeasIt = m_storedMeasValues.begin(); storedMeasIt != m_storedMeasValues.end(); ++storedMeasIt) { @@ -2310,7 +2279,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) break; } - for (std::map::iterator storedMeasIt = m_storedMeasValues.begin(); + for (auto storedMeasIt = m_storedMeasValues.begin(); storedMeasIt != m_storedMeasValues.end(); ++storedMeasIt) { @@ -2427,7 +2396,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) if (entryCond) { - for (std::map::iterator storedMeasIt = m_storedMeasValues.begin(); + for (auto storedMeasIt = m_storedMeasValues.begin(); storedMeasIt != m_storedMeasValues.end(); ++storedMeasIt) { @@ -2500,8 +2469,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) { // leaving condition #2 does not have to be checked - for (std::map::iterator storedMeasIt = - m_storedMeasValues.begin(); + for (auto storedMeasIt = m_storedMeasValues.begin(); storedMeasIt != m_storedMeasValues.end(); ++storedMeasIt) { @@ -2523,8 +2491,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) { // leaving condition #2 has to be checked to cancel time-to-trigger - for (std::map::iterator storedMeasIt = - m_storedMeasValues.begin(); + for (auto storedMeasIt = m_storedMeasValues.begin(); storedMeasIt != m_storedMeasValues.end(); ++storedMeasIt) { @@ -2592,8 +2559,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) // check leaving condition #2 - for (std::map::iterator storedMeasIt = - m_storedMeasValues.begin(); + for (auto storedMeasIt = m_storedMeasValues.begin(); storedMeasIt != m_storedMeasValues.end(); ++storedMeasIt) { @@ -2670,8 +2636,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) this, measId, concernedCellsEntry); - std::map>::iterator enteringTriggerIt = - m_enteringTriggerQueue.find(measId); + auto enteringTriggerIt = m_enteringTriggerQueue.find(measId); NS_ASSERT(enteringTriggerIt != m_enteringTriggerQueue.end()); enteringTriggerIt->second.push_back(t); } @@ -2699,8 +2664,7 @@ LteUeRrc::MeasurementReportTriggering(uint8_t measId) measId, concernedCellsLeaving, reportOnLeave); - std::map>::iterator leavingTriggerIt = - m_leavingTriggerQueue.find(measId); + auto leavingTriggerIt = m_leavingTriggerQueue.find(measId); NS_ASSERT(leavingTriggerIt != m_leavingTriggerQueue.end()); leavingTriggerIt->second.push_back(t); } @@ -2713,14 +2677,12 @@ LteUeRrc::CancelEnteringTrigger(uint8_t measId) { NS_LOG_FUNCTION(this << (uint16_t)measId); - std::map>::iterator it1 = - m_enteringTriggerQueue.find(measId); + auto it1 = m_enteringTriggerQueue.find(measId); NS_ASSERT(it1 != m_enteringTriggerQueue.end()); if (!it1->second.empty()) { - std::list::iterator it2; - for (it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) + for (auto it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) { NS_ASSERT(it2->measId == measId); NS_LOG_LOGIC(this << " canceling entering time-to-trigger event at " @@ -2737,17 +2699,15 @@ LteUeRrc::CancelEnteringTrigger(uint8_t measId, uint16_t cellId) { NS_LOG_FUNCTION(this << (uint16_t)measId << cellId); - std::map>::iterator it1 = - m_enteringTriggerQueue.find(measId); + auto it1 = m_enteringTriggerQueue.find(measId); NS_ASSERT(it1 != m_enteringTriggerQueue.end()); - std::list::iterator it2 = it1->second.begin(); + auto it2 = it1->second.begin(); while (it2 != it1->second.end()) { NS_ASSERT(it2->measId == measId); - ConcernedCells_t::iterator it3; - for (it3 = it2->concernedCells.begin(); it3 != it2->concernedCells.end(); ++it3) + for (auto it3 = it2->concernedCells.begin(); it3 != it2->concernedCells.end(); ++it3) { if (*it3 == cellId) { @@ -2774,14 +2734,12 @@ LteUeRrc::CancelLeavingTrigger(uint8_t measId) { NS_LOG_FUNCTION(this << (uint16_t)measId); - std::map>::iterator it1 = - m_leavingTriggerQueue.find(measId); + auto it1 = m_leavingTriggerQueue.find(measId); NS_ASSERT(it1 != m_leavingTriggerQueue.end()); if (!it1->second.empty()) { - std::list::iterator it2; - for (it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) + for (auto it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) { NS_ASSERT(it2->measId == measId); NS_LOG_LOGIC(this << " canceling leaving time-to-trigger event at " @@ -2798,17 +2756,15 @@ LteUeRrc::CancelLeavingTrigger(uint8_t measId, uint16_t cellId) { NS_LOG_FUNCTION(this << (uint16_t)measId << cellId); - std::map>::iterator it1 = - m_leavingTriggerQueue.find(measId); + auto it1 = m_leavingTriggerQueue.find(measId); NS_ASSERT(it1 != m_leavingTriggerQueue.end()); - std::list::iterator it2 = it1->second.begin(); + auto it2 = it1->second.begin(); while (it2 != it1->second.end()) { NS_ASSERT(it2->measId == measId); - ConcernedCells_t::iterator it3; - for (it3 = it2->concernedCells.begin(); it3 != it2->concernedCells.end(); ++it3) + for (auto it3 = it2->concernedCells.begin(); it3 != it2->concernedCells.end(); ++it3) { if (*it3 == cellId) { @@ -2836,23 +2792,21 @@ LteUeRrc::VarMeasReportListAdd(uint8_t measId, ConcernedCells_t enteringCells) NS_LOG_FUNCTION(this << (uint16_t)measId); NS_ASSERT(!enteringCells.empty()); - std::map::iterator measReportIt = m_varMeasReportList.find(measId); + auto measReportIt = m_varMeasReportList.find(measId); if (measReportIt == m_varMeasReportList.end()) { VarMeasReport r; r.measId = measId; std::pair val(measId, r); - std::pair::iterator, bool> ret = - m_varMeasReportList.insert(val); + auto ret = m_varMeasReportList.insert(val); NS_ASSERT_MSG(ret.second == true, "element already existed"); measReportIt = ret.first; } NS_ASSERT(measReportIt != m_varMeasReportList.end()); - for (ConcernedCells_t::const_iterator it = enteringCells.begin(); it != enteringCells.end(); - ++it) + for (auto it = enteringCells.begin(); it != enteringCells.end(); ++it) { measReportIt->second.cellsTriggeredList.insert(*it); } @@ -2870,8 +2824,7 @@ LteUeRrc::VarMeasReportListAdd(uint8_t measId, ConcernedCells_t enteringCells) measId); } - std::map>::iterator enteringTriggerIt = - m_enteringTriggerQueue.find(measId); + auto enteringTriggerIt = m_enteringTriggerQueue.find(measId); NS_ASSERT(enteringTriggerIt != m_enteringTriggerQueue.end()); if (!enteringTriggerIt->second.empty()) { @@ -2890,9 +2843,7 @@ LteUeRrc::VarMeasReportListAdd(uint8_t measId, ConcernedCells_t enteringCells) * we clean up the time-to-trigger queue. This case might occur when * time-to-trigger > 200 ms. */ - for (ConcernedCells_t::const_iterator it = enteringCells.begin(); - it != enteringCells.end(); - ++it) + for (auto it = enteringCells.begin(); it != enteringCells.end(); ++it) { CancelEnteringTrigger(measId, *it); } @@ -2908,10 +2859,10 @@ LteUeRrc::VarMeasReportListErase(uint8_t measId, ConcernedCells_t leavingCells, NS_LOG_FUNCTION(this << (uint16_t)measId); NS_ASSERT(!leavingCells.empty()); - std::map::iterator measReportIt = m_varMeasReportList.find(measId); + auto measReportIt = m_varMeasReportList.find(measId); NS_ASSERT(measReportIt != m_varMeasReportList.end()); - for (ConcernedCells_t::const_iterator it = leavingCells.begin(); it != leavingCells.end(); ++it) + for (auto it = leavingCells.begin(); it != leavingCells.end(); ++it) { measReportIt->second.cellsTriggeredList.erase(*it); } @@ -2928,8 +2879,7 @@ LteUeRrc::VarMeasReportListErase(uint8_t measId, ConcernedCells_t leavingCells, m_varMeasReportList.erase(measReportIt); } - std::map>::iterator leavingTriggerIt = - m_leavingTriggerQueue.find(measId); + auto leavingTriggerIt = m_leavingTriggerQueue.find(measId); NS_ASSERT(leavingTriggerIt != m_leavingTriggerQueue.end()); if (!leavingTriggerIt->second.empty()) { @@ -2948,9 +2898,7 @@ LteUeRrc::VarMeasReportListErase(uint8_t measId, ConcernedCells_t leavingCells, * we clean up the time-to-trigger queue. This case might occur when * time-to-trigger > 200 ms. */ - for (ConcernedCells_t::const_iterator it = leavingCells.begin(); - it != leavingCells.end(); - ++it) + for (auto it = leavingCells.begin(); it != leavingCells.end(); ++it) { CancelLeavingTrigger(measId, *it); } @@ -2966,7 +2914,7 @@ LteUeRrc::VarMeasReportListClear(uint8_t measId) NS_LOG_FUNCTION(this << (uint16_t)measId); // remove the measurement reporting entry for this measId from the VarMeasReportList - std::map::iterator measReportIt = m_varMeasReportList.find(measId); + auto measReportIt = m_varMeasReportList.find(measId); if (measReportIt != m_varMeasReportList.end()) { NS_LOG_LOGIC(this << " deleting existing report for measId " << (uint16_t)measId); @@ -2984,12 +2932,10 @@ LteUeRrc::SendMeasurementReport(uint8_t measId) NS_LOG_FUNCTION(this << (uint16_t)measId); // 3GPP TS 36.331 section 5.5.5 Measurement reporting - std::map::iterator measIdIt = - m_varMeasConfig.measIdList.find(measId); + auto measIdIt = m_varMeasConfig.measIdList.find(measId); NS_ASSERT(measIdIt != m_varMeasConfig.measIdList.end()); - std::map::iterator reportConfigIt = - m_varMeasConfig.reportConfigList.find(measIdIt->second.reportConfigId); + auto reportConfigIt = m_varMeasConfig.reportConfigList.find(measIdIt->second.reportConfigId); NS_ASSERT(reportConfigIt != m_varMeasConfig.reportConfigList.end()); LteRrcSap::ReportConfigEutra& reportConfigEutra = reportConfigIt->second.reportConfigEutra; @@ -2997,14 +2943,14 @@ LteUeRrc::SendMeasurementReport(uint8_t measId) LteRrcSap::MeasResults& measResults = measurementReport.measResults; measResults.measId = measId; - std::map::iterator measReportIt = m_varMeasReportList.find(measId); + auto measReportIt = m_varMeasReportList.find(measId); if (measReportIt == m_varMeasReportList.end()) { NS_LOG_ERROR("no entry found in m_varMeasReportList for measId " << (uint32_t)measId); } else { - std::map::iterator servingMeasIt = m_storedMeasValues.find(m_cellId); + auto servingMeasIt = m_storedMeasValues.find(m_cellId); NS_ASSERT(servingMeasIt != m_storedMeasValues.end()); measResults.measResultPCell.rsrpResult = EutranMeasurementMapping::Dbm2RsrpRange(servingMeasIt->second.rsrp); @@ -3045,16 +2991,14 @@ LteUeRrc::SendMeasurementReport(uint8_t measId) if (!(measReportIt->second.cellsTriggeredList.empty())) { std::multimap sortedNeighCells; - for (std::set::iterator cellsTriggeredIt = - measReportIt->second.cellsTriggeredList.begin(); + for (auto cellsTriggeredIt = measReportIt->second.cellsTriggeredList.begin(); cellsTriggeredIt != measReportIt->second.cellsTriggeredList.end(); ++cellsTriggeredIt) { uint16_t cellId = *cellsTriggeredIt; if (cellId != m_cellId) { - std::map::iterator neighborMeasIt = - m_storedMeasValues.find(cellId); + auto neighborMeasIt = m_storedMeasValues.find(cellId); double triggerValue; switch (reportConfigEutra.triggerQuantity) { @@ -3080,8 +3024,7 @@ LteUeRrc::SendMeasurementReport(uint8_t measId) ++sortedNeighCellsIt, ++count) { uint16_t cellId = sortedNeighCellsIt->second; - std::map::iterator neighborMeasIt = - m_storedMeasValues.find(cellId); + auto neighborMeasIt = m_storedMeasValues.find(cellId); NS_ASSERT(neighborMeasIt != m_storedMeasValues.end()); LteRrcSap::MeasResultEutra measResultEutra; measResultEutra.physCellId = cellId; @@ -3191,8 +3134,7 @@ LteUeRrc::LeaveConnectedMode() m_storedMeasValues.clear(); ResetRlfParams(); - std::map::iterator measIdIt; - for (measIdIt = m_varMeasConfig.measIdList.begin(); + for (auto measIdIt = m_varMeasConfig.measIdList.begin(); measIdIt != m_varMeasConfig.measIdList.end(); ++measIdIt) { @@ -3268,7 +3210,7 @@ LteUeRrc::DisposeOldSrb1() uint8_t LteUeRrc::Bid2Drbid(uint8_t bid) { - std::map::iterator it = m_bid2DrbidMap.find(bid); + auto it = m_bid2DrbidMap.find(bid); // NS_ASSERT_MSG (it != m_bid2DrbidMap.end (), "could not find BID " << bid); if (it == m_bid2DrbidMap.end()) { diff --git a/src/lte/model/no-op-component-carrier-manager.cc b/src/lte/model/no-op-component-carrier-manager.cc index 14d8a0226..4a85bf264 100644 --- a/src/lte/model/no-op-component-carrier-manager.cc +++ b/src/lte/model/no-op-component-carrier-manager.cc @@ -81,8 +81,7 @@ void NoOpComponentCarrierManager::DoTransmitPdu(LteMacSapProvider::TransmitPduParameters params) { NS_LOG_FUNCTION(this); - std::map::iterator it = - m_macSapProvidersMap.find(params.componentCarrierId); + auto it = m_macSapProvidersMap.find(params.componentCarrierId); NS_ASSERT_MSG(it != m_macSapProvidersMap.end(), "could not find Sap for ComponentCarrier " << params.componentCarrierId); // with this algorithm all traffic is on Primary Carrier @@ -95,8 +94,7 @@ NoOpComponentCarrierManager::DoReportBufferStatus( { NS_LOG_FUNCTION(this); auto ueManager = m_ccmRrcSapUser->GetUeManager(params.rnti); - std::map::iterator it = - m_macSapProvidersMap.find(ueManager->GetComponentCarrierId()); + auto it = m_macSapProvidersMap.find(ueManager->GetComponentCarrierId()); NS_ASSERT_MSG(it != m_macSapProvidersMap.end(), "could not find Sap for ComponentCarrier "); it->second->ReportBufferStatus(params); } @@ -138,7 +136,6 @@ void NoOpComponentCarrierManager::DoAddUe(uint16_t rnti, uint8_t state) { NS_LOG_FUNCTION(this << rnti << (uint16_t)state); - std::map::iterator eccIt; // m_enabledComponentCarrier iterator auto ueInfoIt = m_ueInfo.find(rnti); if (ueInfoIt == m_ueInfo.end()) { diff --git a/src/lte/model/pf-ff-mac-scheduler.cc b/src/lte/model/pf-ff-mac-scheduler.cc index 80d5669dc..34fee7b2d 100644 --- a/src/lte/model/pf-ff-mac-scheduler.cc +++ b/src/lte/model/pf-ff-mac-scheduler.cc @@ -161,7 +161,7 @@ PfFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -207,10 +207,9 @@ PfFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::map::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -237,15 +236,13 @@ PfFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -275,14 +272,12 @@ PfFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -304,11 +299,9 @@ PfFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -355,9 +348,8 @@ PfFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int PfFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -378,13 +370,12 @@ PfFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -408,13 +399,12 @@ PfFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -443,8 +433,7 @@ PfFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -454,8 +443,7 @@ PfFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -495,7 +483,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); rbgMap = m_ffrSapProvider->GetAvailableDlRbg(); - for (std::vector::iterator it = rbgMap.begin(); it != rbgMap.end(); it++) + for (auto it = rbgMap.begin(); it != rbgMap.end(); it++) { if (*it) { @@ -505,9 +493,9 @@ PfFfMacScheduler::DoSchedDlTriggerReq( FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -523,7 +511,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( uint16_t tmpFfrRbStartOffset = 0; uint16_t index = 0; - for (std::vector::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++) + for (auto it = ulRbMap.begin(); it != ulRbMap.end(); it++) { if (*it) { @@ -554,8 +542,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; rbStart = ffrRbStartOffset; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -619,15 +606,13 @@ PfFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -669,7 +654,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -697,8 +682,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -719,16 +703,14 @@ PfFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -815,8 +797,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -893,8 +874,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -907,15 +887,14 @@ PfFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -946,17 +925,16 @@ PfFfMacScheduler::DoSchedDlTriggerReq( NS_LOG_INFO(this << " ALLOCATION for RBG " << i << " of " << rbgNum); if (!rbgMap.at(i)) { - std::map::iterator it; - std::map::iterator itMax = m_flowStatsDl.end(); + auto itMax = m_flowStatsDl.end(); double rcqiMax = 0.0; - for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) + for (auto it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { if (!m_ffrSapProvider->IsDlRbgAvailableForUe(i, (*it).first)) { continue; } - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if (itRnti != rntiAllocated.end() || !HarqProcessAvailability((*it).first)) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -972,10 +950,8 @@ PfFfMacScheduler::DoSchedDlTriggerReq( } continue; } - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_a30CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1043,8 +1019,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( else { rbgMap.at(i) = true; - std::map>::iterator itMap; - itMap = allocationMap.find((*itMax).first); + auto itMap = allocationMap.find((*itMax).first); if (itMap == allocationMap.end()) { // insert new element @@ -1063,15 +1038,14 @@ PfFfMacScheduler::DoSchedDlTriggerReq( } // end for RBGs // reset TTI stats of users - std::map::iterator itStats; - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.lastTtiBytesTrasmitted = 0; } // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -1090,10 +1064,8 @@ PfFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_a30CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1178,9 +1150,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1202,8 +1172,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1232,8 +1201,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1241,8 +1209,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1254,8 +1221,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( ret.m_buildDataList.push_back(newEl); // update UE stats - std::map::iterator it; - it = m_flowStatsDl.find((*itMap).first); + auto it = m_flowStatsDl.find((*itMap).first); if (it != m_flowStatsDl.end()) { (*it).second.lastTtiBytesTrasmitted = bytesTxed; @@ -1272,7 +1238,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq( // update UEs stats NS_LOG_INFO(this << " Update UEs statistics"); - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted; // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term @@ -1310,9 +1276,8 @@ PfFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1327,17 +1292,15 @@ PfFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1350,8 +1313,7 @@ PfFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1365,7 +1327,7 @@ PfFfMacScheduler::DoSchedDlCqiInfoReq( double PfFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1417,7 +1379,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( rbMap.resize(m_cschedCellConfig.m_ulBandwidth, false); rbMap = m_ffrSapProvider->GetAvailableUlRbg(); - for (std::vector::iterator it = rbMap.begin(); it != rbMap.end(); it++) + for (auto it = rbMap.begin(); it != rbMap.end(); it++) { if (*it) { @@ -1448,8 +1410,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1457,16 +1418,14 @@ PfFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1525,7 +1484,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1559,7 +1518,6 @@ PfFfMacScheduler::DoSchedUlTriggerReq( int rbAllocated = 0; - std::map::iterator itStats; if (m_nextRntiUl != 0) { for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) @@ -1581,7 +1539,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1673,7 +1631,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( break; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1744,15 +1702,13 @@ PfFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1760,8 +1716,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1777,7 +1732,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( << (uint16_t)harqId); // update TTI UE stats - itStats = m_flowStatsUl.find((*it).first); + auto itStats = m_flowStatsUl.find((*it).first); if (itStats != m_flowStatsUl.end()) { (*itStats).second.lastTtiBytesTrasmitted = uldci.m_tbSize; @@ -1803,7 +1758,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq( // Update global UE stats // update UEs stats - for (itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) + for (auto itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) { (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted; // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term @@ -1840,8 +1795,6 @@ PfFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1862,7 +1815,7 @@ PfFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1911,11 +1864,9 @@ PfFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -1924,7 +1875,7 @@ PfFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1954,8 +1905,7 @@ PfFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1978,8 +1928,7 @@ PfFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2006,8 +1955,7 @@ PfFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2027,7 +1975,7 @@ void PfFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -2035,12 +1983,12 @@ PfFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -2052,7 +2000,7 @@ PfFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -2060,12 +2008,12 @@ PfFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -2081,7 +2029,7 @@ void PfFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -2089,13 +2037,13 @@ PfFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -2110,9 +2058,8 @@ PfFfMacScheduler::RefreshUlCqiMaps() void PfFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2167,7 +2114,7 @@ void PfFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/pss-ff-mac-scheduler.cc b/src/lte/model/pss-ff-mac-scheduler.cc index 3948ffecb..1802d2e23 100644 --- a/src/lte/model/pss-ff-mac-scheduler.cc +++ b/src/lte/model/pss-ff-mac-scheduler.cc @@ -174,7 +174,7 @@ PssFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -220,10 +220,9 @@ PssFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::map::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -269,15 +268,13 @@ PssFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -307,14 +304,12 @@ PssFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -336,11 +331,9 @@ PssFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -387,9 +380,8 @@ PssFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int PssFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -410,13 +402,12 @@ PssFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -440,13 +431,12 @@ PssFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -475,8 +465,7 @@ PssFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -486,8 +475,7 @@ PssFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -527,7 +515,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); rbgMap = m_ffrSapProvider->GetAvailableDlRbg(); - for (std::vector::iterator it = rbgMap.begin(); it != rbgMap.end(); it++) + for (auto it = rbgMap.begin(); it != rbgMap.end(); it++) { if (*it) { @@ -537,9 +525,9 @@ PssFfMacScheduler::DoSchedDlTriggerReq( FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -555,7 +543,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( uint16_t tmpFfrRbStartOffset = 0; uint16_t index = 0; - for (std::vector::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++) + for (auto it = ulRbMap.begin(); it != ulRbMap.end(); it++) { if (*it) { @@ -586,8 +574,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; rbStart = ffrRbStartOffset; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -651,15 +638,13 @@ PssFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -701,7 +686,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -729,8 +714,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -751,16 +735,14 @@ PssFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -847,8 +829,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -925,8 +906,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -939,15 +919,14 @@ PssFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -973,12 +952,11 @@ PssFfMacScheduler::DoSchedDlTriggerReq( return; } - std::map::iterator it; std::map tdUeSet; // the result of TD scheduler // schedulability check std::map ueSet; - for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) + for (auto it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { if (LcActivePerFlow((*it).first) > 0) { @@ -992,9 +970,9 @@ PssFfMacScheduler::DoSchedDlTriggerReq( // Time Domain scheduler std::vector> ueSet1; std::vector> ueSet2; - for (it = ueSet.begin(); it != ueSet.end(); it++) + for (auto it = ueSet.begin(); it != ueSet.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it).first))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -1016,10 +994,8 @@ PssFfMacScheduler::DoSchedDlTriggerReq( metric = 1 / (*it).second.lastAveragedThroughput; // check first what are channel conditions for this UE, if CQI!=0 - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_p10CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1046,10 +1022,8 @@ PssFfMacScheduler::DoSchedDlTriggerReq( else { // calculate TD PF metric - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_p10CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1112,19 +1086,16 @@ PssFfMacScheduler::DoSchedDlTriggerReq( } } - std::vector>::iterator itSet; - for (itSet = ueSet1.begin(); itSet != ueSet1.end() && nMux != 0; itSet++) + for (auto itSet = ueSet1.begin(); itSet != ueSet1.end() && nMux != 0; itSet++) { - std::map::iterator itUe; - itUe = m_flowStatsDl.find((*itSet).second); + auto itUe = m_flowStatsDl.find((*itSet).second); tdUeSet.insert(std::pair((*itUe).first, (*itUe).second)); nMux--; } - for (itSet = ueSet2.begin(); itSet != ueSet2.end() && nMux != 0; itSet++) + for (auto itSet = ueSet2.begin(); itSet != ueSet2.end() && nMux != 0; itSet++) { - std::map::iterator itUe; - itUe = m_flowStatsDl.find((*itSet).second); + auto itUe = m_flowStatsDl.find((*itSet).second); tdUeSet.insert(std::pair((*itUe).first, (*itUe).second)); nMux--; } @@ -1133,15 +1104,13 @@ PssFfMacScheduler::DoSchedDlTriggerReq( { // FD scheduler: Carrier over Interference to Average (CoItA) std::map sbCqiSum; - for (it = tdUeSet.begin(); it != tdUeSet.end(); it++) + for (auto it = tdUeSet.begin(); it != tdUeSet.end(); it++) { uint8_t sum = 0; for (int i = 0; i < rbgNum; i++) { - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_a30CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1195,9 +1164,9 @@ PssFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::map::iterator itMax = tdUeSet.end(); + auto itMax = tdUeSet.end(); double metricMax = 0.0; - for (it = tdUeSet.begin(); it != tdUeSet.end(); it++) + for (auto it = tdUeSet.begin(); it != tdUeSet.end(); it++) { if (!m_ffrSapProvider->IsDlRbgAvailableForUe(i, (*it).first)) { @@ -1212,13 +1181,10 @@ PssFfMacScheduler::DoSchedDlTriggerReq( weight = 1.0; } - std::map::iterator itSbCqiSum; - itSbCqiSum = sbCqiSum.find((*it).first); + auto itSbCqiSum = sbCqiSum.find((*it).first); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_a30CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1302,9 +1268,9 @@ PssFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::map::iterator itMax = tdUeSet.end(); + auto itMax = tdUeSet.end(); double metricMax = 0.0; - for (it = tdUeSet.begin(); it != tdUeSet.end(); it++) + for (auto it = tdUeSet.begin(); it != tdUeSet.end(); it++) { if (!m_ffrSapProvider->IsDlRbgAvailableForUe(i, (*it).first)) { @@ -1318,10 +1284,8 @@ PssFfMacScheduler::DoSchedDlTriggerReq( weight = 1.0; } - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_a30CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1397,15 +1361,14 @@ PssFfMacScheduler::DoSchedDlTriggerReq( } // end if ueSet // reset TTI stats of users - std::map::iterator itStats; - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.lastTtiBytesTransmitted = 0; } // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -1424,10 +1387,8 @@ PssFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_a30CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1512,9 +1473,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1536,8 +1495,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1566,8 +1524,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1575,8 +1532,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1588,8 +1544,7 @@ PssFfMacScheduler::DoSchedDlTriggerReq( ret.m_buildDataList.push_back(newEl); // update UE stats - std::map::iterator it; - it = m_flowStatsDl.find((*itMap).first); + auto it = m_flowStatsDl.find((*itMap).first); if (it != m_flowStatsDl.end()) { (*it).second.lastTtiBytesTransmitted = bytesTxed; @@ -1606,9 +1561,9 @@ PssFfMacScheduler::DoSchedDlTriggerReq( // update UEs stats NS_LOG_INFO(this << " Update UEs statistics"); - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { - std::map::iterator itUeScheduleted = tdUeSet.end(); + auto itUeScheduleted = tdUeSet.end(); itUeScheduleted = tdUeSet.find((*itStats).first); if (itUeScheduleted != tdUeSet.end()) { @@ -1651,9 +1606,8 @@ PssFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1668,17 +1622,15 @@ PssFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1691,8 +1643,7 @@ PssFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1706,7 +1657,7 @@ PssFfMacScheduler::DoSchedDlCqiInfoReq( double PssFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1759,7 +1710,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( rbMap = m_ffrSapProvider->GetAvailableUlRbg(); - for (std::vector::iterator it = rbMap.begin(); it != rbMap.end(); it++) + for (auto it = rbMap.begin(); it != rbMap.end(); it++) { if (*it) { @@ -1789,8 +1740,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1798,16 +1748,14 @@ PssFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1866,7 +1814,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1899,7 +1847,6 @@ PssFfMacScheduler::DoSchedUlTriggerReq( } int rbAllocated = 0; - std::map::iterator itStats; if (m_nextRntiUl != 0) { for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) @@ -1921,7 +1868,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -2014,7 +1961,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( break; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -2085,15 +2032,13 @@ PssFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -2101,8 +2046,7 @@ PssFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -2156,8 +2100,6 @@ PssFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -2178,7 +2120,7 @@ PssFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -2224,11 +2166,9 @@ PssFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -2237,7 +2177,7 @@ PssFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2267,8 +2207,7 @@ PssFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2289,8 +2228,7 @@ PssFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2317,8 +2255,7 @@ PssFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2338,7 +2275,7 @@ void PssFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -2346,12 +2283,12 @@ PssFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -2363,7 +2300,7 @@ PssFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -2371,12 +2308,12 @@ PssFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -2392,7 +2329,7 @@ void PssFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -2400,13 +2337,13 @@ PssFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -2421,9 +2358,8 @@ PssFfMacScheduler::RefreshUlCqiMaps() void PssFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2478,7 +2414,7 @@ void PssFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/rr-ff-mac-scheduler.cc b/src/lte/model/rr-ff-mac-scheduler.cc index 636d98d24..aa0b41e21 100644 --- a/src/lte/model/rr-ff-mac-scheduler.cc +++ b/src/lte/model/rr-ff-mac-scheduler.cc @@ -160,7 +160,7 @@ RrFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -215,8 +215,7 @@ RrFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::list::iterator it = - m_rlcBufferReq.begin(); + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).m_rnti == params.m_rnti) && @@ -248,8 +247,7 @@ RrFfMacScheduler::DoCschedUeReleaseReq( m_ulHarqProcessesStatus.erase(params.m_rnti); m_ulHarqProcessesDciBuffer.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::list::iterator it = - m_rlcBufferReq.begin(); + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).m_rnti == params.m_rnti) @@ -280,8 +278,7 @@ RrFfMacScheduler::DoSchedDlRlcBufferReq( { NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::list::iterator it = - m_rlcBufferReq.begin(); + auto it = m_rlcBufferReq.begin(); bool newLc = true; while (it != m_rlcBufferReq.end()) { @@ -356,13 +353,12 @@ RrFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -386,13 +382,12 @@ RrFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -420,8 +415,7 @@ RrFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -431,8 +425,7 @@ RrFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_INFO(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -468,9 +461,9 @@ RrFfMacScheduler::DoSchedDlTriggerReq( std::set rntiAllocated; rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -479,8 +472,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -544,15 +536,13 @@ RrFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -594,7 +584,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -622,8 +612,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -644,16 +633,14 @@ RrFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Max number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -740,8 +727,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -819,8 +805,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -833,15 +818,14 @@ RrFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ ACK UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -873,11 +857,10 @@ RrFfMacScheduler::DoSchedDlTriggerReq( int nflows = 0; int nTbs = 0; std::map lcActivesPerRnti; // tracks how many active LCs per RNTI there are - std::map::iterator itLcRnti; for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { // remove old entries of this UE-LC - std::set::iterator itRnti = rntiAllocated.find((*it).m_rnti); + auto itRnti = rntiAllocated.find((*it).m_rnti); if ((((*it).m_rlcTransmissionQueueSize > 0) || ((*it).m_rlcRetransmissionQueueSize > 0) || ((*it).m_rlcStatusPduSize > 0)) && (itRnti == rntiAllocated.end()) // UE must not be allocated for HARQ retx @@ -889,7 +872,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( << (*it).m_rlcStatusPduSize << " retx " << (*it).m_rlcRetransmissionQueueSize << " tx " << (*it).m_rlcTransmissionQueueSize); - std::map::iterator itCqi = m_p10CqiRxed.find((*it).m_rnti); + auto itCqi = m_p10CqiRxed.find((*it).m_rnti); uint8_t cqi = 0; if (itCqi != m_p10CqiRxed.end()) { @@ -903,7 +886,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( { // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213) nflows++; - itLcRnti = lcActivesPerRnti.find((*it).m_rnti); + auto itLcRnti = lcActivesPerRnti.find((*it).m_rnti); if (itLcRnti != lcActivesPerRnti.end()) { (*itLcRnti).second++; @@ -966,11 +949,10 @@ RrFfMacScheduler::DoSchedDlTriggerReq( it = m_rlcBufferReq.begin(); m_nextRntiDl = (*it).m_rnti; } - std::map::iterator itTxMode; do { - itLcRnti = lcActivesPerRnti.find((*it).m_rnti); - std::set::iterator itRnti = rntiAllocated.find((*it).m_rnti); + auto itLcRnti = lcActivesPerRnti.find((*it).m_rnti); + auto itRnti = rntiAllocated.find((*it).m_rnti); if ((itLcRnti == lcActivesPerRnti.end()) || (itRnti != rntiAllocated.end())) { // skip this RNTI (no active queue or yet allocated for HARQ) @@ -990,7 +972,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( } continue; } - itTxMode = m_uesTxMode.find((*it).m_rnti); + auto itTxMode = m_uesTxMode.find((*it).m_rnti); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).m_rnti); @@ -1006,7 +988,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( newDci.m_harqProcess = UpdateHarqProcessId((*it).m_rnti); newDci.m_resAlloc = 0; newDci.m_rbBitmap = 0; - std::map::iterator itCqi = m_p10CqiRxed.find(newEl.m_rnti); + auto itCqi = m_p10CqiRxed.find(newEl.m_rnti); for (uint8_t i = 0; i < nLayer; i++) { if (itCqi == m_p10CqiRxed.end()) @@ -1042,8 +1024,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*it).m_rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*it).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1097,8 +1078,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1106,8 +1086,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1144,16 +1123,14 @@ RrFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; for (unsigned int i = 0; i < params.m_cqiList.size(); i++) { if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::P10) { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1168,8 +1145,7 @@ RrFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1225,8 +1201,7 @@ RrFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1234,16 +1209,14 @@ RrFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in UL-HARQ buffer for UE (might change eNB) " << rnti); } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1296,7 +1269,7 @@ RrFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ NS_LOG_INFO(this << " UE " << (*it).first << " queue " << (*it).second); if (((*it).second > 0) && (itRnti == rntiAllocated.end())) @@ -1348,7 +1321,7 @@ RrFfMacScheduler::DoSchedUlTriggerReq( NS_LOG_INFO(this << " NFlows " << nflows << " RB per Flow " << rbPerFlow); do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1431,7 +1404,7 @@ RrFfMacScheduler::DoSchedUlTriggerReq( std::pair>(params.m_sfnSf, rbgAllocationMap)); return; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1495,15 +1468,13 @@ RrFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1511,8 +1482,7 @@ RrFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1566,8 +1536,6 @@ RrFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1587,7 +1555,7 @@ RrFfMacScheduler::DoSchedUlMacCtrlInfoReq( } uint16_t rnti = params.m_macCeList.at(i).m_rnti; - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1634,9 +1602,7 @@ RrFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { NS_LOG_INFO(this << " Does not find info on allocation, size : " @@ -1647,7 +1613,7 @@ RrFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1675,8 +1641,7 @@ RrFfMacScheduler::DoSchedUlCqiInfoReq( // update the value (*itCqi).second.at(i) = sinr; // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1697,8 +1662,7 @@ RrFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1725,8 +1689,7 @@ RrFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1747,7 +1710,7 @@ RrFfMacScheduler::RefreshDlCqiMaps() { NS_LOG_FUNCTION(this << m_p10CqiTimers.size()); // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -1755,12 +1718,12 @@ RrFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI exired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -1776,7 +1739,7 @@ void RrFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -1784,13 +1747,13 @@ RrFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -1806,8 +1769,7 @@ void RrFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { NS_LOG_FUNCTION(this); - std::list::iterator it; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).m_rnti == rnti) && ((*it).m_logicalChannelIdentity == lcid)) { @@ -1861,7 +1823,7 @@ void RrFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " Update RLC BSR UE " << rnti << " size " << size << " BSR " diff --git a/src/lte/model/simple-ue-component-carrier-manager.cc b/src/lte/model/simple-ue-component-carrier-manager.cc index 724f371f5..52f3e77b4 100644 --- a/src/lte/model/simple-ue-component-carrier-manager.cc +++ b/src/lte/model/simple-ue-component-carrier-manager.cc @@ -182,8 +182,7 @@ void SimpleUeComponentCarrierManager::DoTransmitPdu(LteMacSapProvider::TransmitPduParameters params) { NS_LOG_FUNCTION(this); - std::map::iterator it = - m_macSapProvidersMap.find(params.componentCarrierId); + auto it = m_macSapProvidersMap.find(params.componentCarrierId); NS_ABORT_MSG_IF(it == m_macSapProvidersMap.end(), "could not find Sap for ComponentCarrier " << (uint16_t)params.componentCarrierId); @@ -197,18 +196,17 @@ SimpleUeComponentCarrierManager::DoReportBufferStatus( { NS_LOG_FUNCTION(this); NS_LOG_DEBUG("BSR from RLC for LCID = " << (uint16_t)params.lcid); - std::map::iterator it = m_macSapProvidersMap.find(0); + auto it = m_macSapProvidersMap.find(0); NS_ABORT_MSG_IF(it == m_macSapProvidersMap.end(), "could not find Sap for ComponentCarrier"); NS_LOG_DEBUG("Size of component carrier LC map " << m_componentCarrierLcMap.size()); - for (std::map>::iterator ccLcMapIt = - m_componentCarrierLcMap.begin(); + for (auto ccLcMapIt = m_componentCarrierLcMap.begin(); ccLcMapIt != m_componentCarrierLcMap.end(); ccLcMapIt++) { NS_LOG_DEBUG("BSR from RLC for CC id = " << (uint16_t)ccLcMapIt->first); - std::map::iterator it = ccLcMapIt->second.find(params.lcid); + auto it = ccLcMapIt->second.find(params.lcid); if (it != ccLcMapIt->second.end()) { it->second->ReportBufferStatus(params); @@ -227,7 +225,7 @@ SimpleUeComponentCarrierManager::DoNotifyTxOpportunity( LteMacSapUser::TxOpportunityParameters txOpParams) { NS_LOG_FUNCTION(this); - std::map::iterator lcidIt = m_lcAttached.find(txOpParams.lcid); + auto lcidIt = m_lcAttached.find(txOpParams.lcid); NS_ABORT_MSG_IF(lcidIt == m_lcAttached.end(), "could not find LCID" << (uint16_t)txOpParams.lcid); NS_LOG_DEBUG(this << " lcid = " << (uint32_t)txOpParams.lcid @@ -245,7 +243,7 @@ void SimpleUeComponentCarrierManager::DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) { NS_LOG_FUNCTION(this); - std::map::iterator lcidIt = m_lcAttached.find(rxPduParams.lcid); + auto lcidIt = m_lcAttached.find(rxPduParams.lcid); NS_ABORT_MSG_IF(lcidIt == m_lcAttached.end(), "could not find LCID" << (uint16_t)rxPduParams.lcid); if (lcidIt != m_lcAttached.end()) @@ -265,11 +263,10 @@ SimpleUeComponentCarrierManager::DoRemoveLc(uint8_t lcid) NS_ABORT_MSG_IF(m_lcAttached.find(lcid) == m_lcAttached.end(), "could not find LCID " << lcid); m_lcAttached.erase(lcid); // send back all the configuration to the componentCarrier where we want to remove the Lc - std::map>::iterator it = - m_componentCarrierLcMap.begin(); + auto it = m_componentCarrierLcMap.begin(); while (it != m_componentCarrierLcMap.end()) { - std::map::iterator lcToRemove = it->second.find(lcid); + auto lcToRemove = it->second.find(lcid); if (lcToRemove != it->second.end()) { res.insert(res.end(), it->first); @@ -287,7 +284,7 @@ SimpleUeComponentCarrierManager::DoReset() { NS_LOG_FUNCTION(this); // same semantics as LteUeMac::DoRest - std::map::iterator it = m_lcAttached.begin(); + auto it = m_lcAttached.begin(); while (it != m_lcAttached.end()) { // don't delete CCCH @@ -310,11 +307,10 @@ SimpleUeComponentCarrierManager::DoAddLc(uint8_t lcId, { NS_LOG_FUNCTION(this); std::vector res; - std::map::iterator it = m_lcAttached.find(lcId); + auto it = m_lcAttached.find(lcId); NS_ABORT_MSG_IF(it != m_lcAttached.end(), "Warning, LCID " << lcId << " already exist"); m_lcAttached.insert(std::pair(lcId, msu)); LteUeCcmRrcSapProvider::LcsConfig elem; - std::map>::iterator ccLcMapIt; for (uint8_t ncc = 0; ncc < m_noOfComponentCarriers; ncc++) { elem.componentCarrierId = ncc; @@ -322,7 +318,7 @@ SimpleUeComponentCarrierManager::DoAddLc(uint8_t lcId, elem.msu = m_ccmMacSapUser; res.insert(res.end(), elem); - ccLcMapIt = m_componentCarrierLcMap.find(ncc); + auto ccLcMapIt = m_componentCarrierLcMap.find(ncc); if (ccLcMapIt != m_componentCarrierLcMap.end()) { ccLcMapIt->second.insert( @@ -331,9 +327,8 @@ SimpleUeComponentCarrierManager::DoAddLc(uint8_t lcId, else { std::map empty; - std::pair>::iterator, bool> - ret = m_componentCarrierLcMap.insert( - std::pair>(ncc, empty)); + auto ret = m_componentCarrierLcMap.insert( + std::pair>(ncc, empty)); NS_ABORT_MSG_IF(!ret.second, "element already present, ComponentCarrierId already exist"); ccLcMapIt = m_componentCarrierLcMap.find(ncc); @@ -352,7 +347,7 @@ SimpleUeComponentCarrierManager::DoConfigureSignalBearer( LteMacSapUser* msu) { NS_LOG_FUNCTION(this); - std::map::iterator it = m_lcAttached.find(lcid); + auto it = m_lcAttached.find(lcid); // if the following assert is hit, e.g., in handover scenarios, it means // the DoRest function is not called by UE RRC NS_ABORT_MSG_IF(it != m_lcAttached.end(), @@ -360,10 +355,9 @@ SimpleUeComponentCarrierManager::DoConfigureSignalBearer( m_lcAttached.insert(std::pair(lcid, msu)); - std::map>::iterator ccLcMapIt; for (uint8_t ncc = 0; ncc < m_noOfComponentCarriers; ncc++) { - ccLcMapIt = m_componentCarrierLcMap.find(ncc); + auto ccLcMapIt = m_componentCarrierLcMap.find(ncc); if (ccLcMapIt != m_componentCarrierLcMap.end()) { ccLcMapIt->second.insert( @@ -372,9 +366,8 @@ SimpleUeComponentCarrierManager::DoConfigureSignalBearer( else { std::map empty; - std::pair>::iterator, bool> - ret = m_componentCarrierLcMap.insert( - std::pair>(ncc, empty)); + auto ret = m_componentCarrierLcMap.insert( + std::pair>(ncc, empty)); NS_ABORT_MSG_IF(!ret.second, "element already present, ComponentCarrierId already existed"); ccLcMapIt = m_componentCarrierLcMap.find(ncc); diff --git a/src/lte/model/tdbet-ff-mac-scheduler.cc b/src/lte/model/tdbet-ff-mac-scheduler.cc index f7a61bf6a..4de5bdf72 100644 --- a/src/lte/model/tdbet-ff-mac-scheduler.cc +++ b/src/lte/model/tdbet-ff-mac-scheduler.cc @@ -159,7 +159,7 @@ TdBetFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -205,10 +205,9 @@ TdBetFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::map::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -235,15 +234,13 @@ TdBetFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -273,14 +270,12 @@ TdBetFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -302,11 +297,9 @@ TdBetFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -353,9 +346,8 @@ TdBetFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int TdBetFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -376,13 +368,12 @@ TdBetFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -406,13 +397,12 @@ TdBetFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -441,8 +431,7 @@ TdBetFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -452,8 +441,7 @@ TdBetFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -493,9 +481,9 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -504,8 +492,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -569,15 +556,13 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -619,7 +604,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -647,8 +632,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -669,16 +653,14 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -765,8 +747,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -843,8 +824,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -857,15 +837,14 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -891,16 +870,13 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( return; } - std::map::iterator it; - std::map::iterator itMax = m_flowStatsDl.end(); + auto itMax = m_flowStatsDl.end(); double metricMax = 0.0; - for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) + for (auto it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { // check first what are channel conditions for this UE, if CQI!=0 - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_p10CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -925,7 +901,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it).first))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -967,15 +943,14 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( } // reset TTI stats of users - std::map::iterator itStats; - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.lastTtiBytesTrasmitted = 0; } // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -994,10 +969,8 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_p10CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1033,9 +1006,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1057,8 +1028,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1087,8 +1057,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1096,8 +1065,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1109,8 +1077,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( ret.m_buildDataList.push_back(newEl); // update UE stats - std::map::iterator it; - it = m_flowStatsDl.find((*itMap).first); + auto it = m_flowStatsDl.find((*itMap).first); if (it != m_flowStatsDl.end()) { (*it).second.lastTtiBytesTrasmitted = bytesTxed; @@ -1127,7 +1094,7 @@ TdBetFfMacScheduler::DoSchedDlTriggerReq( // update UEs stats NS_LOG_INFO(this << " Update UEs statistics"); - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted; // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term @@ -1164,9 +1131,8 @@ TdBetFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1181,17 +1147,15 @@ TdBetFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1204,8 +1168,7 @@ TdBetFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1219,7 +1182,7 @@ TdBetFfMacScheduler::DoSchedDlCqiInfoReq( double TdBetFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1286,8 +1249,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1295,16 +1257,14 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1362,7 +1322,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1392,7 +1352,6 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( } int rbAllocated = 0; - std::map::iterator itStats; if (m_nextRntiUl != 0) { for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) @@ -1414,7 +1373,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1499,7 +1458,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( return; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1570,15 +1529,13 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1586,8 +1543,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1603,7 +1559,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( << (uint16_t)harqId); // update TTI UE stats - itStats = m_flowStatsUl.find((*it).first); + auto itStats = m_flowStatsUl.find((*it).first); if (itStats != m_flowStatsUl.end()) { (*itStats).second.lastTtiBytesTrasmitted = uldci.m_tbSize; @@ -1629,7 +1585,7 @@ TdBetFfMacScheduler::DoSchedUlTriggerReq( // Update global UE stats // update UEs stats - for (itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) + for (auto itStats = m_flowStatsUl.begin(); itStats != m_flowStatsUl.end(); itStats++) { (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted; // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term @@ -1666,8 +1622,6 @@ TdBetFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1688,7 +1642,7 @@ TdBetFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1734,11 +1688,9 @@ TdBetFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -1747,7 +1699,7 @@ TdBetFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1777,8 +1729,7 @@ TdBetFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1799,8 +1750,7 @@ TdBetFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1827,8 +1777,7 @@ TdBetFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1848,7 +1797,7 @@ void TdBetFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -1856,12 +1805,12 @@ TdBetFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -1873,7 +1822,7 @@ TdBetFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -1881,12 +1830,12 @@ TdBetFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -1902,7 +1851,7 @@ void TdBetFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -1910,13 +1859,13 @@ TdBetFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -1931,9 +1880,8 @@ TdBetFfMacScheduler::RefreshUlCqiMaps() void TdBetFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -1988,7 +1936,7 @@ void TdBetFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/tdmt-ff-mac-scheduler.cc b/src/lte/model/tdmt-ff-mac-scheduler.cc index 42fc8865f..33c8282b2 100644 --- a/src/lte/model/tdmt-ff-mac-scheduler.cc +++ b/src/lte/model/tdmt-ff-mac-scheduler.cc @@ -158,7 +158,7 @@ TdMtFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -204,10 +204,9 @@ TdMtFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::set::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -224,15 +223,13 @@ TdMtFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -262,14 +259,12 @@ TdMtFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -291,11 +286,9 @@ TdMtFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -342,9 +335,8 @@ TdMtFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int TdMtFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -365,13 +357,12 @@ TdMtFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -395,13 +386,12 @@ TdMtFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -430,8 +420,7 @@ TdMtFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -441,8 +430,7 @@ TdMtFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -482,9 +470,9 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -493,8 +481,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -558,15 +545,13 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -608,7 +593,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -636,8 +621,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -658,16 +642,14 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -754,8 +736,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -832,8 +813,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -846,15 +826,14 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -880,12 +859,11 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( return; } - std::set::iterator it; - std::set::iterator itMax = m_flowStatsDl.end(); + auto itMax = m_flowStatsDl.end(); double metricMax = 0.0; - for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) + for (auto it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it)); + auto itRnti = rntiAllocated.find((*it)); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it)))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -901,14 +879,13 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it)); + auto itTxMode = m_uesTxMode.find((*it)); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it)); } auto nLayer = TransmissionModesLayers::TxMode2LayerNum((*itTxMode).second); - std::map::iterator itCqi = m_p10CqiRxed.find((*it)); + auto itCqi = m_p10CqiRxed.find((*it)); uint8_t wbCqi = 0; if (itCqi != m_p10CqiRxed.end()) { @@ -978,7 +955,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -997,10 +974,8 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_p10CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_p10CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1033,9 +1008,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1057,8 +1030,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1087,8 +1059,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1096,8 +1067,7 @@ TdMtFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1137,9 +1107,8 @@ TdMtFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1154,17 +1123,15 @@ TdMtFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1177,8 +1144,7 @@ TdMtFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1192,7 +1158,7 @@ TdMtFfMacScheduler::DoSchedDlCqiInfoReq( double TdMtFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1259,8 +1225,7 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1268,16 +1233,14 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1335,7 +1298,7 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1386,7 +1349,7 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1471,7 +1434,7 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( return; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1542,15 +1505,13 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1558,8 +1519,7 @@ TdMtFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1613,8 +1573,6 @@ TdMtFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1635,7 +1593,7 @@ TdMtFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1681,11 +1639,9 @@ TdMtFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -1694,7 +1650,7 @@ TdMtFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1724,8 +1680,7 @@ TdMtFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1746,8 +1701,7 @@ TdMtFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1774,8 +1728,7 @@ TdMtFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1795,7 +1748,7 @@ void TdMtFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -1803,12 +1756,12 @@ TdMtFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -1820,7 +1773,7 @@ TdMtFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -1828,12 +1781,12 @@ TdMtFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -1849,7 +1802,7 @@ void TdMtFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -1857,13 +1810,13 @@ TdMtFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -1878,9 +1831,8 @@ TdMtFfMacScheduler::RefreshUlCqiMaps() void TdMtFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -1935,7 +1887,7 @@ void TdMtFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/tdtbfq-ff-mac-scheduler.cc b/src/lte/model/tdtbfq-ff-mac-scheduler.cc index 9d2300390..d746ac00b 100644 --- a/src/lte/model/tdtbfq-ff-mac-scheduler.cc +++ b/src/lte/model/tdtbfq-ff-mac-scheduler.cc @@ -184,7 +184,7 @@ TdTbfqFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -230,10 +230,9 @@ TdTbfqFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::map::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -287,15 +286,13 @@ TdTbfqFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -325,14 +322,12 @@ TdTbfqFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -354,11 +349,9 @@ TdTbfqFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -405,9 +398,8 @@ TdTbfqFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int TdTbfqFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -428,13 +420,12 @@ TdTbfqFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -458,13 +449,12 @@ TdTbfqFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -493,8 +483,7 @@ TdTbfqFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -504,8 +493,7 @@ TdTbfqFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -545,7 +533,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); rbgMap = m_ffrSapProvider->GetAvailableDlRbg(); - for (std::vector::iterator it = rbgMap.begin(); it != rbgMap.end(); it++) + for (auto it = rbgMap.begin(); it != rbgMap.end(); it++) { if (*it) { @@ -555,9 +543,9 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -573,7 +561,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( uint16_t tmpFfrRbStartOffset = 0; uint16_t index = 0; - for (std::vector::iterator it = ulRbMap.begin(); it != ulRbMap.end(); it++) + for (auto it = ulRbMap.begin(); it != ulRbMap.end(); it++) { if (*it) { @@ -604,8 +592,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; rbStart = ffrRbStartOffset; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -669,15 +656,13 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -719,7 +704,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -747,8 +732,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -769,16 +753,14 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -865,8 +847,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -943,8 +924,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -957,15 +937,14 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -992,8 +971,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( } // update token pool, counter and bank size - std::map::iterator itStats; - for (itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) + for (auto itStats = m_flowStatsDl.begin(); itStats != m_flowStatsDl.end(); itStats++) { if ((*itStats).second.tokenGenerationRate / 1000 + (*itStats).second.tokenPoolSize > (*itStats).second.maxTokenPoolSize) @@ -1012,13 +990,12 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( } // select UE with largest metric - std::map::iterator it; - std::map::iterator itMax = m_flowStatsDl.end(); + auto itMax = m_flowStatsDl.end(); double metricMax = 0.0; bool firstRnti = true; - for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) + for (auto it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it).first))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -1034,10 +1011,8 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( } // check first the channel conditions for this UE, if CQI!=0 - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*it).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it).first); + auto itCqi = m_a30CqiRxed.find((*it).first); + auto itTxMode = m_uesTxMode.find((*it).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it).first); @@ -1124,7 +1099,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -1143,10 +1118,8 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_a30CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1219,9 +1192,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1243,8 +1214,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1273,8 +1243,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1282,8 +1251,7 @@ TdTbfqFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1344,9 +1312,8 @@ TdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1361,17 +1328,15 @@ TdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1384,8 +1349,7 @@ TdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1399,7 +1363,7 @@ TdTbfqFfMacScheduler::DoSchedDlCqiInfoReq( double TdTbfqFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1452,7 +1416,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( rbMap = m_ffrSapProvider->GetAvailableUlRbg(); - for (std::vector::iterator it = rbMap.begin(); it != rbMap.end(); it++) + for (auto it = rbMap.begin(); it != rbMap.end(); it++) { if (*it) { @@ -1482,8 +1446,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1491,16 +1454,14 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1559,7 +1520,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1592,7 +1553,6 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( } int rbAllocated = 0; - std::map::iterator itStats; if (m_nextRntiUl != 0) { for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) @@ -1614,7 +1574,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1707,7 +1667,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( break; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1778,15 +1738,13 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1794,8 +1752,7 @@ TdTbfqFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1849,8 +1806,6 @@ TdTbfqFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1871,7 +1826,7 @@ TdTbfqFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1917,11 +1872,9 @@ TdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -1930,7 +1883,7 @@ TdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1960,8 +1913,7 @@ TdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( NS_LOG_DEBUG(this << " RNTI " << (*itMap).second.at(i) << " RB " << i << " SINR " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1982,8 +1934,7 @@ TdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -2010,8 +1961,7 @@ TdTbfqFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -2031,7 +1981,7 @@ void TdTbfqFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -2039,12 +1989,12 @@ TdTbfqFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -2056,7 +2006,7 @@ TdTbfqFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -2064,12 +2014,12 @@ TdTbfqFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -2085,7 +2035,7 @@ void TdTbfqFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -2093,13 +2043,13 @@ TdTbfqFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -2114,9 +2064,8 @@ TdTbfqFfMacScheduler::RefreshUlCqiMaps() void TdTbfqFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2171,7 +2120,7 @@ void TdTbfqFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/model/tta-ff-mac-scheduler.cc b/src/lte/model/tta-ff-mac-scheduler.cc index 0824005a4..3b54a5ab4 100644 --- a/src/lte/model/tta-ff-mac-scheduler.cc +++ b/src/lte/model/tta-ff-mac-scheduler.cc @@ -158,7 +158,7 @@ TtaFfMacScheduler::DoCschedUeConfigReq( { NS_LOG_FUNCTION(this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode); - std::map::iterator it = m_uesTxMode.find(params.m_rnti); + auto it = m_uesTxMode.find(params.m_rnti); if (it == m_uesTxMode.end()) { m_uesTxMode.insert(std::pair(params.m_rnti, params.m_transmissionMode)); @@ -204,10 +204,9 @@ TtaFfMacScheduler::DoCschedLcConfigReq( { NS_LOG_FUNCTION(this << " New LC, rnti: " << params.m_rnti); - std::set::iterator it; for (std::size_t i = 0; i < params.m_logicalChannelConfigList.size(); i++) { - it = m_flowStatsDl.find(params.m_rnti); + auto it = m_flowStatsDl.find(params.m_rnti); if (it == m_flowStatsDl.end()) { @@ -224,15 +223,13 @@ TtaFfMacScheduler::DoCschedLcReleaseReq( NS_LOG_FUNCTION(this); for (std::size_t i = 0; i < params.m_logicalChannelIdentity.size(); i++) { - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at(i))) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -262,14 +259,12 @@ TtaFfMacScheduler::DoCschedUeReleaseReq( m_flowStatsDl.erase(params.m_rnti); m_flowStatsUl.erase(params.m_rnti); m_ceBsrRxed.erase(params.m_rnti); - std::map::iterator it = - m_rlcBufferReq.begin(); - std::map::iterator temp; + auto it = m_rlcBufferReq.begin(); while (it != m_rlcBufferReq.end()) { if ((*it).first.m_rnti == params.m_rnti) { - temp = it; + auto temp = it; it++; m_rlcBufferReq.erase(temp); } @@ -291,11 +286,9 @@ TtaFfMacScheduler::DoSchedDlRlcBufferReq( NS_LOG_FUNCTION(this << params.m_rnti << (uint32_t)params.m_logicalChannelIdentity); // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map::iterator it; - LteFlowId_t flow(params.m_rnti, params.m_logicalChannelIdentity); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it == m_rlcBufferReq.end()) { @@ -342,9 +335,8 @@ TtaFfMacScheduler::GetRbgSize(int dlbandwidth) unsigned int TtaFfMacScheduler::LcActivePerFlow(uint16_t rnti) { - std::map::iterator it; unsigned int lcActive = 0; - for (it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) + for (auto it = m_rlcBufferReq.begin(); it != m_rlcBufferReq.end(); it++) { if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0) || ((*it).second.m_rlcRetransmissionQueueSize > 0) || @@ -365,13 +357,12 @@ TtaFfMacScheduler::HarqProcessAvailability(uint16_t rnti) { NS_LOG_FUNCTION(this << rnti); - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -395,13 +386,12 @@ TtaFfMacScheduler::UpdateHarqProcessId(uint16_t rnti) return (0); } - std::map::iterator it = m_dlHarqCurrentProcessId.find(rnti); + auto it = m_dlHarqCurrentProcessId.find(rnti); if (it == m_dlHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No Process Id found for this RNTI " << rnti); } - std::map::iterator itStat = - m_dlHarqProcessesStatus.find(rnti); + auto itStat = m_dlHarqProcessesStatus.find(rnti); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Statusfound for this RNTI " << rnti); @@ -430,8 +420,7 @@ TtaFfMacScheduler::RefreshHarqProcesses() { NS_LOG_FUNCTION(this); - std::map::iterator itTimers; - for (itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); + for (auto itTimers = m_dlHarqProcessesTimer.begin(); itTimers != m_dlHarqProcessesTimer.end(); itTimers++) { for (uint16_t i = 0; i < HARQ_PROC_NUM; i++) @@ -441,8 +430,7 @@ TtaFfMacScheduler::RefreshHarqProcesses() // reset HARQ process NS_LOG_DEBUG(this << " Reset HARQ proc " << i << " for RNTI " << (*itTimers).first); - std::map::iterator itStat = - m_dlHarqProcessesStatus.find((*itTimers).first); + auto itStat = m_dlHarqProcessesStatus.find((*itTimers).first); if (itStat == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No Process Id Status found for this RNTI " @@ -482,9 +470,9 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( rbgMap.resize(m_cschedCellConfig.m_dlBandwidth / rbgSize, false); FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // update UL HARQ proc id - std::map::iterator itProcId; - for (itProcId = m_ulHarqCurrentProcessId.begin(); itProcId != m_ulHarqCurrentProcessId.end(); + // update UL HARQ proc id + for (auto itProcId = m_ulHarqCurrentProcessId.begin(); + itProcId != m_ulHarqCurrentProcessId.end(); itProcId++) { (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM; @@ -493,8 +481,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( // RACH Allocation m_rachAllocationMap.resize(m_cschedCellConfig.m_ulBandwidth, 0); uint16_t rbStart = 0; - std::vector::iterator itRach; - for (itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) + for (auto itRach = m_rachList.begin(); itRach != m_rachList.end(); itRach++) { NS_ASSERT_MSG(m_amc->GetUlTbSizeFromMcs(m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize, @@ -558,15 +545,13 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( uldci.m_pdcchPowerOffset = 0; // not used uint8_t harqId = 0; - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -608,7 +593,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( std::vector dlInfoListUntxed; for (std::size_t i = 0; i < m_dlInfoListBuffered.size(); i++) { - std::set::iterator itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); + auto itRnti = rntiAllocated.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRnti != rntiAllocated.end()) { // RNTI already allocated for retx @@ -636,8 +621,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( uint16_t rnti = m_dlInfoListBuffered.at(i).m_rnti; uint8_t harqId = m_dlInfoListBuffered.at(i).m_harqProcessId; NS_LOG_INFO(this << " HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId); - std::map::iterator itHarq = - m_dlHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_dlHarqProcessesDciBuffer.find(rnti); if (itHarq == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << rnti); @@ -658,16 +642,14 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( { // maximum number of retx reached -> drop process NS_LOG_INFO("Maximum number of retransmissions reached -> drop process"); - std::map::iterator it = - m_dlHarqProcessesStatus.find(rnti); + auto it = m_dlHarqProcessesStatus.find(rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(harqId) = 0; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -754,8 +736,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( } // retrieve RLC PDU list for retx TBsize and update DCI BuildDataListElement_s newEl; - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find(rnti); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti); @@ -832,8 +813,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( newEl.m_dci = dci; (*itHarq).second.at(harqId).m_rv = dci.m_rv; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)rnti); @@ -846,15 +826,14 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( { // update HARQ process status NS_LOG_INFO(this << " HARQ received ACK for UE " << m_dlInfoListBuffered.at(i).m_rnti); - std::map::iterator it = - m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); + auto it = m_dlHarqProcessesStatus.find(m_dlInfoListBuffered.at(i).m_rnti); if (it == m_dlHarqProcessesStatus.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at(i).m_rnti); } (*it).second.at(m_dlInfoListBuffered.at(i).m_harqProcessId) = 0; - std::map::iterator itRlcPdu = + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find(m_dlInfoListBuffered.at(i).m_rnti); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { @@ -885,12 +864,11 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( NS_LOG_INFO(this << " ALLOCATION for RBG " << i << " of " << rbgNum); if (!rbgMap.at(i)) { - std::set::iterator it; - std::set::iterator itMax = m_flowStatsDl.end(); + auto itMax = m_flowStatsDl.end(); double rcqiMax = 0.0; - for (it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) + for (auto it = m_flowStatsDl.begin(); it != m_flowStatsDl.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it)); + auto itRnti = rntiAllocated.find((*it)); if ((itRnti != rntiAllocated.end()) || (!HarqProcessAvailability((*it)))) { // UE already allocated for HARQ or without HARQ process available -> drop it @@ -905,13 +883,10 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( continue; } - std::map::iterator itSbCqi; - itSbCqi = m_a30CqiRxed.find((*it)); - std::map::iterator itWbCqi; - itWbCqi = m_p10CqiRxed.find((*it)); + auto itSbCqi = m_a30CqiRxed.find((*it)); + auto itWbCqi = m_p10CqiRxed.find((*it)); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*it)); + auto itTxMode = m_uesTxMode.find((*it)); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*it)); @@ -992,8 +967,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( else { rbgMap.at(i) = true; - std::map>::iterator itMap; - itMap = allocationMap.find((*itMax)); + auto itMap = allocationMap.find((*itMax)); if (itMap == allocationMap.end()) { // insert new element @@ -1013,7 +987,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( // generate the transmission opportunities by grouping the RBGs of the same RNTI and // creating the correspondent DCIs - std::map>::iterator itMap = allocationMap.begin(); + auto itMap = allocationMap.begin(); while (itMap != allocationMap.end()) { // create new BuildDataListElement_s for this LC @@ -1032,10 +1006,8 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( lcActives = (uint16_t)65535; // UINT16_MAX; } uint16_t RgbPerRnti = (*itMap).second.size(); - std::map::iterator itCqi; - itCqi = m_a30CqiRxed.find((*itMap).first); - std::map::iterator itTxMode; - itTxMode = m_uesTxMode.find((*itMap).first); + auto itCqi = m_a30CqiRxed.find((*itMap).first); + auto itTxMode = m_uesTxMode.find((*itMap).first); if (itTxMode == m_uesTxMode.end()) { NS_FATAL_ERROR("No Transmission Mode info on user " << (*itMap).first); @@ -1118,9 +1090,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) // create the rlc PDUs -> equally divide resources among actives LCs - std::map::iterator - itBufReq; - for (itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) + for (auto itBufReq = m_rlcBufferReq.begin(); itBufReq != m_rlcBufferReq.end(); itBufReq++) { if (((*itBufReq).first.m_rnti == (*itMap).first) && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0) || @@ -1142,8 +1112,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store RLC PDU list for HARQ - std::map::iterator itRlcPdu = - m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); + auto itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find((*itMap).first); if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end()) { NS_FATAL_ERROR("Unable to find RlcPdcList in HARQ buffer for RNTI " @@ -1172,8 +1141,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( if (m_harqOn) { // store DCI for HARQ - std::map::iterator itDci = - m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); + auto itDci = m_dlHarqProcessesDciBuffer.find(newEl.m_rnti); if (itDci == m_dlHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in DCI HARQ buffer for RNTI " @@ -1181,8 +1149,7 @@ TtaFfMacScheduler::DoSchedDlTriggerReq( } (*itDci).second.at(newDci.m_harqProcess) = newDci; // refresh timer - std::map::iterator itHarqTimer = - m_dlHarqProcessesTimer.find(newEl.m_rnti); + auto itHarqTimer = m_dlHarqProcessesTimer.find(newEl.m_rnti); if (itHarqTimer == m_dlHarqProcessesTimer.end()) { NS_FATAL_ERROR("Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti); @@ -1222,9 +1189,8 @@ TtaFfMacScheduler::DoSchedDlCqiInfoReq( { NS_LOG_LOGIC("wideband CQI " << (uint32_t)params.m_cqiList.at(i).m_wbCqi.at(0) << " reported"); - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_p10CqiRxed.find(rnti); + auto it = m_p10CqiRxed.find(rnti); if (it == m_p10CqiRxed.end()) { // create the new entry @@ -1239,17 +1205,15 @@ TtaFfMacScheduler::DoSchedDlCqiInfoReq( // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_wbCqi.at(0); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_p10CqiTimers.find(rnti); + auto itTimers = m_p10CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } else if (params.m_cqiList.at(i).m_cqiType == CqiListElement_s::A30) { // subband CQI reporting high layer configured - std::map::iterator it; uint16_t rnti = params.m_cqiList.at(i).m_rnti; - it = m_a30CqiRxed.find(rnti); + auto it = m_a30CqiRxed.find(rnti); if (it == m_a30CqiRxed.end()) { // create the new entry @@ -1262,8 +1226,7 @@ TtaFfMacScheduler::DoSchedDlCqiInfoReq( { // update the CQI value and refresh correspondent timer (*it).second = params.m_cqiList.at(i).m_sbMeasResult; - std::map::iterator itTimers; - itTimers = m_a30CqiTimers.find(rnti); + auto itTimers = m_a30CqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1277,7 +1240,7 @@ TtaFfMacScheduler::DoSchedDlCqiInfoReq( double TtaFfMacScheduler::EstimateUlSinr(uint16_t rnti, uint16_t rb) { - std::map>::iterator itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // no cqi info about this UE @@ -1344,8 +1307,7 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( { // retx correspondent block: retrieve the UL-DCI uint16_t rnti = params.m_ulInfoList.at(i).m_rnti; - std::map::iterator itProcId = - m_ulHarqCurrentProcessId.find(rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1353,16 +1315,14 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM; NS_LOG_INFO(this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size " << params.m_ulInfoList.size()); - std::map::iterator itHarq = - m_ulHarqProcessesDciBuffer.find(rnti); + auto itHarq = m_ulHarqProcessesDciBuffer.find(rnti); if (itHarq == m_ulHarqProcessesDciBuffer.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); continue; } UlDciListElement_s dci = (*itHarq).second.at(harqId); - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(rnti); + auto itStat = m_ulHarqProcessesStatus.find(rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " << rnti); @@ -1420,7 +1380,7 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( for (it = m_ceBsrRxed.begin(); it != m_ceBsrRxed.end(); it++) { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); // select UEs with queues not empty and not yet allocated for HARQ if (((*it).second > 0) && (itRnti == rntiAllocated.end())) { @@ -1471,7 +1431,7 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( } do { - std::set::iterator itRnti = rntiAllocated.find((*it).first); + auto itRnti = rntiAllocated.find((*it).first); if ((itRnti != rntiAllocated.end()) || ((*it).second == 0)) { // UE already allocated for UL-HARQ -> skip it @@ -1556,7 +1516,7 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( return; } - std::map>::iterator itCqi = m_ueCqi.find((*it).first); + auto itCqi = m_ueCqi.find((*it).first); int cqi = 0; if (itCqi == m_ueCqi.end()) { @@ -1627,15 +1587,13 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( uint8_t harqId = 0; if (m_harqOn) { - std::map::iterator itProcId; - itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); + auto itProcId = m_ulHarqCurrentProcessId.find(uldci.m_rnti); if (itProcId == m_ulHarqCurrentProcessId.end()) { NS_FATAL_ERROR("No info find in HARQ buffer for UE " << uldci.m_rnti); } harqId = (*itProcId).second; - std::map::iterator itDci = - m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); + auto itDci = m_ulHarqProcessesDciBuffer.find(uldci.m_rnti); if (itDci == m_ulHarqProcessesDciBuffer.end()) { NS_FATAL_ERROR("Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " @@ -1643,8 +1601,7 @@ TtaFfMacScheduler::DoSchedUlTriggerReq( } (*itDci).second.at(harqId) = uldci; // Update HARQ process status (RV 0) - std::map::iterator itStat = - m_ulHarqProcessesStatus.find(uldci.m_rnti); + auto itStat = m_ulHarqProcessesStatus.find(uldci.m_rnti); if (itStat == m_ulHarqProcessesStatus.end()) { NS_LOG_ERROR("No info find in HARQ buffer for UE (might change eNB) " @@ -1698,8 +1655,6 @@ TtaFfMacScheduler::DoSchedUlMacCtrlInfoReq( { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (unsigned int i = 0; i < params.m_macCeList.size(); i++) { if (params.m_macCeList.at(i).m_macCeType == MacCeListElement_s::BSR) @@ -1720,7 +1675,7 @@ TtaFfMacScheduler::DoSchedUlMacCtrlInfoReq( uint16_t rnti = params.m_macCeList.at(i).m_rnti; NS_LOG_LOGIC(this << "RNTI=" << rnti << " buffer=" << buffer); - it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it == m_ceBsrRxed.end()) { // create the new entry @@ -1766,11 +1721,9 @@ TtaFfMacScheduler::DoSchedUlCqiInfoReq( switch (params.m_ulCqi.m_type) { case UlCqi_s::PUSCH: { - std::map>::iterator itMap; - std::map>::iterator itCqi; NS_LOG_DEBUG(this << " Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf)); - itMap = m_allocationMaps.find(params.m_sfnSf); + auto itMap = m_allocationMaps.find(params.m_sfnSf); if (itMap == m_allocationMaps.end()) { return; @@ -1779,7 +1732,7 @@ TtaFfMacScheduler::DoSchedUlCqiInfoReq( { // convert from fixed point notation Sxxxxxxxxxxx.xxx to double double sinr = LteFfConverter::fpS11dot3toDouble(params.m_ulCqi.m_sinr.at(i)); - itCqi = m_ueCqi.find((*itMap).second.at(i)); + auto itCqi = m_ueCqi.find((*itMap).second.at(i)); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1809,8 +1762,7 @@ TtaFfMacScheduler::DoSchedUlCqiInfoReq( // NS_LOG_DEBUG (this << " RNTI " << (*itMap).second.at (i) << " RB " << i << " SINR // " << sinr); // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); + auto itTimers = m_ueCqiTimers.find((*itMap).second.at(i)); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1831,8 +1783,7 @@ TtaFfMacScheduler::DoSchedUlCqiInfoReq( rnti = vsp->GetRnti(); } } - std::map>::iterator itCqi; - itCqi = m_ueCqi.find(rnti); + auto itCqi = m_ueCqi.find(rnti); if (itCqi == m_ueCqi.end()) { // create a new entry @@ -1859,8 +1810,7 @@ TtaFfMacScheduler::DoSchedUlCqiInfoReq( << sinr); } // update correspondent timer - std::map::iterator itTimers; - itTimers = m_ueCqiTimers.find(rnti); + auto itTimers = m_ueCqiTimers.find(rnti); (*itTimers).second = m_cqiTimersThreshold; } } @@ -1880,7 +1830,7 @@ void TtaFfMacScheduler::RefreshDlCqiMaps() { // refresh DL CQI P01 Map - std::map::iterator itP10 = m_p10CqiTimers.begin(); + auto itP10 = m_p10CqiTimers.begin(); while (itP10 != m_p10CqiTimers.end()) { NS_LOG_INFO(this << " P10-CQI for user " << (*itP10).first << " is " @@ -1888,12 +1838,12 @@ TtaFfMacScheduler::RefreshDlCqiMaps() if ((*itP10).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_p10CqiRxed.find((*itP10).first); + auto itMap = m_p10CqiRxed.find((*itP10).first); NS_ASSERT_MSG(itMap != m_p10CqiRxed.end(), " Does not find CQI report for user " << (*itP10).first); NS_LOG_INFO(this << " P10-CQI expired for user " << (*itP10).first); m_p10CqiRxed.erase(itMap); - std::map::iterator temp = itP10; + auto temp = itP10; itP10++; m_p10CqiTimers.erase(temp); } @@ -1905,7 +1855,7 @@ TtaFfMacScheduler::RefreshDlCqiMaps() } // refresh DL CQI A30 Map - std::map::iterator itA30 = m_a30CqiTimers.begin(); + auto itA30 = m_a30CqiTimers.begin(); while (itA30 != m_a30CqiTimers.end()) { NS_LOG_INFO(this << " A30-CQI for user " << (*itA30).first << " is " @@ -1913,12 +1863,12 @@ TtaFfMacScheduler::RefreshDlCqiMaps() if ((*itA30).second == 0) { // delete correspondent entries - std::map::iterator itMap = m_a30CqiRxed.find((*itA30).first); + auto itMap = m_a30CqiRxed.find((*itA30).first); NS_ASSERT_MSG(itMap != m_a30CqiRxed.end(), " Does not find CQI report for user " << (*itA30).first); NS_LOG_INFO(this << " A30-CQI expired for user " << (*itA30).first); m_a30CqiRxed.erase(itMap); - std::map::iterator temp = itA30; + auto temp = itA30; itA30++; m_a30CqiTimers.erase(temp); } @@ -1934,7 +1884,7 @@ void TtaFfMacScheduler::RefreshUlCqiMaps() { // refresh UL CQI Map - std::map::iterator itUl = m_ueCqiTimers.begin(); + auto itUl = m_ueCqiTimers.begin(); while (itUl != m_ueCqiTimers.end()) { NS_LOG_INFO(this << " UL-CQI for user " << (*itUl).first << " is " @@ -1942,13 +1892,13 @@ TtaFfMacScheduler::RefreshUlCqiMaps() if ((*itUl).second == 0) { // delete correspondent entries - std::map>::iterator itMap = m_ueCqi.find((*itUl).first); + auto itMap = m_ueCqi.find((*itUl).first); NS_ASSERT_MSG(itMap != m_ueCqi.end(), " Does not find CQI report for user " << (*itUl).first); NS_LOG_INFO(this << " UL-CQI exired for user " << (*itUl).first); (*itMap).second.clear(); m_ueCqi.erase(itMap); - std::map::iterator temp = itUl; + auto temp = itUl; itUl++; m_ueCqiTimers.erase(temp); } @@ -1963,9 +1913,8 @@ TtaFfMacScheduler::RefreshUlCqiMaps() void TtaFfMacScheduler::UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size) { - std::map::iterator it; LteFlowId_t flow(rnti, lcid); - it = m_rlcBufferReq.find(flow); + auto it = m_rlcBufferReq.find(flow); if (it != m_rlcBufferReq.end()) { NS_LOG_INFO(this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " @@ -2020,7 +1969,7 @@ void TtaFfMacScheduler::UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size) { size = size - 2; // remove the minimum RLC overhead - std::map::iterator it = m_ceBsrRxed.find(rnti); + auto it = m_ceBsrRxed.find(rnti); if (it != m_ceBsrRxed.end()) { NS_LOG_INFO(this << " UE " << rnti << " size " << size << " BSR " << (*it).second); diff --git a/src/lte/test/epc-test-gtpu.cc b/src/lte/test/epc-test-gtpu.cc index b0dcb6333..8649892ce 100644 --- a/src/lte/test/epc-test-gtpu.cc +++ b/src/lte/test/epc-test-gtpu.cc @@ -57,7 +57,7 @@ EpsGtpuHeaderTestCase::~EpsGtpuHeaderTestCase() void EpsGtpuHeaderTestCase::DoRun() { - LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); + auto logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); LogComponentEnable("EpcGtpuTest", logLevel); GtpuHeader h1; diff --git a/src/lte/test/epc-test-s1u-downlink.cc b/src/lte/test/epc-test-s1u-downlink.cc index a00e830ec..f18163f0e 100644 --- a/src/lte/test/epc-test-s1u-downlink.cc +++ b/src/lte/test/epc-test-s1u-downlink.cc @@ -154,9 +154,7 @@ EpcS1uDlTestCase::DoRun() uint16_t cellIdCounter = 0; uint64_t imsiCounter = 0; - for (std::vector::iterator enbit = m_enbDlTestData.begin(); - enbit < m_enbDlTestData.end(); - ++enbit) + for (auto enbit = m_enbDlTestData.begin(); enbit < m_enbDlTestData.end(); ++enbit) { Ptr enb = CreateObject(); enbs.Add(enb); @@ -245,12 +243,9 @@ EpcS1uDlTestCase::DoRun() Simulator::Run(); - for (std::vector::iterator enbit = m_enbDlTestData.begin(); - enbit < m_enbDlTestData.end(); - ++enbit) + for (auto enbit = m_enbDlTestData.begin(); enbit < m_enbDlTestData.end(); ++enbit) { - for (std::vector::iterator ueit = enbit->ues.begin(); ueit < enbit->ues.end(); - ++ueit) + for (auto ueit = enbit->ues.begin(); ueit < enbit->ues.end(); ++ueit) { NS_TEST_ASSERT_MSG_EQ(ueit->serverApp->GetTotalRx(), (ueit->numPkts) * (ueit->pktSize), diff --git a/src/lte/test/epc-test-s1u-uplink.cc b/src/lte/test/epc-test-s1u-uplink.cc index 1e80b1c48..bdf0acd6a 100644 --- a/src/lte/test/epc-test-s1u-uplink.cc +++ b/src/lte/test/epc-test-s1u-uplink.cc @@ -366,9 +366,7 @@ EpcS1uUlTestCase::DoRun() uint16_t cellIdCounter = 0; uint64_t imsiCounter = 0; - for (std::vector::iterator enbit = m_enbUlTestData.begin(); - enbit < m_enbUlTestData.end(); - ++enbit) + for (auto enbit = m_enbUlTestData.begin(); enbit < m_enbUlTestData.end(); ++enbit) { Ptr enb = CreateObject(); enbs.Add(enb); @@ -486,12 +484,9 @@ EpcS1uUlTestCase::DoRun() Simulator::Run(); - for (std::vector::iterator enbit = m_enbUlTestData.begin(); - enbit < m_enbUlTestData.end(); - ++enbit) + for (auto enbit = m_enbUlTestData.begin(); enbit < m_enbUlTestData.end(); ++enbit) { - for (std::vector::iterator ueit = enbit->ues.begin(); ueit < enbit->ues.end(); - ++ueit) + for (auto ueit = enbit->ues.begin(); ueit < enbit->ues.end(); ++ueit) { NS_TEST_ASSERT_MSG_EQ(ueit->serverApp->GetTotalRx(), (ueit->numPkts) * (ueit->pktSize), diff --git a/src/lte/test/lte-ffr-simple.cc b/src/lte/test/lte-ffr-simple.cc index 2ebf0e2c6..6a28394e2 100644 --- a/src/lte/test/lte-ffr-simple.cc +++ b/src/lte/test/lte-ffr-simple.cc @@ -279,9 +279,7 @@ LteFfrSimple::DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults measResults) { NS_LOG_FUNCTION(this << rnti << (uint16_t)measResults.measId); - std::map::iterator it; - - it = m_ues.find(rnti); + auto it = m_ues.find(rnti); if (it == m_ues.end()) { @@ -302,8 +300,7 @@ LteFfrSimple::UpdatePdschConfigDedicated() { NS_LOG_FUNCTION(this); - std::map::iterator it; - for (it = m_ues.begin(); it != m_ues.end(); it++) + for (auto it = m_ues.begin(); it != m_ues.end(); it++) { if (it->second.pa != m_pdschConfigDedicated.pa) { diff --git a/src/lte/test/lte-simple-helper.cc b/src/lte/test/lte-simple-helper.cc index fa98fe77c..d64c8e114 100644 --- a/src/lte/test/lte-simple-helper.cc +++ b/src/lte/test/lte-simple-helper.cc @@ -91,7 +91,7 @@ LteSimpleHelper::InstallEnbDevice(NodeContainer c) NS_LOG_FUNCTION(this); Initialize(); // will run DoInitialize () if necessary NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr device = InstallSingleEnbDevice(node); @@ -105,7 +105,7 @@ LteSimpleHelper::InstallUeDevice(NodeContainer c) { NS_LOG_FUNCTION(this); NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; Ptr device = InstallSingleUeDevice(node); @@ -209,8 +209,7 @@ LteSimpleHelper::InstallSingleUeDevice(Ptr n) void LteSimpleHelper::EnableLogComponents() { - LogLevel level = - (LogLevel)(LOG_LEVEL_ALL | LOG_PREFIX_TIME | LOG_PREFIX_NODE | LOG_PREFIX_FUNC); + auto level = (LogLevel)(LOG_LEVEL_ALL | LOG_PREFIX_TIME | LOG_PREFIX_NODE | LOG_PREFIX_FUNC); LogComponentEnable("Config", level); LogComponentEnable("LteSimpleHelper", level); diff --git a/src/lte/test/lte-test-carrier-aggregation.cc b/src/lte/test/lte-test-carrier-aggregation.cc index e80b3eeb8..4268afaa5 100644 --- a/src/lte/test/lte-test-carrier-aggregation.cc +++ b/src/lte/test/lte-test-carrier-aggregation.cc @@ -425,8 +425,7 @@ CarrierAggregationTestCase::DoRun() bool testDownlinkShare = true; - for (std::map::iterator itDownlink = m_ccDownlinkTraffic.begin(); - itDownlink != m_ccDownlinkTraffic.end(); + for (auto itDownlink = m_ccDownlinkTraffic.begin(); itDownlink != m_ccDownlinkTraffic.end(); itDownlink++) { if (itDownlink == m_ccDownlinkTraffic.begin()) @@ -445,9 +444,7 @@ CarrierAggregationTestCase::DoRun() bool testUplinkShare = true; - for (std::map::iterator itUplink = m_ccUplinkTraffic.begin(); - itUplink != m_ccUplinkTraffic.end(); - itUplink++) + for (auto itUplink = m_ccUplinkTraffic.begin(); itUplink != m_ccUplinkTraffic.end(); itUplink++) { if (itUplink == m_ccUplinkTraffic.begin()) { diff --git a/src/lte/test/lte-test-cell-selection.cc b/src/lte/test/lte-test-cell-selection.cc index e993e33ab..cb2a03aef 100644 --- a/src/lte/test/lte-test-cell-selection.cc +++ b/src/lte/test/lte-test-cell-selection.cc @@ -185,7 +185,7 @@ LteCellSelectionTestCase::DoRun() NodeContainer enbNodes; enbNodes.Create(4); NodeContainer ueNodes; - uint16_t nUe = static_cast(m_ueSetupList.size()); + auto nUe = static_cast(m_ueSetupList.size()); ueNodes.Create(nUe); // Assign nodes to position diff --git a/src/lte/test/lte-test-cqa-ff-mac-scheduler.cc b/src/lte/test/lte-test-cqa-ff-mac-scheduler.cc index 1cf739a0a..1485b7120 100644 --- a/src/lte/test/lte-test-cqa-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-cqa-ff-mac-scheduler.cc @@ -542,7 +542,7 @@ LenaCqaFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-deactivate-bearer.cc b/src/lte/test/lte-test-deactivate-bearer.cc index cfab671f8..518354661 100644 --- a/src/lte/test/lte-test-deactivate-bearer.cc +++ b/src/lte/test/lte-test-deactivate-bearer.cc @@ -109,7 +109,7 @@ LenaDeactivateBearerTestCase::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-entities.cc b/src/lte/test/lte-test-entities.cc index f1863b126..86460b436 100644 --- a/src/lte/test/lte-test-entities.cc +++ b/src/lte/test/lte-test-entities.cc @@ -162,7 +162,7 @@ LteTestRrc::DoReceivePdcpSdu(LtePdcpSapUser::ReceivePdcpSduParameters params) // NS_LOG_LOGIC ("PDU received = " << (*p)); uint32_t dataLen = p->GetSize(); - uint8_t* buf = new uint8_t[dataLen]; + auto buf = new uint8_t[dataLen]; // Stats m_rxPdus++; @@ -312,7 +312,7 @@ LteTestPdcp::DoReceivePdcpPdu(Ptr p) NS_LOG_LOGIC("Data = " << (*p)); uint32_t dataLen = p->GetSize(); - uint8_t* buf = new uint8_t[dataLen]; + auto buf = new uint8_t[dataLen]; p->CopyData(buf, dataLen); m_receivedData = std::string((char*)buf, dataLen); @@ -606,7 +606,7 @@ LteTestMac::DoTransmitPdu(LteMacSapProvider::TransmitPduParameters params) // Copy data to a string uint32_t dataLen = params.pdu->GetSize(); - uint8_t* buf = new uint8_t[dataLen]; + auto buf = new uint8_t[dataLen]; params.pdu->CopyData(buf, dataLen); m_receivedData = std::string((char*)buf, dataLen); @@ -623,8 +623,7 @@ LteTestMac::DoReportBufferStatus(LteMacSapProvider::ReportBufferStatusParameters if (m_txOpportunityMode == AUTOMATIC_MODE) { // cancel all previously scheduled TxOpps - for (std::list::iterator it = m_nextTxOppList.begin(); it != m_nextTxOppList.end(); - ++it) + for (auto it = m_nextTxOppList.begin(); it != m_nextTxOppList.end(); ++it) { it->Cancel(); } diff --git a/src/lte/test/lte-test-fdbet-ff-mac-scheduler.cc b/src/lte/test/lte-test-fdbet-ff-mac-scheduler.cc index 42b273052..c98b2da52 100644 --- a/src/lte/test/lte-test-fdbet-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-fdbet-ff-mac-scheduler.cc @@ -383,7 +383,7 @@ LenaFdBetFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.cc b/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.cc index 147999e5b..540d9292e 100644 --- a/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.cc @@ -548,7 +548,7 @@ LenaFdTbfqFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-frequency-reuse.cc b/src/lte/test/lte-test-frequency-reuse.cc index ae367e0de..ed5456869 100644 --- a/src/lte/test/lte-test-frequency-reuse.cc +++ b/src/lte/test/lte-test-frequency-reuse.cc @@ -480,9 +480,8 @@ void LteFrTestCase::DlDataRxStart(Ptr spectrumValue) { NS_LOG_DEBUG("DL DATA Power allocation :"); - Values::const_iterator it; uint32_t i = 0; - for (it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) + for (auto it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) { double power = (*it) * (m_dlBandwidth * 180000); NS_LOG_DEBUG("RB " << i << " POWER: " @@ -500,9 +499,8 @@ void LteFrTestCase::UlDataRxStart(Ptr spectrumValue) { NS_LOG_DEBUG("UL DATA Power allocation :"); - Values::const_iterator it; uint32_t i = 0; - for (it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) + for (auto it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) { double power = (*it) * (m_ulBandwidth * 180000); NS_LOG_DEBUG("RB " << i << " POWER: " @@ -822,9 +820,8 @@ LteFrAreaTestCase::DlDataRxStart(Ptr spectrumValue) } NS_LOG_DEBUG("DL DATA Power allocation :"); - Values::const_iterator it; uint32_t i = 0; - for (it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) + for (auto it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) { double power = (*it) * (m_dlBandwidth * 180000); NS_LOG_DEBUG("RB " << i << " POWER: " @@ -858,7 +855,6 @@ LteFrAreaTestCase::UlDataRxStart(Ptr spectrumValue) } NS_LOG_DEBUG("UL DATA Power allocation :"); - Values::const_iterator it; uint32_t i = 0; uint32_t numActiveRbs = 0; @@ -866,7 +862,7 @@ LteFrAreaTestCase::UlDataRxStart(Ptr spectrumValue) // of active RBs. This method is independent of the bandwidth // configuration done in a test scenario, thus, it requires // minimum change to the script. - for (it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) + for (auto it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) { // Count the RB as active if it is part of // the expected UL RBs and has Power Spectral Density (PSD) > 0 @@ -879,7 +875,7 @@ LteFrAreaTestCase::UlDataRxStart(Ptr spectrumValue) // The uplink power control and the uplink PSD // calculation only consider active resource blocks. - for (it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) + for (auto it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++) { double power = (*it) * (numActiveRbs * 180000); NS_LOG_DEBUG("RB " << i << " POWER: " << power diff --git a/src/lte/test/lte-test-ipv6-routing.cc b/src/lte/test/lte-test-ipv6-routing.cc index deb45e976..1f20f98d0 100644 --- a/src/lte/test/lte-test-ipv6-routing.cc +++ b/src/lte/test/lte-test-ipv6-routing.cc @@ -164,8 +164,7 @@ LteIpv6RoutingTestCase::Checker() bool b = false; bool check = true; // Extract each received reply packet of the client - for (std::list>::iterator it1 = m_clientRxPkts.begin(); it1 != m_clientRxPkts.end(); - it1++) + for (auto it1 = m_clientRxPkts.begin(); it1 != m_clientRxPkts.end(); it1++) { Ipv6Header ipv6header1; UdpHeader udpHeader1; @@ -174,9 +173,7 @@ LteIpv6RoutingTestCase::Checker() uint64_t uid = p1->GetUid(); p1->RemoveHeader(udpHeader1); // Search each packet in list of sent request packet of the client - for (std::list>::iterator it2 = m_clientTxPkts.begin(); - it2 != m_clientTxPkts.end(); - it2++) + for (auto it2 = m_clientTxPkts.begin(); it2 != m_clientTxPkts.end(); it2++) { Ptr p2 = (*it2)->Copy(); Ipv6Header ipv6header2; diff --git a/src/lte/test/lte-test-pf-ff-mac-scheduler.cc b/src/lte/test/lte-test-pf-ff-mac-scheduler.cc index 86db09f4a..a16909b5a 100644 --- a/src/lte/test/lte-test-pf-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-pf-ff-mac-scheduler.cc @@ -399,7 +399,7 @@ LenaPfFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-phy-error-model.cc b/src/lte/test/lte-test-phy-error-model.cc index 689375394..17317fa1c 100644 --- a/src/lte/test/lte-test-phy-error-model.cc +++ b/src/lte/test/lte-test-phy-error-model.cc @@ -260,7 +260,7 @@ LenaDataPhyErrorModelTestCase::DoRun() // sanity check for whether the tx packets reported by the stats are correct // we expect one packet per TTI - double expectedDlTxPackets = static_cast(statsDuration.GetMilliSeconds()); + auto expectedDlTxPackets = static_cast(statsDuration.GetMilliSeconds()); NS_TEST_ASSERT_MSG_EQ_TOL(dlTxPackets, expectedDlTxPackets, expectedDlTxPackets * 0.005, @@ -422,7 +422,7 @@ LenaDlCtrlPhyErrorModelTestCase::DoRun() // sanity check for whether the tx packets reported by the stats are correct // we expect one packet per TTI - double expectedDlTxPackets = static_cast(statsDuration.GetMilliSeconds()); + auto expectedDlTxPackets = static_cast(statsDuration.GetMilliSeconds()); NS_TEST_ASSERT_MSG_EQ_TOL(dlTxPackets, expectedDlTxPackets, expectedDlTxPackets * 0.005, diff --git a/src/lte/test/lte-test-pss-ff-mac-scheduler.cc b/src/lte/test/lte-test-pss-ff-mac-scheduler.cc index 90b77e709..f175c8b21 100644 --- a/src/lte/test/lte-test-pss-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-pss-ff-mac-scheduler.cc @@ -544,7 +544,7 @@ LenaPssFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-radio-link-failure.cc b/src/lte/test/lte-test-radio-link-failure.cc index d16962ef4..f03ee1018 100644 --- a/src/lte/test/lte-test-radio-link-failure.cc +++ b/src/lte/test/lte-test-radio-link-failure.cc @@ -282,9 +282,7 @@ LteRadioLinkFailureTestCase::DoRun() // Mobility Ptr positionAllocEnb = CreateObject(); - for (std::vector::iterator enbPosIt = m_enbPositionList.begin(); - enbPosIt != m_enbPositionList.end(); - ++enbPosIt) + for (auto enbPosIt = m_enbPositionList.begin(); enbPosIt != m_enbPositionList.end(); ++enbPosIt) { positionAllocEnb->Add(*enbPosIt); } @@ -295,9 +293,7 @@ LteRadioLinkFailureTestCase::DoRun() Ptr positionAllocUe = CreateObject(); - for (std::vector::iterator uePosIt = m_uePositionList.begin(); - uePosIt != m_uePositionList.end(); - ++uePosIt) + for (auto uePosIt = m_uePositionList.begin(); uePosIt != m_uePositionList.end(); ++uePosIt) { positionAllocUe->Add(*uePosIt); } @@ -464,9 +460,7 @@ LteRadioLinkFailureTestCase::CheckConnected(Ptr ueDevice, NetDeviceCo Ptr enbLteDevice; - for (std::vector>::const_iterator enbDevIt = enbDevices.Begin(); - enbDevIt != enbDevices.End(); - ++enbDevIt) + for (auto enbDevIt = enbDevices.Begin(); enbDevIt != enbDevices.End(); ++enbDevIt) { if (((*enbDevIt)->GetObject())->HasCellId(cellId)) { @@ -512,8 +506,8 @@ LteRadioLinkFailureTestCase::CheckConnected(Ptr ueDevice, NetDeviceCo ueRrc->GetAttribute("DataRadioBearerMap", ueDataRadioBearerMapValue); NS_TEST_ASSERT_MSG_EQ(ueDataRadioBearerMapValue.GetN(), 1 + 1, "wrong num bearers at UE"); - ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin(); - ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin(); + auto enbBearerIt = enbDataRadioBearerMapValue.Begin(); + auto ueBearerIt = ueDataRadioBearerMapValue.Begin(); while (enbBearerIt != enbDataRadioBearerMapValue.End() && ueBearerIt != ueDataRadioBearerMapValue.End()) { diff --git a/src/lte/test/lte-test-tdbet-ff-mac-scheduler.cc b/src/lte/test/lte-test-tdbet-ff-mac-scheduler.cc index 0c20b0a58..5bcc4a63a 100644 --- a/src/lte/test/lte-test-tdbet-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-tdbet-ff-mac-scheduler.cc @@ -388,7 +388,7 @@ LenaTdBetFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.cc b/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.cc index 0672c5fda..01450c96c 100644 --- a/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.cc +++ b/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.cc @@ -547,7 +547,7 @@ LenaTdTbfqFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector::iterator it = dist.begin(); it != dist.end(); ++it) + for (auto it = dist.begin(); it != dist.end(); ++it) { oss << *it << " "; } diff --git a/src/lte/test/lte-test-ue-measurements.cc b/src/lte/test/lte-test-ue-measurements.cc index 2ade5de4b..530454f14 100644 --- a/src/lte/test/lte-test-ue-measurements.cc +++ b/src/lte/test/lte-test-ue-measurements.cc @@ -1607,8 +1607,7 @@ LteUeMeasurementsPiecewiseTestCase2::RecvMeasurementReportCallback( NS_TEST_ASSERT_MSG_EQ(measResults.haveMeasResultNeighCells, true, "Unexpected report content"); - std::list::iterator it = - measResults.measResultListEutra.begin(); + auto it = measResults.measResultListEutra.begin(); NS_ASSERT(it != measResults.measResultListEutra.end()); NS_ASSERT(it->physCellId == 2); NS_TEST_ASSERT_MSG_EQ(it->haveCgiInfo, @@ -1900,8 +1899,7 @@ LteUeMeasurementsPiecewiseTestCase3::RecvMeasurementReportCallback( NS_TEST_ASSERT_MSG_EQ(measResults.haveMeasResultNeighCells, true, "Unexpected report content"); - std::list::iterator it = - measResults.measResultListEutra.begin(); + auto it = measResults.measResultListEutra.begin(); NS_ASSERT(it != measResults.measResultListEutra.end()); for (const auto& it : measResults.measResultListEutra) { @@ -2402,18 +2400,19 @@ LteUeMeasurementsHandoverTestCase::DoRun() // Setup UE measurement configuration in eNodeBs uint8_t measId; - std::list::const_iterator itReportConfig; Ptr enbRrc1 = enbDevs.Get(0)->GetObject()->GetRrc(); Ptr enbRrc2 = enbDevs.Get(1)->GetObject()->GetRrc(); - for (itReportConfig = m_sourceConfigList.begin(); itReportConfig != m_sourceConfigList.end(); + for (auto itReportConfig = m_sourceConfigList.begin(); + itReportConfig != m_sourceConfigList.end(); itReportConfig++) { measId = enbRrc1->AddUeMeasReportConfig(*itReportConfig).at(0); m_expectedSourceCellMeasId.insert(measId); } - for (itReportConfig = m_targetConfigList.begin(); itReportConfig != m_targetConfigList.end(); + for (auto itReportConfig = m_targetConfigList.begin(); + itReportConfig != m_targetConfigList.end(); itReportConfig++) { measId = enbRrc2->AddUeMeasReportConfig(*itReportConfig).at(0); @@ -2490,12 +2489,12 @@ LteUeMeasurementsHandoverTestCase::RecvMeasurementReportCallback( bool isCorrectMeasId; if (cellId == 1) { - std::set::iterator itMeasId = m_expectedSourceCellMeasId.find(measId); + auto itMeasId = m_expectedSourceCellMeasId.find(measId); isCorrectMeasId = (itMeasId != m_expectedSourceCellMeasId.end()); } else if (cellId == 2) { - std::set::iterator itMeasId = m_expectedTargetCellMeasId.find(measId); + auto itMeasId = m_expectedTargetCellMeasId.find(measId); isCorrectMeasId = (itMeasId != m_expectedTargetCellMeasId.end()); } else @@ -2528,8 +2527,7 @@ LteUeMeasurementsHandoverTestCase::RecvMeasurementReportCallback( NS_TEST_ASSERT_MSG_EQ(measResults.haveMeasResultNeighCells, true, "Unexpected report content"); - std::list::iterator it = - measResults.measResultListEutra.begin(); + auto it = measResults.measResultListEutra.begin(); NS_ASSERT(it != measResults.measResultListEutra.end()); NS_ASSERT(it->physCellId != cellId); NS_ASSERT(it->physCellId <= 2); diff --git a/src/lte/test/test-asn1-encoding.cc b/src/lte/test/test-asn1-encoding.cc index b11f70733..37bf3fe8b 100644 --- a/src/lte/test/test-asn1-encoding.cc +++ b/src/lte/test/test-asn1-encoding.cc @@ -207,9 +207,9 @@ RrcHeaderTestCase::AssertEqualRadioResourceConfigDedicated( "SrbToAddModList different sizes"); std::list srcSrbToAddModList = rrcd1.srbToAddModList; - std::list::iterator it1 = srcSrbToAddModList.begin(); + auto it1 = srcSrbToAddModList.begin(); std::list dstSrbToAddModList = rrcd2.srbToAddModList; - std::list::iterator it2 = dstSrbToAddModList.begin(); + auto it2 = dstSrbToAddModList.begin(); for (; it1 != srcSrbToAddModList.end(); it1++, it2++) { @@ -233,9 +233,9 @@ RrcHeaderTestCase::AssertEqualRadioResourceConfigDedicated( "DrbToAddModList different sizes"); std::list srcDrbToAddModList = rrcd1.drbToAddModList; - std::list::iterator it3 = srcDrbToAddModList.begin(); + auto it3 = srcDrbToAddModList.begin(); std::list dstDrbToAddModList = rrcd2.drbToAddModList; - std::list::iterator it4 = dstDrbToAddModList.begin(); + auto it4 = dstDrbToAddModList.begin(); for (; it3 != srcDrbToAddModList.end(); it3++, it4++) { @@ -267,8 +267,8 @@ RrcHeaderTestCase::AssertEqualRadioResourceConfigDedicated( std::list srcDrbToReleaseList = rrcd1.drbToReleaseList; std::list dstDrbToReleaseList = rrcd2.drbToReleaseList; - std::list::iterator it5 = srcDrbToReleaseList.begin(); - std::list::iterator it6 = dstDrbToReleaseList.begin(); + auto it5 = srcDrbToReleaseList.begin(); + auto it6 = dstDrbToReleaseList.begin(); for (; it5 != srcDrbToReleaseList.end(); it5++, it6++) { @@ -1186,8 +1186,8 @@ MeasurementReportTestCase::DoRun() if (srcMeas.haveMeasResultNeighCells) { - std::list::iterator itsrc = srcMeas.measResultListEutra.begin(); - std::list::iterator itdst = dstMeas.measResultListEutra.begin(); + auto itsrc = srcMeas.measResultListEutra.begin(); + auto itdst = dstMeas.measResultListEutra.begin(); for (; itsrc != srcMeas.measResultListEutra.end(); itsrc++, itdst++) { NS_TEST_ASSERT_MSG_EQ(itsrc->physCellId, itdst->physCellId, "Different physCellId!"); @@ -1210,8 +1210,8 @@ MeasurementReportTestCase::DoRun() if (!itsrc->cgiInfo.plmnIdentityList.empty()) { - std::list::iterator itsrc2 = itsrc->cgiInfo.plmnIdentityList.begin(); - std::list::iterator itdst2 = itdst->cgiInfo.plmnIdentityList.begin(); + auto itsrc2 = itsrc->cgiInfo.plmnIdentityList.begin(); + auto itdst2 = itdst->cgiInfo.plmnIdentityList.begin(); for (; itsrc2 != itsrc->cgiInfo.plmnIdentityList.begin(); itsrc2++, itdst2++) { NS_TEST_ASSERT_MSG_EQ(*itsrc2, *itdst2, "Different plmnId elements!"); diff --git a/src/lte/test/test-lte-epc-e2e-data.cc b/src/lte/test/test-lte-epc-e2e-data.cc index 706c7b0d1..ce23efd75 100644 --- a/src/lte/test/test-lte-epc-e2e-data.cc +++ b/src/lte/test/test-lte-epc-e2e-data.cc @@ -195,13 +195,11 @@ LteEpcE2eDataTestCase::DoRun() StringValue("RowFirst")); enbMobility.Install(enbs); NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice(enbs); - NetDeviceContainer::Iterator enbLteDevIt = enbLteDevs.Begin(); + auto enbLteDevIt = enbLteDevs.Begin(); uint16_t ulPort = 1000; - for (std::vector::iterator enbit = m_enbTestData.begin(); - enbit < m_enbTestData.end(); - ++enbit, ++enbLteDevIt) + for (auto enbit = m_enbTestData.begin(); enbit < m_enbTestData.end(); ++enbit, ++enbLteDevIt) { NS_ABORT_IF(enbLteDevIt == enbLteDevs.End()); @@ -317,12 +315,9 @@ LteEpcE2eDataTestCase::DoRun() uint64_t imsiCounter = 0; - for (std::vector::iterator enbit = m_enbTestData.begin(); - enbit < m_enbTestData.end(); - ++enbit) + for (auto enbit = m_enbTestData.begin(); enbit < m_enbTestData.end(); ++enbit) { - for (std::vector::iterator ueit = enbit->ues.begin(); ueit < enbit->ues.end(); - ++ueit) + for (auto ueit = enbit->ues.begin(); ueit < enbit->ues.end(); ++ueit) { uint64_t imsi = ++imsiCounter; for (uint32_t b = 0; b < ueit->bearers.size(); ++b) diff --git a/src/lte/test/test-lte-rlc-header.cc b/src/lte/test/test-lte-rlc-header.cc index f1aef251b..bc696a2a0 100644 --- a/src/lte/test/test-lte-rlc-header.cc +++ b/src/lte/test/test-lte-rlc-header.cc @@ -151,8 +151,7 @@ RlcAmStatusPduTestCase::DoRun() LteRlcAmHeader h; h.SetControlPdu(LteRlcAmHeader::STATUS_PDU); h.SetAckSn(m_ackSn); - for (std::list::iterator it = m_nackSnList.begin(); it != m_nackSnList.end(); - ++it) + for (auto it = m_nackSnList.begin(); it != m_nackSnList.end(); ++it) { h.PushNack(it->GetValue()); } @@ -170,8 +169,7 @@ RlcAmStatusPduTestCase::DoRun() SequenceNumber10 ackSn = h2.GetAckSn(); NS_TEST_ASSERT_MSG_EQ(ackSn, m_ackSn, "deserialized ACK SN differs from test vector"); - for (std::list::iterator it = m_nackSnList.begin(); it != m_nackSnList.end(); - ++it) + for (auto it = m_nackSnList.begin(); it != m_nackSnList.end(); ++it) { int nackSn = h2.PopNack(); NS_TEST_ASSERT_MSG_GT(nackSn, -1, "not enough elements in deserialized NACK list"); diff --git a/src/lte/test/test-lte-rrc.cc b/src/lte/test/test-lte-rrc.cc index 9b1441a97..36c26e3b0 100644 --- a/src/lte/test/test-lte-rrc.cc +++ b/src/lte/test/test-lte-rrc.cc @@ -321,7 +321,7 @@ LteRrcConnectionEstablishmentTestCase::DoRun() // instead of lteHelper->Attach () and lteHelper->ActivateXxx // Set AdmitConnectionRequest attribute - for (NetDeviceContainer::Iterator it = enbDevs.Begin(); it != enbDevs.End(); ++it) + for (auto it = enbDevs.Begin(); it != enbDevs.End(); ++it) { Ptr enbRrc = (*it)->GetObject()->GetRrc(); enbRrc->SetAttribute("AdmitRrcConnectionRequest", @@ -330,7 +330,7 @@ LteRrcConnectionEstablishmentTestCase::DoRun() uint32_t i = 0; uint32_t tmax = 0; - for (NetDeviceContainer::Iterator it = ueDevs.Begin(); it != ueDevs.End(); ++it) + for (auto it = ueDevs.Begin(); it != ueDevs.End(); ++it) { Ptr ueDevice = *it; Ptr enbDevice = enbDevs.Get(0); @@ -494,8 +494,8 @@ LteRrcConnectionEstablishmentTestCase::CheckConnected(Ptr ueDevice, m_nBearers, "wrong num bearers at UE"); - ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin(); - ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin(); + auto enbBearerIt = enbDataRadioBearerMapValue.Begin(); + auto ueBearerIt = ueDataRadioBearerMapValue.Begin(); while (enbBearerIt != enbDataRadioBearerMapValue.End() && ueBearerIt != ueDataRadioBearerMapValue.End()) { @@ -679,7 +679,7 @@ LteRrcConnectionEstablishmentErrorTestCase::DoRun() // instead of lteHelper->Attach () and lteHelper->ActivateXxx // Set AdmitConnectionRequest attribute - for (NetDeviceContainer::Iterator it = enbDevs.Begin(); it != enbDevs.End(); ++it) + for (auto it = enbDevs.Begin(); it != enbDevs.End(); ++it) { Ptr enbRrc = (*it)->GetObject()->GetRrc(); enbRrc->SetAttribute("AdmitRrcConnectionRequest", @@ -688,7 +688,7 @@ LteRrcConnectionEstablishmentErrorTestCase::DoRun() uint32_t i = 0; uint32_t tmax = 0; - for (NetDeviceContainer::Iterator it = ueDevs.Begin(); it != ueDevs.End(); ++it) + for (auto it = ueDevs.Begin(); it != ueDevs.End(); ++it) { Ptr ueDevice = *it; Ptr enbDevice = enbDevs.Get(0); diff --git a/src/lte/test/test-lte-x2-handover-measures.cc b/src/lte/test/test-lte-x2-handover-measures.cc index af60fb26c..09db4e31d 100644 --- a/src/lte/test/test-lte-x2-handover-measures.cc +++ b/src/lte/test/test-lte-x2-handover-measures.cc @@ -345,7 +345,7 @@ LteX2HandoverMeasuresTestCase::DoRun() NetDeviceContainer enbDevices; enbDevices = m_lteHelper->InstallEnbDevice(enbNodes); stream += m_lteHelper->AssignStreams(enbDevices, stream); - for (NetDeviceContainer::Iterator it = enbDevices.Begin(); it != enbDevices.End(); ++it) + for (auto it = enbDevices.Begin(); it != enbDevices.End(); ++it) { Ptr enbRrc = (*it)->GetObject()->GetRrc(); enbRrc->SetAttribute("AdmitHandoverRequest", BooleanValue(m_admitHo)); @@ -541,7 +541,7 @@ LteX2HandoverMeasuresTestCase::DoRun() // check initial RRC connection const Time maxRrcConnectionEstablishmentDuration = Seconds(0.080); - for (NetDeviceContainer::Iterator it = ueDevices.Begin(); it != ueDevices.End(); ++it) + for (auto it = ueDevices.Begin(); it != ueDevices.End(); ++it) { NS_LOG_FUNCTION(maxRrcConnectionEstablishmentDuration); Simulator::Schedule(maxRrcConnectionEstablishmentDuration, @@ -554,7 +554,7 @@ LteX2HandoverMeasuresTestCase::DoRun() // schedule the checkpoint events Time stopTime = Seconds(0); - for (std::list::iterator checkPointEventIt = m_checkPointEventList.begin(); + for (auto checkPointEventIt = m_checkPointEventList.begin(); checkPointEventIt != m_checkPointEventList.end(); ++checkPointEventIt) { @@ -642,8 +642,8 @@ LteX2HandoverMeasuresTestCase::CheckConnected(Ptr ueDevice, Ptr::iterator it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); + for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); it != m_ueDataVector.at(ueIndex).bearerDataList.end(); ++it) { @@ -698,7 +698,7 @@ LteX2HandoverMeasuresTestCase::CheckStats(uint32_t ueIndex) { NS_LOG_FUNCTION(ueIndex); uint32_t b = 1; - for (std::list::iterator it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); + for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); it != m_ueDataVector.at(ueIndex).bearerDataList.end(); ++it) { diff --git a/src/lte/test/test-lte-x2-handover.cc b/src/lte/test/test-lte-x2-handover.cc index 759997062..b8cbbb297 100644 --- a/src/lte/test/test-lte-x2-handover.cc +++ b/src/lte/test/test-lte-x2-handover.cc @@ -276,7 +276,7 @@ LteX2HandoverTestCase::DoRun() NetDeviceContainer enbDevices; enbDevices = m_lteHelper->InstallEnbDevice(enbNodes); stream += m_lteHelper->AssignStreams(enbDevices, stream); - for (NetDeviceContainer::Iterator it = enbDevices.Begin(); it != enbDevices.End(); ++it) + for (auto it = enbDevices.Begin(); it != enbDevices.End(); ++it) { Ptr enbRrc = (*it)->GetObject()->GetRrc(); enbRrc->SetAttribute("AdmitHandoverRequest", BooleanValue(m_admitHo)); @@ -440,7 +440,7 @@ LteX2HandoverTestCase::DoRun() // check initial RRC connection const Time maxRrcConnectionEstablishmentDuration = Seconds(0.080); - for (NetDeviceContainer::Iterator it = ueDevices.Begin(); it != ueDevices.End(); ++it) + for (auto it = ueDevices.Begin(); it != ueDevices.End(); ++it) { Simulator::Schedule(maxRrcConnectionEstablishmentDuration, &LteX2HandoverTestCase::CheckConnected, @@ -452,8 +452,7 @@ LteX2HandoverTestCase::DoRun() // schedule handover events and corresponding checks Time stopTime = Seconds(0); - for (std::list::iterator hoEventIt = m_handoverEventList.begin(); - hoEventIt != m_handoverEventList.end(); + for (auto hoEventIt = m_handoverEventList.begin(); hoEventIt != m_handoverEventList.end(); ++hoEventIt) { // Teleport the UE between both eNBs just before the handover starts @@ -569,8 +568,8 @@ LteX2HandoverTestCase::CheckConnected(Ptr ueDevice, Ptr en m_nDedicatedBearers + 1, "wrong num bearers at UE"); - ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin(); - ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin(); + auto enbBearerIt = enbDataRadioBearerMapValue.Begin(); + auto ueBearerIt = ueDataRadioBearerMapValue.Begin(); while (enbBearerIt != enbDataRadioBearerMapValue.End() && ueBearerIt != ueDataRadioBearerMapValue.End()) { @@ -621,7 +620,7 @@ LteX2HandoverTestCase::TeleportUeNearTargetEnb(Ptr ueNode, Ptr enbNo void LteX2HandoverTestCase::SaveStatsAfterHandover(uint32_t ueIndex) { - for (std::list::iterator it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); + for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); it != m_ueDataVector.at(ueIndex).bearerDataList.end(); ++it) { @@ -634,7 +633,7 @@ void LteX2HandoverTestCase::CheckStatsAWhileAfterHandover(uint32_t ueIndex) { uint32_t b = 1; - for (std::list::iterator it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); + for (auto it = m_ueDataVector.at(ueIndex).bearerDataList.begin(); it != m_ueDataVector.at(ueIndex).bearerDataList.end(); ++it) { @@ -761,9 +760,7 @@ LteX2HandoverTestSuite::LteX2HandoverTestSuite() "ns3::PfFfMacScheduler", }; - for (std::vector::iterator schedIt = schedulers.begin(); - schedIt != schedulers.end(); - ++schedIt) + for (auto schedIt = schedulers.begin(); schedIt != schedulers.end(); ++schedIt) { for (auto useIdealRrc : {true, false}) { diff --git a/src/mesh/examples/mesh.cc b/src/mesh/examples/mesh.cc index 69fcd9787..79c9a3e47 100644 --- a/src/mesh/examples/mesh.cc +++ b/src/mesh/examples/mesh.cc @@ -336,7 +336,7 @@ void MeshTest::Report() { unsigned n(0); - for (NetDeviceContainer::Iterator i = meshDevices.Begin(); i != meshDevices.End(); ++i, ++n) + for (auto i = meshDevices.Begin(); i != meshDevices.End(); ++i, ++n) { std::ostringstream os; os << "mp-report-" << n << ".xml"; diff --git a/src/mesh/helper/dot11s/dot11s-installer.cc b/src/mesh/helper/dot11s/dot11s-installer.cc index b3e32e5da..45264c10c 100644 --- a/src/mesh/helper/dot11s/dot11s-installer.cc +++ b/src/mesh/helper/dot11s/dot11s-installer.cc @@ -92,7 +92,7 @@ Dot11sStack::Report(const Ptr mp, std::ostream& os) mp->Report(os); std::vector> ifaces = mp->GetInterfaces(); - for (std::vector>::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i) + for (auto i = ifaces.begin(); i != ifaces.end(); ++i) { Ptr device = (*i)->GetObject(); NS_ASSERT(device); @@ -115,7 +115,7 @@ Dot11sStack::ResetStats(const Ptr mp) mp->ResetStats(); std::vector> ifaces = mp->GetInterfaces(); - for (std::vector>::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i) + for (auto i = ifaces.begin(); i != ifaces.end(); ++i) { Ptr device = (*i)->GetObject(); NS_ASSERT(device); diff --git a/src/mesh/helper/mesh-helper.cc b/src/mesh/helper/mesh-helper.cc index 157823f12..1760cc1f2 100644 --- a/src/mesh/helper/mesh-helper.cc +++ b/src/mesh/helper/mesh-helper.cc @@ -64,7 +64,7 @@ MeshHelper::Install(const WifiPhyHelper& phyHelper, NodeContainer c) const { NetDeviceContainer devices; NS_ASSERT(m_stack); - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; // Create a mesh point device @@ -179,7 +179,7 @@ MeshHelper::AssignStreams(NetDeviceContainer c, int64_t stream) { int64_t currentStream = stream; Ptr netDevice; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { netDevice = (*i); Ptr mpd = DynamicCast(netDevice); @@ -190,7 +190,7 @@ MeshHelper::AssignStreams(NetDeviceContainer c, int64_t stream) currentStream += mpd->AssignStreams(currentStream); // To access, we need the underlying WifiNetDevices std::vector> ifaces = mpd->GetInterfaces(); - for (std::vector>::iterator i = ifaces.begin(); i != ifaces.end(); i++) + for (auto i = ifaces.begin(); i != ifaces.end(); i++) { wifi = DynamicCast(*i); diff --git a/src/mesh/model/dot11s/hwmp-protocol-mac.cc b/src/mesh/model/dot11s/hwmp-protocol-mac.cc index 61e265549..f7fd7f328 100644 --- a/src/mesh/model/dot11s/hwmp-protocol-mac.cc +++ b/src/mesh/model/dot11s/hwmp-protocol-mac.cc @@ -120,7 +120,7 @@ HwmpProtocolMac::ReceiveAction(Ptr packet, const WifiMacHeader& header) // this is the last header to remove. packet->RemoveHeader(elements, packet->GetSize()); std::vector failedDestinations; - for (MeshInformationElementVector::Iterator i = elements.Begin(); i != elements.End(); i++) + for (auto i = elements.Begin(); i != elements.End(); i++) { if ((*i)->ElementId() == IE_RANN) { @@ -169,10 +169,7 @@ HwmpProtocolMac::ReceiveAction(Ptr packet, const WifiMacHeader& header) m_stats.rxPerr++; std::vector destinations = perr->GetAddressUnitVector(); - for (std::vector::const_iterator i = - destinations.begin(); - i != destinations.end(); - i++) + for (auto i = destinations.begin(); i != destinations.end(); i++) { failedDestinations.push_back(*i); } @@ -263,7 +260,7 @@ HwmpProtocolMac::SendPreqVector(std::vector preq) NS_LOG_FUNCTION(this); Ptr packet = Create(); MeshInformationElementVector elements; - for (std::vector::iterator i = preq.begin(); i != preq.end(); i++) + for (auto i = preq.begin(); i != preq.end(); i++) { elements.AddInformationElement(Ptr(&(*i))); } @@ -278,7 +275,7 @@ HwmpProtocolMac::SendPreqVector(std::vector preq) hdr.SetAddr3(m_protocol->GetAddress()); // Send Management frame std::vector receivers = m_protocol->GetPreqReceivers(m_ifIndex); - for (std::vector::const_iterator i = receivers.begin(); i != receivers.end(); i++) + for (auto i = receivers.begin(); i != receivers.end(); i++) { hdr.SetAddr1(*i); m_stats.txPreq++; @@ -292,7 +289,7 @@ void HwmpProtocolMac::RequestDestination(Mac48Address dst, uint32_t originator_seqno, uint32_t dst_seqno) { NS_LOG_FUNCTION(this << dst << originator_seqno << dst_seqno); - for (std::vector::iterator i = m_myPreq.begin(); i != m_myPreq.end(); i++) + for (auto i = m_myPreq.begin(); i != m_myPreq.end(); i++) { if (i->IsFull()) { @@ -372,10 +369,7 @@ HwmpProtocolMac::ForwardPerr(std::vector failed Ptr packet = Create(); Ptr perr = Create(); MeshInformationElementVector elements; - for (std::vector::const_iterator i = - failedDestinations.begin(); - i != failedDestinations.end(); - i++) + for (auto i = failedDestinations.begin(); i != failedDestinations.end(); i++) { if (!perr->IsFull()) { @@ -406,7 +400,7 @@ HwmpProtocolMac::ForwardPerr(std::vector failed receivers.push_back(Mac48Address::GetBroadcast()); } // Send Management frame - for (std::vector::const_iterator i = receivers.begin(); i != receivers.end(); i++) + for (auto i = receivers.begin(); i != receivers.end(); i++) { // // 64-bit Intel valgrind complains about hdr.SetAddr1 (*i). It likes this @@ -429,13 +423,10 @@ HwmpProtocolMac::InitiatePerr(std::vector faile // All duplicates in PERR are checked here, and there is no reason to // check it at any other place { - std::vector::const_iterator end = receivers.end(); - for (std::vector::const_iterator i = receivers.begin(); i != end; i++) + for (auto i = receivers.begin(); i != receivers.end(); i++) { bool should_add = true; - for (std::vector::const_iterator j = m_myPerr.receivers.begin(); - j != m_myPerr.receivers.end(); - j++) + for (auto j = m_myPerr.receivers.begin(); j != m_myPerr.receivers.end(); j++) { if ((*i) == (*j)) { @@ -450,17 +441,10 @@ HwmpProtocolMac::InitiatePerr(std::vector faile } } { - std::vector::const_iterator end = failedDestinations.end(); - for (std::vector::const_iterator i = - failedDestinations.begin(); - i != end; - i++) + for (auto i = failedDestinations.begin(); i != failedDestinations.end(); i++) { bool should_add = true; - for (std::vector::const_iterator j = - m_myPerr.destinations.begin(); - j != m_myPerr.destinations.end(); - j++) + for (auto j = m_myPerr.destinations.begin(); j != m_myPerr.destinations.end(); j++) { if (((*i).destination == (*j).destination) && ((*j).seqnum > (*i).seqnum)) { diff --git a/src/mesh/model/dot11s/hwmp-protocol.cc b/src/mesh/model/dot11s/hwmp-protocol.cc index 1ea3b93f2..221acddd6 100644 --- a/src/mesh/model/dot11s/hwmp-protocol.cc +++ b/src/mesh/model/dot11s/hwmp-protocol.cc @@ -201,9 +201,7 @@ void HwmpProtocol::DoDispose() { NS_LOG_FUNCTION(this); - for (std::map::iterator i = m_preqTimeouts.begin(); - i != m_preqTimeouts.end(); - i++) + for (auto i = m_preqTimeouts.begin(); i != m_preqTimeouts.end(); i++) { i->second.preqTimeout.Cancel(); } @@ -263,14 +261,10 @@ HwmpProtocol::RequestRoute(uint32_t sourceIface, m_stats.txBytes += packet->GetSize(); // channel IDs where we have already sent broadcast: std::vector channels; - for (HwmpProtocolMacMap::const_iterator plugin = m_interfaces.begin(); - plugin != m_interfaces.end(); - plugin++) + for (auto plugin = m_interfaces.begin(); plugin != m_interfaces.end(); plugin++) { bool shouldSend = true; - for (std::vector::const_iterator chan = channels.begin(); - chan != channels.end(); - chan++) + for (auto chan = channels.begin(); chan != channels.end(); chan++) { if ((*chan) == plugin->second->GetChannelId()) { @@ -283,9 +277,7 @@ HwmpProtocol::RequestRoute(uint32_t sourceIface, } channels.push_back(plugin->second->GetChannelId()); std::vector receivers = GetBroadcastReceivers(plugin->first); - for (std::vector::const_iterator i = receivers.begin(); - i != receivers.end(); - i++) + for (auto i = receivers.begin(); i != receivers.end(); i++) { Ptr packetCopy = packet->Copy(); // @@ -396,8 +388,7 @@ HwmpProtocol::ForwardUnicast(uint32_t sourceIface, dst_seqno = result.seqnum; } m_stats.initiatedPreq++; - for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); - i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { i->second->RequestDestination(destination, originator_seqno, dst_seqno); } @@ -433,8 +424,7 @@ HwmpProtocol::ReceivePreq(IePreq preq, NS_LOG_FUNCTION(this << from << interface << fromMp << metric); preq.IncrementMetric(metric); // acceptance cretirea: - std::map>::const_iterator i = - m_hwmpSeqnoMetricDatabase.find(preq.GetOriginatorAddress()); + auto i = m_hwmpSeqnoMetricDatabase.find(preq.GetOriginatorAddress()); bool freshInfo(true); if (i != m_hwmpSeqnoMetricDatabase.end()) { @@ -501,9 +491,7 @@ HwmpProtocol::ReceivePreq(IePreq preq, m_routeChangeTraceSource(rChange); ReactivePathResolved(fromMp); } - for (std::vector>::const_iterator i = destinations.begin(); - i != destinations.end(); - i++) + for (auto i = destinations.begin(); i != destinations.end(); i++) { if ((*i)->GetDestinationAddress() == Mac48Address::GetBroadcast()) { @@ -603,7 +591,7 @@ HwmpProtocol::ReceivePreq(IePreq preq, } // Forward PREQ to all interfaces: NS_LOG_DEBUG("I am " << GetAddress() << "retransmitting PREQ:" << preq); - for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { Time forwardingDelay = GetMeshPoint()->GetForwardingDelay(); NS_LOG_DEBUG("Forwarding PREQ from " << from << " with delay " @@ -622,8 +610,7 @@ HwmpProtocol::ReceivePrep(IePrep prep, NS_LOG_FUNCTION(this << from << interface << fromMp << metric); prep.IncrementMetric(metric); // acceptance cretirea: - std::map>::const_iterator i = - m_hwmpSeqnoMetricDatabase.find(prep.GetOriginatorAddress()); + auto i = m_hwmpSeqnoMetricDatabase.find(prep.GetOriginatorAddress()); bool freshInfo(true); uint32_t sequence = prep.GetDestinationSeqNumber(); if (i != m_hwmpSeqnoMetricDatabase.end()) @@ -711,7 +698,7 @@ HwmpProtocol::ReceivePrep(IePrep prep, return; } // Forward PREP - HwmpProtocolMacMap::const_iterator prep_sender = m_interfaces.find(result.ifIndex); + auto prep_sender = m_interfaces.find(result.ifIndex); NS_ASSERT(prep_sender != m_interfaces.end()); Time forwardingDelay = GetMeshPoint()->GetForwardingDelay(); NS_LOG_DEBUG("Forwarding PREP from " << from << " with delay " << forwardingDelay.As(Time::US)); @@ -768,7 +755,7 @@ HwmpProtocol::SendPrep(Mac48Address src, prep.SetMetric(initMetric); prep.SetOriginatorAddress(src); prep.SetOriginatorSeqNumber(originatorDsn); - HwmpProtocolMacMap::const_iterator prep_sender = m_interfaces.find(interface); + auto prep_sender = m_interfaces.find(interface); NS_ASSERT(prep_sender != m_interfaces.end()); prep_sender->second->SendPrep(prep, retransmitter); m_stats.initiatedPrep++; @@ -780,8 +767,7 @@ HwmpProtocol::Install(Ptr mp) NS_LOG_FUNCTION(this << mp); m_mp = mp; std::vector> interfaces = mp->GetInterfaces(); - for (std::vector>::const_iterator i = interfaces.begin(); i != interfaces.end(); - i++) + for (auto i = interfaces.begin(); i != interfaces.end(); i++) { // Checking for compatible net device Ptr wifiNetDev = (*i)->GetObject(); @@ -888,7 +874,7 @@ void HwmpProtocol::InitiatePathError(PathError perr) { NS_LOG_FUNCTION(this); - for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { std::vector receivers_for_interface; for (unsigned int j = 0; j < perr.receivers.size(); j++) @@ -906,7 +892,7 @@ void HwmpProtocol::ForwardPathError(PathError perr) { NS_LOG_FUNCTION(this); - for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { std::vector receivers_for_interface; for (unsigned int j = 0; j < perr.receivers.size(); j++) @@ -1020,7 +1006,7 @@ HwmpProtocol::DequeueFirstPacketByDst(Mac48Address dst) NS_LOG_FUNCTION(this << dst); QueuedPacket retval; retval.pkt = nullptr; - for (std::vector::iterator i = m_rqueue.begin(); i != m_rqueue.end(); i++) + for (auto i = m_rqueue.begin(); i != m_rqueue.end(); i++) { if ((*i).dst == dst) { @@ -1050,7 +1036,7 @@ void HwmpProtocol::ReactivePathResolved(Mac48Address dst) { NS_LOG_FUNCTION(this << dst); - std::map::iterator i = m_preqTimeouts.find(dst); + auto i = m_preqTimeouts.find(dst); if (i != m_preqTimeouts.end()) { m_routeDiscoveryTimeCallback(Simulator::Now() - i->second.whenScheduled); @@ -1105,7 +1091,7 @@ bool HwmpProtocol::ShouldSendPreq(Mac48Address dst) { NS_LOG_FUNCTION(this << dst); - std::map::const_iterator i = m_preqTimeouts.find(dst); + auto i = m_preqTimeouts.find(dst); if (i == m_preqTimeouts.end()) { m_preqTimeouts[dst].preqTimeout = @@ -1131,7 +1117,7 @@ HwmpProtocol::RetryPathDiscovery(Mac48Address dst, uint8_t numOfRetry) } if (result.retransmitter != Mac48Address::GetBroadcast()) { - std::map::iterator i = m_preqTimeouts.find(dst); + auto i = m_preqTimeouts.find(dst); NS_ASSERT(i != m_preqTimeouts.end()); m_preqTimeouts.erase(i); return; @@ -1151,7 +1137,7 @@ HwmpProtocol::RetryPathDiscovery(Mac48Address dst, uint8_t numOfRetry) HwmpRtable::MAX_METRIC); packet = DequeueFirstPacketByDst(dst); } - std::map::iterator i = m_preqTimeouts.find(dst); + auto i = m_preqTimeouts.find(dst); NS_ASSERT(i != m_preqTimeouts.end()); m_routeDiscoveryTimeCallback(Simulator::Now() - i->second.whenScheduled); m_preqTimeouts.erase(i); @@ -1160,7 +1146,7 @@ HwmpProtocol::RetryPathDiscovery(Mac48Address dst, uint8_t numOfRetry) numOfRetry++; uint32_t originator_seqno = GetNextHwmpSeqno(); uint32_t dst_seqno = m_rtable->LookupReactiveExpired(dst).seqnum; - for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { i->second->RequestDestination(dst, originator_seqno, dst_seqno); } @@ -1203,7 +1189,7 @@ HwmpProtocol::SendProactivePreq() preq.SetOriginatorAddress(GetAddress()); preq.SetPreqID(GetNextPreqId()); preq.SetOriginatorSeqNumber(GetNextHwmpSeqno()); - for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin(); i != m_interfaces.end(); i++) + for (auto i = m_interfaces.begin(); i != m_interfaces.end(); i++) { i->second->SendPreq(preq); } @@ -1351,9 +1337,7 @@ HwmpProtocol::Report(std::ostream& os) const << "doFlag=\"" << m_doFlag << "\"" << std::endl << "rfFlag=\"" << m_rfFlag << "\">" << std::endl; m_stats.Print(os); - for (HwmpProtocolMacMap::const_iterator plugin = m_interfaces.begin(); - plugin != m_interfaces.end(); - plugin++) + for (auto plugin = m_interfaces.begin(); plugin != m_interfaces.end(); plugin++) { plugin->second->Report(os); } @@ -1365,9 +1349,7 @@ HwmpProtocol::ResetStats() { NS_LOG_FUNCTION(this); m_stats = Statistics(); - for (HwmpProtocolMacMap::const_iterator plugin = m_interfaces.begin(); - plugin != m_interfaces.end(); - plugin++) + for (auto plugin = m_interfaces.begin(); plugin != m_interfaces.end(); plugin++) { plugin->second->ResetStats(); } diff --git a/src/mesh/model/dot11s/hwmp-rtable.cc b/src/mesh/model/dot11s/hwmp-rtable.cc index c397f8cc5..ed3f21d9a 100644 --- a/src/mesh/model/dot11s/hwmp-rtable.cc +++ b/src/mesh/model/dot11s/hwmp-rtable.cc @@ -70,7 +70,7 @@ HwmpRtable::AddReactivePath(Mac48Address destination, { NS_LOG_FUNCTION(this << destination << retransmitter << interface << metric << lifetime.GetSeconds() << seqnum); - std::map::iterator i = m_routes.find(destination); + auto i = m_routes.find(destination); if (i == m_routes.end()) { ReactiveRoute newroute; @@ -113,7 +113,7 @@ HwmpRtable::AddPrecursor(Mac48Address destination, precursor.interface = precursorInterface; precursor.address = precursorAddress; precursor.whenExpire = Simulator::Now() + lifetime; - std::map::iterator i = m_routes.find(destination); + auto i = m_routes.find(destination); if (i != m_routes.end()) { bool should_add = true; @@ -161,7 +161,7 @@ void HwmpRtable::DeleteReactivePath(Mac48Address destination) { NS_LOG_FUNCTION(this << destination); - std::map::iterator i = m_routes.find(destination); + auto i = m_routes.find(destination); if (i != m_routes.end()) { m_routes.erase(i); @@ -172,7 +172,7 @@ HwmpRtable::LookupResult HwmpRtable::LookupReactive(Mac48Address destination) { NS_LOG_FUNCTION(this << destination); - std::map::iterator i = m_routes.find(destination); + auto i = m_routes.find(destination); if (i == m_routes.end()) { return LookupResult(); @@ -189,7 +189,7 @@ HwmpRtable::LookupResult HwmpRtable::LookupReactiveExpired(Mac48Address destination) { NS_LOG_FUNCTION(this << destination); - std::map::iterator i = m_routes.find(destination); + auto i = m_routes.find(destination); if (i == m_routes.end()) { return LookupResult(); @@ -232,8 +232,7 @@ HwmpRtable::GetUnreachableDestinations(Mac48Address peerAddress) NS_LOG_FUNCTION(this << peerAddress); HwmpProtocol::FailedDestination dst; std::vector retval; - for (std::map::iterator i = m_routes.begin(); i != m_routes.end(); - i++) + for (auto i = m_routes.begin(); i != m_routes.end(); i++) { if (i->second.retransmitter == peerAddress) { @@ -259,12 +258,10 @@ HwmpRtable::GetPrecursors(Mac48Address destination) NS_LOG_FUNCTION(this << destination); // We suppose that no duplicates here can be PrecursorList retval; - std::map::iterator route = m_routes.find(destination); + auto route = m_routes.find(destination); if (route != m_routes.end()) { - for (std::vector::const_iterator i = route->second.precursors.begin(); - i != route->second.precursors.end(); - i++) + for (auto i = route->second.precursors.begin(); i != route->second.precursors.end(); i++) { if (i->whenExpire > Simulator::Now()) { diff --git a/src/mesh/model/dot11s/ie-dot11s-beacon-timing.cc b/src/mesh/model/dot11s/ie-dot11s-beacon-timing.cc index a6dcfc29c..a203dd8ab 100644 --- a/src/mesh/model/dot11s/ie-dot11s-beacon-timing.cc +++ b/src/mesh/model/dot11s/ie-dot11s-beacon-timing.cc @@ -99,9 +99,7 @@ IeBeaconTiming::AddNeighboursTimingElementUnit(uint16_t aid, Time last_beacon, T return; } // First we lookup if this element already exists - for (NeighboursTimingUnitsList::const_iterator i = m_neighbours.begin(); - i != m_neighbours.end(); - i++) + for (auto i = m_neighbours.begin(); i != m_neighbours.end(); i++) { if (((*i)->GetAid() == AidToU8(aid)) && ((*i)->GetLastBeacon() == TimestampToU16(last_beacon)) && @@ -121,7 +119,7 @@ IeBeaconTiming::AddNeighboursTimingElementUnit(uint16_t aid, Time last_beacon, T void IeBeaconTiming::DelNeighboursTimingElementUnit(uint16_t aid, Time last_beacon, Time beacon_interval) { - for (NeighboursTimingUnitsList::iterator i = m_neighbours.begin(); i != m_neighbours.end(); i++) + for (auto i = m_neighbours.begin(); i != m_neighbours.end(); i++) { if (((*i)->GetAid() == AidToU8(aid)) && ((*i)->GetLastBeacon() == TimestampToU16(last_beacon)) && @@ -137,7 +135,7 @@ IeBeaconTiming::DelNeighboursTimingElementUnit(uint16_t aid, Time last_beacon, T void IeBeaconTiming::ClearTimingElement() { - for (NeighboursTimingUnitsList::iterator j = m_neighbours.begin(); j != m_neighbours.end(); j++) + for (auto j = m_neighbours.begin(); j != m_neighbours.end(); j++) { (*j) = nullptr; } @@ -154,9 +152,7 @@ void IeBeaconTiming::Print(std::ostream& os) const { os << "BeaconTiming=(Number of units=" << (uint16_t)m_numOfUnits; - for (NeighboursTimingUnitsList::const_iterator j = m_neighbours.begin(); - j != m_neighbours.end(); - j++) + for (auto j = m_neighbours.begin(); j != m_neighbours.end(); j++) { os << "(AID=" << (uint16_t)(*j)->GetAid() << ", Last beacon at=" << (*j)->GetLastBeacon() << ", with beacon interval=" << (*j)->GetBeaconInterval() << ")"; @@ -167,9 +163,7 @@ IeBeaconTiming::Print(std::ostream& os) const void IeBeaconTiming::SerializeInformationField(Buffer::Iterator i) const { - for (NeighboursTimingUnitsList::const_iterator j = m_neighbours.begin(); - j != m_neighbours.end(); - j++) + for (auto j = m_neighbours.begin(); j != m_neighbours.end(); j++) { i.WriteU8((*j)->GetAid()); i.WriteHtolsbU16((*j)->GetLastBeacon()); @@ -223,7 +217,7 @@ IeBeaconTiming::operator==(const WifiInformationElement& a) const { try { - const IeBeaconTiming& aa = dynamic_cast(a); + const auto& aa = dynamic_cast(a); if (m_numOfUnits != aa.m_numOfUnits) { diff --git a/src/mesh/model/dot11s/ie-dot11s-perr.cc b/src/mesh/model/dot11s/ie-dot11s-perr.cc index 2c40cbb0a..79555cd95 100644 --- a/src/mesh/model/dot11s/ie-dot11s-perr.cc +++ b/src/mesh/model/dot11s/ie-dot11s-perr.cc @@ -140,9 +140,7 @@ IePerr::GetAddressUnitVector() const void IePerr::DeleteAddressUnit(Mac48Address address) { - for (std::vector::iterator i = m_addressUnits.begin(); - i != m_addressUnits.end(); - i++) + for (auto i = m_addressUnits.begin(); i != m_addressUnits.end(); i++) { if (i->destination == address) { diff --git a/src/mesh/model/dot11s/ie-dot11s-preq.cc b/src/mesh/model/dot11s/ie-dot11s-preq.cc index 88c2b5688..eef8b546b 100644 --- a/src/mesh/model/dot11s/ie-dot11s-preq.cc +++ b/src/mesh/model/dot11s/ie-dot11s-preq.cc @@ -266,9 +266,7 @@ IePreq::SerializeInformationField(Buffer::Iterator i) const i.WriteHtolsbU32(m_metric); i.WriteU8(m_destCount); int written = 0; - for (std::vector>::const_iterator j = m_destinations.begin(); - j != m_destinations.end(); - j++) + for (auto j = m_destinations.begin(); j != m_destinations.end(); j++) { uint8_t flags = 0; if ((*j)->IsDo()) @@ -386,9 +384,7 @@ IePreq::AddDestinationAddressElement(bool doFlag, Mac48Address dest_address, uint32_t dest_seq_number) { - for (std::vector>::const_iterator i = m_destinations.begin(); - i != m_destinations.end(); - i++) + for (auto i = m_destinations.begin(); i != m_destinations.end(); i++) { if ((*i)->GetDestinationAddress() == dest_address) { @@ -407,9 +403,7 @@ IePreq::AddDestinationAddressElement(bool doFlag, void IePreq::DelDestinationAddressElement(Mac48Address dest_address) { - for (std::vector>::iterator i = m_destinations.begin(); - i != m_destinations.end(); - i++) + for (auto i = m_destinations.begin(); i != m_destinations.end(); i++) { if ((*i)->GetDestinationAddress() == dest_address) { @@ -423,9 +417,7 @@ IePreq::DelDestinationAddressElement(Mac48Address dest_address) void IePreq::ClearDestinationAddressElements() { - for (std::vector>::iterator j = m_destinations.begin(); - j != m_destinations.end(); - j++) + for (auto j = m_destinations.begin(); j != m_destinations.end(); j++) { (*j) = nullptr; } diff --git a/src/mesh/model/dot11s/peer-management-protocol.cc b/src/mesh/model/dot11s/peer-management-protocol.cc index f945505f8..7ab49548a 100644 --- a/src/mesh/model/dot11s/peer-management-protocol.cc +++ b/src/mesh/model/dot11s/peer-management-protocol.cc @@ -105,9 +105,9 @@ PeerManagementProtocol::DoDispose() { // cancel cleanup event and go through the map of peer links, // deleting each - for (PeerLinksMap::iterator j = m_peerLinks.begin(); j != m_peerLinks.end(); j++) + for (auto j = m_peerLinks.begin(); j != m_peerLinks.end(); j++) { - for (PeerLinksOnInterface::iterator i = j->second.begin(); i != j->second.end(); i++) + for (auto i = j->second.begin(); i != j->second.end(); i++) { (*i) = nullptr; } @@ -121,7 +121,7 @@ bool PeerManagementProtocol::Install(Ptr mp) { std::vector> interfaces = mp->GetInterfaces(); - for (std::vector>::iterator i = interfaces.begin(); i != interfaces.end(); i++) + for (auto i = interfaces.begin(); i != interfaces.end(); i++) { Ptr wifiNetDev = (*i)->GetObject(); if (!wifiNetDev) @@ -154,9 +154,9 @@ PeerManagementProtocol::GetBeaconTimingElement(uint32_t interface) return nullptr; } Ptr retval = Create(); - PeerLinksMap::iterator iface = m_peerLinks.find(interface); + auto iface = m_peerLinks.find(interface); NS_ASSERT(iface != m_peerLinks.end()); - for (PeerLinksOnInterface::iterator i = iface->second.begin(); i != iface->second.end(); i++) + for (auto i = iface->second.begin(); i != iface->second.end(); i++) { // If we do not know peer Assoc Id, we shall not add any info // to a beacon timing element @@ -180,8 +180,7 @@ PeerManagementProtocol::ReceiveBeacon(uint32_t interface, { // PM STATE Machine // Check that a given beacon is not from our interface - for (PeerManagementProtocolMacMap::const_iterator i = m_plugins.begin(); i != m_plugins.end(); - i++) + for (auto i = m_plugins.begin(); i != m_plugins.end(); i++) { if (i->second->GetAddress() == peerAddress) { @@ -304,9 +303,9 @@ PeerManagementProtocol::InitiateLink(uint32_t interface, NS_FATAL_ERROR("Peer link must not exist."); } // Plugin must exist - PeerManagementProtocolMacMap::iterator plugin = m_plugins.find(interface); + auto plugin = m_plugins.find(interface); NS_ASSERT(plugin != m_plugins.end()); - PeerLinksMap::iterator iface = m_peerLinks.find(interface); + auto iface = m_peerLinks.find(interface); NS_ASSERT(iface != m_peerLinks.end()); new_link->SetLocalAid(m_lastAssocId++); new_link->SetInterface(interface); @@ -323,9 +322,9 @@ PeerManagementProtocol::InitiateLink(uint32_t interface, Ptr PeerManagementProtocol::FindPeerLink(uint32_t interface, Mac48Address peerAddress) { - PeerLinksMap::iterator iface = m_peerLinks.find(interface); + auto iface = m_peerLinks.find(interface); NS_ASSERT(iface != m_peerLinks.end()); - for (PeerLinksOnInterface::iterator i = iface->second.begin(); i != iface->second.end(); i++) + for (auto i = iface->second.begin(); i != iface->second.end(); i++) { if ((*i)->GetPeerAddress() == peerAddress) { @@ -355,10 +354,9 @@ std::vector PeerManagementProtocol::GetPeers(uint32_t interface) const { std::vector retval; - PeerLinksMap::const_iterator iface = m_peerLinks.find(interface); + auto iface = m_peerLinks.find(interface); NS_ASSERT(iface != m_peerLinks.end()); - for (PeerLinksOnInterface::const_iterator i = iface->second.begin(); i != iface->second.end(); - i++) + for (auto i = iface->second.begin(); i != iface->second.end(); i++) { if ((*i)->LinkIsEstab()) { @@ -373,12 +371,9 @@ PeerManagementProtocol::GetPeerLinks() const { std::vector> links; - for (PeerLinksMap::const_iterator iface = m_peerLinks.begin(); iface != m_peerLinks.end(); - ++iface) + for (auto iface = m_peerLinks.begin(); iface != m_peerLinks.end(); ++iface) { - for (PeerLinksOnInterface::const_iterator i = iface->second.begin(); - i != iface->second.end(); - i++) + for (auto i = iface->second.begin(); i != iface->second.end(); i++) { if ((*i)->LinkIsEstab()) { @@ -426,19 +421,18 @@ PeerManagementProtocol::CheckBeaconCollisions(uint32_t interface) { return; } - PeerLinksMap::iterator iface = m_peerLinks.find(interface); + auto iface = m_peerLinks.find(interface); NS_ASSERT(iface != m_peerLinks.end()); NS_ASSERT(m_plugins.find(interface) != m_plugins.end()); - std::map::const_iterator lastBeacon = m_lastBeacon.find(interface); - std::map::const_iterator beaconInterval = m_beaconInterval.find(interface); + auto lastBeacon = m_lastBeacon.find(interface); + auto beaconInterval = m_beaconInterval.find(interface); if ((lastBeacon == m_lastBeacon.end()) || (beaconInterval == m_beaconInterval.end())) { return; } // my last beacon in 256 us units - uint16_t lastBeaconInTimeElement = - (uint16_t)((lastBeacon->second.GetMicroSeconds() >> 8) & 0xffff); + auto lastBeaconInTimeElement = (uint16_t)((lastBeacon->second.GetMicroSeconds() >> 8) & 0xffff); NS_ASSERT_MSG(TuToTime(m_maxBeaconShift) <= m_beaconInterval[interface], "Wrong beacon shift parameters"); @@ -451,14 +445,12 @@ PeerManagementProtocol::CheckBeaconCollisions(uint32_t interface) } // check whether all my peers receive my beacon and I'am not in collision with other beacons - for (PeerLinksOnInterface::iterator i = iface->second.begin(); i != iface->second.end(); i++) + for (auto i = iface->second.begin(); i != iface->second.end(); i++) { bool myBeaconExists = false; IeBeaconTiming::NeighboursTimingUnitsList neighbors = (*i)->GetBeaconTimingElement().GetNeighboursTimingElementsList(); - for (IeBeaconTiming::NeighboursTimingUnitsList::const_iterator j = neighbors.begin(); - j != neighbors.end(); - j++) + for (auto j = neighbors.begin(); j != neighbors.end(); j++) { if ((*i)->GetPeerAid() == (*j)->GetAid()) { @@ -494,7 +486,7 @@ PeerManagementProtocol::ShiftOwnBeacon(uint32_t interface) shift = (int)m_beaconShift->GetValue(); } while (shift == 0); // Apply beacon shift parameters: - PeerManagementProtocolMacMap::iterator plugin = m_plugins.find(interface); + auto plugin = m_plugins.find(interface); NS_ASSERT(plugin != m_plugins.end()); plugin->second->SetBeaconShift(TuToTime(shift)); } @@ -550,7 +542,7 @@ PeerManagementProtocol::PeerLinkStatus(uint32_t interface, PeerLink::PeerState ostate, PeerLink::PeerState nstate) { - PeerManagementProtocolMacMap::iterator plugin = m_plugins.find(interface); + auto plugin = m_plugins.find(interface); NS_ASSERT(plugin != m_plugins.end()); NS_LOG_DEBUG("Link between me:" << m_address << " my interface:" << plugin->second->GetAddress() << " and peer mesh point:" << peerMeshPointAddress @@ -635,18 +627,14 @@ PeerManagementProtocol::Report(std::ostream& os) const { os << "" << std::endl; m_stats.Print(os); - for (PeerManagementProtocolMacMap::const_iterator plugins = m_plugins.begin(); - plugins != m_plugins.end(); - plugins++) + for (auto plugins = m_plugins.begin(); plugins != m_plugins.end(); plugins++) { // Take statistics from plugin: plugins->second->Report(os); // Print all active peer links: - PeerLinksMap::const_iterator iface = m_peerLinks.find(plugins->second->m_ifIndex); + auto iface = m_peerLinks.find(plugins->second->m_ifIndex); NS_ASSERT(iface != m_peerLinks.end()); - for (PeerLinksOnInterface::const_iterator i = iface->second.begin(); - i != iface->second.end(); - i++) + for (auto i = iface->second.begin(); i != iface->second.end(); i++) { (*i)->Report(os); } @@ -658,9 +646,7 @@ void PeerManagementProtocol::ResetStats() { m_stats = Statistics(m_stats.linksTotal); // don't reset number of links - for (PeerManagementProtocolMacMap::const_iterator plugins = m_plugins.begin(); - plugins != m_plugins.end(); - plugins++) + for (auto plugins = m_plugins.begin(); plugins != m_plugins.end(); plugins++) { plugins->second->ResetStats(); } diff --git a/src/mesh/model/flame/flame-protocol.cc b/src/mesh/model/flame/flame-protocol.cc index d4dc1cce1..e046b5b14 100644 --- a/src/mesh/model/flame/flame-protocol.cc +++ b/src/mesh/model/flame/flame-protocol.cc @@ -324,8 +324,7 @@ FlameProtocol::Install(Ptr mp) { m_mp = mp; std::vector> interfaces = mp->GetInterfaces(); - for (std::vector>::const_iterator i = interfaces.begin(); i != interfaces.end(); - i++) + for (auto i = interfaces.begin(); i != interfaces.end(); i++) { // Checking for compatible net device Ptr wifiNetDev = (*i)->GetObject(); @@ -423,8 +422,7 @@ FlameProtocol::Report(std::ostream& os) const << "broadcastInterval=\"" << m_broadcastInterval.GetSeconds() << "\"" << std::endl << "maxCost=\"" << (uint16_t)m_maxCost << "\">" << std::endl; m_stats.Print(os); - for (FlamePluginMap::const_iterator plugin = m_interfaces.begin(); plugin != m_interfaces.end(); - plugin++) + for (auto plugin = m_interfaces.begin(); plugin != m_interfaces.end(); plugin++) { plugin->second->Report(os); } @@ -435,8 +433,7 @@ void FlameProtocol::ResetStats() { m_stats = Statistics(); - for (FlamePluginMap::const_iterator plugin = m_interfaces.begin(); plugin != m_interfaces.end(); - plugin++) + for (auto plugin = m_interfaces.begin(); plugin != m_interfaces.end(); plugin++) { plugin->second->ResetStats(); } diff --git a/src/mesh/model/flame/flame-rtable.cc b/src/mesh/model/flame/flame-rtable.cc index 2bbc097be..e885270c6 100644 --- a/src/mesh/model/flame/flame-rtable.cc +++ b/src/mesh/model/flame/flame-rtable.cc @@ -70,7 +70,7 @@ FlameRtable::AddPath(const Mac48Address destination, const uint8_t cost, const uint16_t seqnum) { - std::map::iterator i = m_routes.find(destination); + auto i = m_routes.find(destination); if (i == m_routes.end()) { Route newroute; @@ -93,7 +93,7 @@ FlameRtable::AddPath(const Mac48Address destination, FlameRtable::LookupResult FlameRtable::Lookup(Mac48Address destination) { - std::map::iterator i = m_routes.find(destination); + auto i = m_routes.find(destination); if (i == m_routes.end()) { return LookupResult(); diff --git a/src/mesh/model/mesh-information-element-vector.cc b/src/mesh/model/mesh-information-element-vector.cc index 26a05e654..bb58b0234 100644 --- a/src/mesh/model/mesh-information-element-vector.cc +++ b/src/mesh/model/mesh-information-element-vector.cc @@ -47,7 +47,7 @@ MeshInformationElementVector::MeshInformationElementVector() MeshInformationElementVector::~MeshInformationElementVector() { - for (IE_VECTOR::iterator i = m_elements.begin(); i != m_elements.end(); i++) + for (auto i = m_elements.begin(); i != m_elements.end(); i++) { *i = nullptr; } @@ -79,7 +79,7 @@ MeshInformationElementVector::GetSerializedSize() const void MeshInformationElementVector::Serialize(Buffer::Iterator start) const { - for (IE_VECTOR::const_iterator i = m_elements.begin(); i != m_elements.end(); i++) + for (auto i = m_elements.begin(); i != m_elements.end(); i++) { start = (*i)->Serialize(start); } @@ -164,7 +164,7 @@ MeshInformationElementVector::DeserializeSingleIe(Buffer::Iterator start) void MeshInformationElementVector::Print(std::ostream& os) const { - for (IE_VECTOR::const_iterator i = m_elements.begin(); i != m_elements.end(); i++) + for (auto i = m_elements.begin(); i != m_elements.end(); i++) { os << "("; (*i)->Print(os); @@ -198,7 +198,7 @@ MeshInformationElementVector::AddInformationElement(Ptr Ptr MeshInformationElementVector::FindFirst(WifiInformationElementId id) const { - for (IE_VECTOR::const_iterator i = m_elements.begin(); i != m_elements.end(); i++) + for (auto i = m_elements.begin(); i != m_elements.end(); i++) { if ((*i)->ElementId() == id) { @@ -212,7 +212,7 @@ uint32_t MeshInformationElementVector::GetSize() const { uint32_t size = 0; - for (IE_VECTOR::const_iterator i = m_elements.begin(); i != m_elements.end(); i++) + for (auto i = m_elements.begin(); i != m_elements.end(); i++) { size += (*i)->GetSerializedSize(); } @@ -234,10 +234,8 @@ MeshInformationElementVector::operator==(const MeshInformationElementVector& a) // I'm leaving it like this, however, so that there is the option of // having individual Information Elements implement slightly more // flexible equality operators. - MeshInformationElementVector::IE_VECTOR::const_iterator j = a.m_elements.begin(); - for (MeshInformationElementVector::IE_VECTOR::const_iterator i = m_elements.begin(); - i != m_elements.end(); - i++, j++) + auto j = a.m_elements.begin(); + for (auto i = m_elements.begin(); i != m_elements.end(); i++, j++) { if (!(*(*i) == *(*j))) { diff --git a/src/mesh/model/mesh-point-device.cc b/src/mesh/model/mesh-point-device.cc index 2c568f1fa..8e6bc37d1 100644 --- a/src/mesh/model/mesh-point-device.cc +++ b/src/mesh/model/mesh-point-device.cc @@ -83,8 +83,7 @@ void MeshPointDevice::DoDispose() { NS_LOG_FUNCTION(this); - for (std::vector>::iterator iter = m_ifaces.begin(); iter != m_ifaces.end(); - iter++) + for (auto iter = m_ifaces.begin(); iter != m_ifaces.end(); iter++) { *iter = nullptr; } @@ -399,7 +398,7 @@ Ptr MeshPointDevice::GetInterface(uint32_t n) const { NS_LOG_FUNCTION(this << n); - for (std::vector>::const_iterator i = m_ifaces.begin(); i != m_ifaces.end(); i++) + for (auto i = m_ifaces.begin(); i != m_ifaces.end(); i++) { if ((*i)->GetIfIndex() == n) { @@ -516,7 +515,7 @@ MeshPointDevice::DoSend(bool success, } else { - for (std::vector>::iterator i = m_ifaces.begin(); i != m_ifaces.end(); i++) + for (auto i = m_ifaces.begin(); i != m_ifaces.end(); i++) { (*i)->SendFrom(packet->Copy(), src, dst, protocol); } diff --git a/src/mesh/model/mesh-wifi-interface-mac.cc b/src/mesh/model/mesh-wifi-interface-mac.cc index baf6fe1de..4c5be44ac 100644 --- a/src/mesh/model/mesh-wifi-interface-mac.cc +++ b/src/mesh/model/mesh-wifi-interface-mac.cc @@ -167,7 +167,7 @@ MeshWifiInterfaceMac::AssignStreams(int64_t stream) NS_LOG_FUNCTION(this << stream); int64_t currentStream = stream; m_coefficient->SetStream(currentStream++); - for (PluginList::const_iterator i = m_plugins.begin(); i < m_plugins.end(); i++) + for (auto i = m_plugins.begin(); i < m_plugins.end(); i++) { currentStream += (*i)->AssignStreams(currentStream); } @@ -240,7 +240,7 @@ MeshWifiInterfaceMac::ForwardDown(Ptr packet, Mac48Address from, Mac48Ad // Address 1 is unknown here. Routing plugin is responsible to correctly set it. hdr.SetAddr1(Mac48Address()); // Filter packet through all installed plugins - for (PluginList::const_iterator i = m_plugins.end() - 1; i != m_plugins.begin() - 1; i--) + for (auto i = m_plugins.end() - 1; i != m_plugins.begin() - 1; i--) { bool drop = !((*i)->UpdateOutcomingFrame(packet, hdr, from, to)); if (drop) @@ -286,7 +286,7 @@ MeshWifiInterfaceMac::SendManagementFrame(Ptr packet, const WifiMacHeade { // Filter management frames: WifiMacHeader header = hdr; - for (PluginList::const_iterator i = m_plugins.end() - 1; i != m_plugins.begin() - 1; i--) + for (auto i = m_plugins.end() - 1; i != m_plugins.begin() - 1; i--) { bool drop = !((*i)->UpdateOutcomingFrame(packet, header, Mac48Address(), Mac48Address())); if (drop) @@ -429,7 +429,7 @@ MeshWifiInterfaceMac::SendBeacon() MeshWifiBeacon beacon(GetSsid(), GetSupportedRates(), m_beaconInterval.GetMicroSeconds()); // Ask all plugins to add their specific information elements to beacon - for (PluginList::const_iterator i = m_plugins.begin(); i != m_plugins.end(); ++i) + for (auto i = m_plugins.begin(); i != m_plugins.end(); ++i) { (*i)->UpdateBeacon(beacon); } @@ -487,7 +487,7 @@ MeshWifiInterfaceMac::Receive(Ptr mpdu, uint8_t linkId) m_stats.recvFrames++; } // Filter frame through all installed plugins - for (PluginList::iterator i = m_plugins.begin(); i != m_plugins.end(); ++i) + for (auto i = m_plugins.begin(); i != m_plugins.end(); ++i) { bool drop = !((*i)->Receive(packet, *hdr)); if (drop) diff --git a/src/mesh/test/dot11s/dot11s-test-suite.cc b/src/mesh/test/dot11s/dot11s-test-suite.cc index 99b0744ec..b1cdaa3b8 100644 --- a/src/mesh/test/dot11s/dot11s-test-suite.cc +++ b/src/mesh/test/dot11s/dot11s-test-suite.cc @@ -186,8 +186,7 @@ HwmpRtableTest::TestExpire() void HwmpRtableTest::TestPrecursorAdd() { - for (std::vector::const_iterator i = precursors.begin(); i != precursors.end(); - i++) + for (auto i = precursors.begin(); i != precursors.end(); i++) { table->AddPrecursor(dst, iface, *i, Seconds(100)); // Check that duplicates are filtered diff --git a/src/mobility/examples/main-grid-topology.cc b/src/mobility/examples/main-grid-topology.cc index 8941b00ea..c1c7fc493 100644 --- a/src/mobility/examples/main-grid-topology.cc +++ b/src/mobility/examples/main-grid-topology.cc @@ -61,7 +61,7 @@ main(int argc, char* argv[]) mobility.Install(nodes); // iterate our nodes and print their position. - for (NodeContainer::Iterator j = nodes.Begin(); j != nodes.End(); ++j) + for (auto j = nodes.Begin(); j != nodes.End(); ++j) { Ptr object = *j; Ptr position = object->GetObject(); diff --git a/src/mobility/helper/group-mobility-helper.cc b/src/mobility/helper/group-mobility-helper.cc index 1544f4f9c..e7834756e 100644 --- a/src/mobility/helper/group-mobility-helper.cc +++ b/src/mobility/helper/group-mobility-helper.cc @@ -101,7 +101,7 @@ GroupMobilityHelper::Install(std::string nodeName) void GroupMobilityHelper::Install(NodeContainer c) { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Install(*i); } @@ -114,7 +114,7 @@ GroupMobilityHelper::AssignStreams(NodeContainer c, int64_t stream) Ptr node; bool firstNode = true; Ptr mobility; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { node = (*i); mobility = node->GetObject(); diff --git a/src/mobility/helper/mobility-helper.cc b/src/mobility/helper/mobility-helper.cc index 9bd7bc9b3..7047ce788 100644 --- a/src/mobility/helper/mobility-helper.cc +++ b/src/mobility/helper/mobility-helper.cc @@ -126,7 +126,7 @@ MobilityHelper::Install(std::string nodeName) const void MobilityHelper::Install(NodeContainer c) const { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Install(*i); } @@ -201,7 +201,7 @@ MobilityHelper::EnableAscii(Ptr stream, uint32_t nodeid) void MobilityHelper::EnableAscii(Ptr stream, NodeContainer n) { - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { EnableAscii(stream, (*i)->GetId()); } @@ -219,7 +219,7 @@ MobilityHelper::AssignStreams(NodeContainer c, int64_t stream) int64_t currentStream = stream; Ptr node; Ptr mobility; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { node = (*i); mobility = node->GetObject(); diff --git a/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc b/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc index 19a9200b4..bc9dd8fd7 100644 --- a/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc +++ b/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc @@ -106,11 +106,9 @@ SteadyStateRandomWaypointTest::DistribCompare() double sum_x = 0; double sum_y = 0; double sum_v = 0; - std::vector>::iterator i; - Ptr model; - for (i = mobilityStack.begin(); i != mobilityStack.end(); ++i) + for (auto i = mobilityStack.begin(); i != mobilityStack.end(); ++i) { - model = (*i); + auto model = (*i); velocity = std::sqrt(std::pow(model->GetVelocity().x, 2) + std::pow(model->GetVelocity().y, 2)); sum_x += model->GetPosition().x; @@ -129,9 +127,9 @@ SteadyStateRandomWaypointTest::DistribCompare() sum_y = 0; sum_v = 0; double tmp; - for (i = mobilityStack.begin(); i != mobilityStack.end(); ++i) + for (auto i = mobilityStack.begin(); i != mobilityStack.end(); ++i) { - model = (*i); + auto model = (*i); velocity = std::sqrt(std::pow(model->GetVelocity().x, 2) + std::pow(model->GetVelocity().y, 2)); tmp = model->GetPosition().x - mean_x; diff --git a/src/mobility/test/waypoint-mobility-model-test.cc b/src/mobility/test/waypoint-mobility-model-test.cc index 92704257b..32c92ae41 100644 --- a/src/mobility/test/waypoint-mobility-model-test.cc +++ b/src/mobility/test/waypoint-mobility-model-test.cc @@ -105,15 +105,14 @@ WaypointMobilityModelNotifyTest::DoRun() } // Add the same waypoints to each node - std::vector>::iterator i; - for (i = mobilityStack.begin(); i != mobilityStack.end(); ++i) + for (auto i = mobilityStack.begin(); i != mobilityStack.end(); ++i) { Ptr mob = (*i)->GetObject(); mob->TraceConnectWithoutContext( "CourseChange", MakeCallback(&WaypointMobilityModelNotifyTest::CourseChangeCallback, this)); - for (std::deque::iterator w = waypoints.begin(); w != waypoints.end(); ++w) + for (auto w = waypoints.begin(); w != waypoints.end(); ++w) { mob->AddWaypoint(*w); } @@ -135,8 +134,7 @@ WaypointMobilityModelNotifyTest::DoRun() void WaypointMobilityModelNotifyTest::ForceUpdates() { - std::vector>::iterator i; - for (i = mobilityStack.begin(); i != mobilityStack.end(); ++i) + for (auto i = mobilityStack.begin(); i != mobilityStack.end(); ++i) { Ptr mob = (*i)->GetObject(); mob->Update(); diff --git a/src/mpi/model/distributed-simulator-impl.cc b/src/mpi/model/distributed-simulator-impl.cc index 1c6914639..425d1437e 100644 --- a/src/mpi/model/distributed-simulator-impl.cc +++ b/src/mpi/model/distributed-simulator-impl.cc @@ -172,7 +172,7 @@ DistributedSimulatorImpl::CalculateLookAhead() else { NodeContainer c = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator iter = c.Begin(); iter != c.End(); ++iter) + for (auto iter = c.Begin(); iter != c.End(); ++iter) { if ((*iter)->GetSystemId() != MpiInterface::GetSystemId()) { @@ -553,7 +553,7 @@ DistributedSimulatorImpl::Remove(const EventId& id) if (id.GetUid() == EventId::UID::DESTROY) { // destroy events. - for (DestroyEvents::iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { @@ -599,8 +599,7 @@ DistributedSimulatorImpl::IsExpired(const EventId& id) const return true; } // destroy events. - for (DestroyEvents::const_iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); - i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { diff --git a/src/mpi/model/granted-time-window-mpi-interface.cc b/src/mpi/model/granted-time-window-mpi-interface.cc index 488bcf34a..616108a72 100644 --- a/src/mpi/model/granted-time-window-mpi-interface.cc +++ b/src/mpi/model/granted-time-window-mpi-interface.cc @@ -219,16 +219,16 @@ GrantedTimeWindowMpiInterface::SendPacket(Ptr p, SentBuffer sendBuf; g_pendingTx.push_back(sendBuf); - std::list::reverse_iterator i = g_pendingTx.rbegin(); // Points to the last element + auto i = g_pendingTx.rbegin(); // Points to the last element uint32_t serializedSize = p->GetSerializedSize(); - uint8_t* buffer = new uint8_t[serializedSize + 16]; + auto buffer = new uint8_t[serializedSize + 16]; i->SetBuffer(buffer); // Add the time, dest node and dest device uint64_t t = rxTime.GetInteger(); - uint64_t* pTime = reinterpret_cast(buffer); + auto pTime = reinterpret_cast(buffer); *pTime++ = t; - uint32_t* pData = reinterpret_cast(pTime); + auto pData = reinterpret_cast(pTime); *pData++ = node; *pData++ = dev; // Serialize the packet @@ -270,9 +270,9 @@ GrantedTimeWindowMpiInterface::ReceiveMessages() g_rxCount++; // Count this receive // Get the meta data first - uint64_t* pTime = reinterpret_cast(g_pRxBuffers[index]); + auto pTime = reinterpret_cast(g_pRxBuffers[index]); uint64_t time = *pTime++; - uint32_t* pData = reinterpret_cast(pTime); + auto pData = reinterpret_cast(pTime); uint32_t node = *pData++; uint32_t dev = *pData++; @@ -321,14 +321,14 @@ GrantedTimeWindowMpiInterface::TestSendComplete() { NS_LOG_FUNCTION_NOARGS(); - std::list::iterator i = g_pendingTx.begin(); + auto i = g_pendingTx.begin(); while (i != g_pendingTx.end()) { MPI_Status status; int flag = 0; MPI_Test(i->GetRequest(), &flag, &status); - std::list::iterator current = i; // Save current for erasing - i++; // Advance to next + auto current = i; // Save current for erasing + i++; // Advance to next if (flag) { // This message is complete g_pendingTx.erase(current); diff --git a/src/mpi/model/null-message-mpi-interface.cc b/src/mpi/model/null-message-mpi-interface.cc index cdab32df6..7341d8800 100644 --- a/src/mpi/model/null-message-mpi-interface.cc +++ b/src/mpi/model/null-message-mpi-interface.cc @@ -270,23 +270,22 @@ NullMessageMpiInterface::SendPacket(Ptr p, const Time& rxTime, uint32_t NullMessageSentBuffer sendBuf; g_pendingTx.push_back(sendBuf); - std::list::reverse_iterator iter = - g_pendingTx.rbegin(); // Points to the last element + auto iter = g_pendingTx.rbegin(); // Points to the last element uint32_t serializedSize = p->GetSerializedSize(); uint32_t bufferSize = serializedSize + (2 * sizeof(uint64_t)) + (2 * sizeof(uint32_t)); - uint8_t* buffer = new uint8_t[bufferSize]; + auto buffer = new uint8_t[bufferSize]; iter->SetBuffer(buffer); // Add the time, dest node and dest device uint64_t t = rxTime.GetInteger(); - uint64_t* pTime = reinterpret_cast(buffer); + auto pTime = reinterpret_cast(buffer); *pTime++ = t; Time guarantee_update = NullMessageSimulatorImpl::GetInstance()->CalculateGuaranteeTime(nodeSysId); *pTime++ = guarantee_update.GetTimeStep(); - uint32_t* pData = reinterpret_cast(pTime); + auto pData = reinterpret_cast(pTime); *pData++ = node; *pData++ = dev; // Serialize the packet @@ -313,17 +312,16 @@ NullMessageMpiInterface::SendNullMessage(const Time& guarantee_update, NullMessageSentBuffer sendBuf; g_pendingTx.push_back(sendBuf); - std::list::reverse_iterator iter = - g_pendingTx.rbegin(); // Points to the last element + auto iter = g_pendingTx.rbegin(); // Points to the last element uint32_t bufferSize = 2 * sizeof(uint64_t) + 2 * sizeof(uint32_t); - uint8_t* buffer = new uint8_t[bufferSize]; + auto buffer = new uint8_t[bufferSize]; iter->SetBuffer(buffer); // Add the time, dest node and dest device - uint64_t* pTime = reinterpret_cast(buffer); + auto pTime = reinterpret_cast(buffer); *pTime++ = 0; *pTime++ = guarantee_update.GetInteger(); - uint32_t* pData = reinterpret_cast(pTime); + auto pData = reinterpret_cast(pTime); *pData++ = 0; *pData++ = 0; @@ -395,11 +393,11 @@ NullMessageMpiInterface::ReceiveMessages(bool blocking) MPI_Get_count(&status, MPI_CHAR, &count); // Get the meta data first - uint64_t* pTime = reinterpret_cast(g_pRxBuffers[index]); + auto pTime = reinterpret_cast(g_pRxBuffers[index]); uint64_t time = *pTime++; uint64_t guaranteeUpdate = *pTime++; - uint32_t* pData = reinterpret_cast(pTime); + auto pData = reinterpret_cast(pTime); uint32_t node = *pData++; uint32_t dev = *pData++; @@ -465,14 +463,14 @@ NullMessageMpiInterface::TestSendComplete() NS_ASSERT(g_enabled); - std::list::iterator iter = g_pendingTx.begin(); + auto iter = g_pendingTx.begin(); while (iter != g_pendingTx.end()) { MPI_Status status; int flag = 0; MPI_Test(iter->GetRequest(), &flag, &status); - std::list::iterator current = iter; // Save current for erasing - ++iter; // Advance to next + auto current = iter; // Save current for erasing + ++iter; // Advance to next if (flag) { // This message is complete g_pendingTx.erase(current); @@ -487,9 +485,7 @@ NullMessageMpiInterface::Disable() if (g_enabled) { - for (std::list::iterator iter = g_pendingTx.begin(); - iter != g_pendingTx.end(); - ++iter) + for (auto iter = g_pendingTx.begin(); iter != g_pendingTx.end(); ++iter) { MPI_Cancel(iter->GetRequest()); MPI_Request_free(iter->GetRequest()); diff --git a/src/mpi/model/null-message-simulator-impl.cc b/src/mpi/model/null-message-simulator-impl.cc index 03d3ad948..59446ab72 100644 --- a/src/mpi/model/null-message-simulator-impl.cc +++ b/src/mpi/model/null-message-simulator-impl.cc @@ -140,7 +140,7 @@ NullMessageSimulatorImpl::CalculateLookAhead() if (MpiInterface::GetSize() > 1) { NodeContainer c = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator iter = c.Begin(); iter != c.End(); ++iter) + for (auto iter = c.Begin(); iter != c.End(); ++iter) { if ((*iter)->GetSystemId() != MpiInterface::GetSystemId()) { @@ -476,7 +476,7 @@ NullMessageSimulatorImpl::Remove(const EventId& id) if (id.GetUid() == EventId::UID::DESTROY) { // destroy events. - for (DestroyEvents::iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { @@ -522,8 +522,7 @@ NullMessageSimulatorImpl::IsExpired(const EventId& id) const return true; } // destroy events. - for (DestroyEvents::const_iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); - i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { diff --git a/src/mpi/model/remote-channel-bundle-manager.cc b/src/mpi/model/remote-channel-bundle-manager.cc index c7d094716..222f5827c 100644 --- a/src/mpi/model/remote-channel-bundle-manager.cc +++ b/src/mpi/model/remote-channel-bundle-manager.cc @@ -41,8 +41,7 @@ ns3::RemoteChannelBundleManager::RemoteChannelMap Ptr RemoteChannelBundleManager::Find(uint32_t systemId) { - ns3::RemoteChannelBundleManager::RemoteChannelMap::iterator kv = - g_remoteChannelBundles.find(systemId); + auto kv = g_remoteChannelBundles.find(systemId); if (kv == g_remoteChannelBundles.end()) { @@ -78,9 +77,7 @@ RemoteChannelBundleManager::InitializeNullMessageEvents() { NS_ASSERT(!g_initialized); - for (RemoteChannelMap::const_iterator iter = g_remoteChannelBundles.begin(); - iter != g_remoteChannelBundles.end(); - ++iter) + for (auto iter = g_remoteChannelBundles.begin(); iter != g_remoteChannelBundles.end(); ++iter) { Ptr bundle = iter->second; bundle->Send(bundle->GetDelay()); @@ -98,9 +95,7 @@ RemoteChannelBundleManager::GetSafeTime() Time safeTime = Simulator::GetMaximumSimulationTime(); - for (RemoteChannelMap::const_iterator kv = g_remoteChannelBundles.begin(); - kv != g_remoteChannelBundles.end(); - ++kv) + for (auto kv = g_remoteChannelBundles.begin(); kv != g_remoteChannelBundles.end(); ++kv) { safeTime = Min(safeTime, kv->second->GetGuaranteeTime()); } diff --git a/src/netanim/examples/uan-animation.cc b/src/netanim/examples/uan-animation.cc index 7cffc498c..a4f332ba2 100644 --- a/src/netanim/examples/uan-animation.cc +++ b/src/netanim/examples/uan-animation.cc @@ -98,7 +98,7 @@ void NetAnimExperiment::UpdatePositions(NodeContainer& nodes) const { NS_LOG_DEBUG(Simulator::Now().As(Time::S) << " Updating positions"); - NodeContainer::Iterator it = nodes.Begin(); + auto it = nodes.Begin(); Ptr uv = CreateObject(); uv->SetAttribute("Min", DoubleValue(0.0)); uv->SetAttribute("Max", DoubleValue(m_boundary)); diff --git a/src/netanim/model/animation-interface.cc b/src/netanim/model/animation-interface.cc index ff62e334a..c5d06908c 100644 --- a/src/netanim/model/animation-interface.cc +++ b/src/netanim/model/animation-interface.cc @@ -135,7 +135,7 @@ AnimationInterface::EnableWifiPhyCounters(Time startTime, Time stopTime, Time po m_wifiPhyCountersPollInterval = pollInterval; m_wifiPhyTxDropCounterId = AddNodeCounter("WifiPhy TxDrop", AnimationInterface::DOUBLE_COUNTER); m_wifiPhyRxDropCounterId = AddNodeCounter("WifiPhy RxDrop", AnimationInterface::DOUBLE_COUNTER); - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; m_nodeWifiPhyTxDrop[n->GetId()] = 0; @@ -155,7 +155,7 @@ AnimationInterface::EnableWifiMacCounters(Time startTime, Time stopTime, Time po m_wifiMacTxDropCounterId = AddNodeCounter("WifiMac TxDrop", AnimationInterface::DOUBLE_COUNTER); m_wifiMacRxCounterId = AddNodeCounter("WifiMac Rx", AnimationInterface::DOUBLE_COUNTER); m_wifiMacRxDropCounterId = AddNodeCounter("WifiMac RxDrop", AnimationInterface::DOUBLE_COUNTER); - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; m_nodeWifiMacTx[n->GetId()] = 0; @@ -178,7 +178,7 @@ AnimationInterface::EnableQueueCounters(Time startTime, Time stopTime, Time poll m_queueEnqueueCounterId = AddNodeCounter("Enqueue", AnimationInterface::DOUBLE_COUNTER); m_queueDequeueCounterId = AddNodeCounter("Dequeue", AnimationInterface::DOUBLE_COUNTER); m_queueDropCounterId = AddNodeCounter("Queue Drop", AnimationInterface::DOUBLE_COUNTER); - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; m_nodeQueueEnqueue[n->GetId()] = 0; @@ -199,7 +199,7 @@ AnimationInterface::EnableIpv4L3ProtocolCounters(Time startTime, Time stopTime, m_ipv4L3ProtocolTxCounterId = AddNodeCounter("Ipv4 Tx", AnimationInterface::DOUBLE_COUNTER); m_ipv4L3ProtocolRxCounterId = AddNodeCounter("Ipv4 Rx", AnimationInterface::DOUBLE_COUNTER); m_ipv4L3ProtocolDropCounterId = AddNodeCounter("Ipv4 Drop", AnimationInterface::DOUBLE_COUNTER); - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; m_nodeIpv4Tx[n->GetId()] = 0; @@ -440,7 +440,7 @@ AnimationInterface::UpdateNodeDescription(uint32_t nodeId, std::string descr) double AnimationInterface::GetNodeEnergyFraction(Ptr node) const { - const EnergyFractionMap::const_iterator fractionIter = m_nodeEnergyFraction.find(node->GetId()); + const auto fractionIter = m_nodeEnergyFraction.find(node->GetId()); NS_ASSERT(fractionIter != m_nodeEnergyFraction.end()); return fractionIter->second; } @@ -500,7 +500,7 @@ std::vector> AnimationInterface::GetMovedNodes() { std::vector> movedNodes; - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; NS_ASSERT(n); @@ -573,9 +573,8 @@ AnimationInterface::WriteRoutePath(uint32_t nodeId, { NS_LOG_INFO("Writing Route Path From :" << nodeId << " To: " << destination); WriteXmlRp(nodeId, destination, rpElements); - /*for (Ipv4RoutePathElements::const_iterator i = rpElements.begin (); - i != rpElements.end (); - ++i) + /* + for (auto i = rpElements.begin (); i != rpElements.end (); ++i) { Ipv4RoutePathElement rpElement = *i; NS_LOG_INFO ("Node:" << rpElement.nodeId << "-->" << rpElement.nextHop.c_str ()); @@ -1124,7 +1123,7 @@ AnimationInterface::LteSpectrumPhyTxStart(std::string context, Ptr> pbList = pb->GetPackets(); - for (std::list>::iterator i = pbList.begin(); i != pbList.end(); ++i) + for (auto i = pbList.begin(); i != pbList.end(); ++i) { Ptr p = *i; ++gAnimUid; @@ -1152,7 +1151,7 @@ AnimationInterface::LteSpectrumPhyRxStart(std::string context, Ptr> pbList = pb->GetPackets(); - for (std::list>::iterator i = pbList.begin(); i != pbList.end(); ++i) + for (auto i = pbList.begin(); i != pbList.end(); ++i) { Ptr p = *i; uint64_t animUid = GetAnimUidFromPacket(p); @@ -1325,8 +1324,7 @@ AnimationInterface::PurgePendingPackets(AnimationInterface::ProtocolType protoco return; } std::vector purgeList; - for (AnimUidPacketInfoMap::iterator i = pendingPackets->begin(); i != pendingPackets->end(); - ++i) + for (auto i = pendingPackets->begin(); i != pendingPackets->end(); ++i) { AnimPacketInfo pktInfo = i->second; double delta = (Simulator::Now().GetSeconds() - pktInfo.m_fbTx); @@ -1335,7 +1333,7 @@ AnimationInterface::PurgePendingPackets(AnimationInterface::ProtocolType protoco purgeList.push_back(i->first); } } - for (std::vector::iterator i = purgeList.begin(); i != purgeList.end(); ++i) + for (auto i = purgeList.begin(); i != purgeList.end(); ++i) { pendingPackets->erase(*i); } @@ -1502,9 +1500,7 @@ void AnimationInterface::AddToIpv4AddressNodeIdTable(std::vector ipv4Addresses, uint32_t nodeId) { - for (std::vector::const_iterator i = ipv4Addresses.begin(); - i != ipv4Addresses.end(); - ++i) + for (auto i = ipv4Addresses.begin(); i != ipv4Addresses.end(); ++i) { AddToIpv4AddressNodeIdTable(*i, nodeId); } @@ -1521,9 +1517,7 @@ void AnimationInterface::AddToIpv6AddressNodeIdTable(std::vector ipv6Addresses, uint32_t nodeId) { - for (std::vector::const_iterator i = ipv6Addresses.begin(); - i != ipv6Addresses.end(); - ++i) + for (auto i = ipv6Addresses.begin(); i != ipv6Addresses.end(); ++i) { AddToIpv6AddressNodeIdTable(*i, nodeId); } @@ -1591,7 +1585,7 @@ AnimationInterface::ConnectLteUe(Ptr n, Ptr nd, uint32_t d void AnimationInterface::ConnectLte() { - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; NS_ASSERT(n); @@ -1892,12 +1886,11 @@ AnimationInterface::GetIpv6Addresses(Ptr nd) void AnimationInterface::WriteIpv4Addresses() { - for (NodeIdIpv4Map::const_iterator i = m_nodeIdIpv4Map.begin(); i != m_nodeIdIpv4Map.end(); ++i) + for (auto i = m_nodeIdIpv4Map.begin(); i != m_nodeIdIpv4Map.end(); ++i) { std::vector ipv4Addresses; - std::pair iterPair = - m_nodeIdIpv4Map.equal_range(i->first); - for (NodeIdIpv4Map::const_iterator it = iterPair.first; it != iterPair.second; ++it) + auto iterPair = m_nodeIdIpv4Map.equal_range(i->first); + for (auto it = iterPair.first; it != iterPair.second; ++it) { ipv4Addresses.push_back(it->second); } @@ -1908,13 +1901,12 @@ AnimationInterface::WriteIpv4Addresses() void AnimationInterface::WriteIpv6Addresses() { - for (NodeIdIpv6Map::const_iterator i = m_nodeIdIpv6Map.begin(); i != m_nodeIdIpv6Map.end(); + for (auto i = m_nodeIdIpv6Map.begin(); i != m_nodeIdIpv6Map.end(); i = m_nodeIdIpv6Map.upper_bound(i->first)) { std::vector ipv6Addresses; - std::pair iterPair = - m_nodeIdIpv6Map.equal_range(i->first); - for (NodeIdIpv6Map::const_iterator it = iterPair.first; it != iterPair.second; ++it) + auto iterPair = m_nodeIdIpv6Map.equal_range(i->first); + for (auto it = iterPair.first; it != iterPair.second; ++it) { ipv6Addresses.push_back(it->second); } @@ -1925,7 +1917,7 @@ AnimationInterface::WriteIpv6Addresses() void AnimationInterface::WriteLinkProperties() { - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; UpdatePosition(n); @@ -2026,7 +2018,7 @@ AnimationInterface::WriteLinkProperties() void AnimationInterface::WriteNodes() { - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; NS_LOG_INFO("Update Position for Node: " << n->GetId()); @@ -2038,7 +2030,7 @@ AnimationInterface::WriteNodes() void AnimationInterface::WriteNodeColors() { - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; Rgb rgb = {255, 0, 0}; @@ -2053,7 +2045,7 @@ AnimationInterface::WriteNodeColors() void AnimationInterface::WriteNodeSizes() { - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; NS_LOG_INFO("Update Size for Node: " << n->GetId()); @@ -2068,7 +2060,7 @@ AnimationInterface::WriteNodeEnergies() { m_remainingEnergyCounterId = AddNodeCounter("RemainingEnergy", AnimationInterface::DOUBLE_COUNTER); - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; if (NodeList::GetNode(n->GetId())->GetObject()) @@ -2144,7 +2136,7 @@ AnimationInterface::TrackQueueCounters() NS_LOG_INFO("TrackQueueCounters Completed"); return; } - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { uint32_t nodeId = Ptr(*i)->GetId(); UpdateNodeCounter(m_queueEnqueueCounterId, nodeId, m_nodeQueueEnqueue[nodeId]); @@ -2162,7 +2154,7 @@ AnimationInterface::TrackWifiMacCounters() NS_LOG_INFO("TrackWifiMacCounters Completed"); return; } - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { uint32_t nodeId = Ptr(*i)->GetId(); UpdateNodeCounter(m_wifiMacTxCounterId, nodeId, m_nodeWifiMacTx[nodeId]); @@ -2183,7 +2175,7 @@ AnimationInterface::TrackWifiPhyCounters() NS_LOG_INFO("TrackWifiPhyCounters Completed"); return; } - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { uint32_t nodeId = Ptr(*i)->GetId(); UpdateNodeCounter(m_wifiPhyTxDropCounterId, nodeId, m_nodeWifiPhyTxDrop[nodeId]); @@ -2202,7 +2194,7 @@ AnimationInterface::TrackIpv4L3ProtocolCounters() NS_LOG_INFO("TrackIpv4L3ProtocolCounters Completed"); return; } - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { uint32_t nodeId = Ptr(*i)->GetId(); UpdateNodeCounter(m_ipv4L3ProtocolTxCounterId, nodeId, m_nodeIpv4Tx[nodeId]); @@ -2223,9 +2215,7 @@ AnimationInterface::TrackIpv4RoutePaths() { return; } - for (std::vector::const_iterator i = m_ipv4RouteTrackElements.begin(); - i != m_ipv4RouteTrackElements.end(); - ++i) + for (auto i = m_ipv4RouteTrackElements.begin(); i != m_ipv4RouteTrackElements.end(); ++i) { Ipv4RouteTrackElement trackElement = *i; Ptr fromNode = NodeList::GetNode(trackElement.fromNodeId); @@ -2300,7 +2290,7 @@ AnimationInterface::TrackIpv4Route() } if (m_routingNc.GetN()) { - for (NodeContainer::Iterator i = m_routingNc.Begin(); i != m_routingNc.End(); ++i) + for (auto i = m_routingNc.Begin(); i != m_routingNc.End(); ++i) { Ptr n = *i; WriteXmlRouting(n->GetId(), GetIpv4RoutingTable(n)); @@ -2308,7 +2298,7 @@ AnimationInterface::TrackIpv4Route() } else { - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { Ptr n = *i; WriteXmlRouting(n->GetId(), GetIpv4RoutingTable(n)); @@ -2495,9 +2485,7 @@ AnimationInterface::WriteXmlIpv4Addresses(uint32_t nodeId, std::vector::const_iterator i = ipv4Addresses.begin(); - i != ipv4Addresses.end(); - ++i) + for (auto i = ipv4Addresses.begin(); i != ipv4Addresses.end(); ++i) { AnimXmlElement valueElement("address"); valueElement.SetText(*i); @@ -2511,9 +2499,7 @@ AnimationInterface::WriteXmlIpv6Addresses(uint32_t nodeId, std::vector::const_iterator i = ipv6Addresses.begin(); - i != ipv6Addresses.end(); - ++i) + for (auto i = ipv6Addresses.begin(); i != ipv6Addresses.end(); ++i) { AnimXmlElement valueElement("address"); valueElement.SetText(*i); @@ -2543,7 +2529,7 @@ AnimationInterface::WriteXmlRp(uint32_t nodeId, element.AddAttribute("id", nodeId); element.AddAttribute("d", destination.c_str()); element.AddAttribute("c", rpElements.size()); - for (Ipv4RoutePathElements::const_iterator i = rpElements.begin(); i != rpElements.end(); ++i) + for (auto i = rpElements.begin(); i != rpElements.end(); ++i) { Ipv4RoutePathElement rpElement = *i; AnimXmlElement rpeElement("rpe"); @@ -2753,7 +2739,7 @@ AnimationInterface::AnimXmlElement::AddAttribute(std::string attribute, T value, { attributeString += "=\""; std::string valueStr = oss.str(); - for (std::string::iterator it = valueStr.begin(); it != valueStr.end(); ++it) + for (auto it = valueStr.begin(); it != valueStr.end(); ++it) { switch (*it) { @@ -2803,8 +2789,7 @@ AnimationInterface::AnimXmlElement::ToString(bool autoClose) { std::string elementString = "<" + m_tagName + " "; - for (std::vector::const_iterator i = m_attributes.begin(); i != m_attributes.end(); - ++i) + for (auto i = m_attributes.begin(); i != m_attributes.end(); ++i) { elementString += *i; } @@ -2825,9 +2810,7 @@ AnimationInterface::AnimXmlElement::ToString(bool autoClose) if (!m_children.empty()) { elementString += "\n"; - for (std::vector::const_iterator i = m_children.begin(); - i != m_children.end(); - ++i) + for (auto i = m_children.begin(); i != m_children.end(); ++i) { elementString += *i + "\n"; } diff --git a/src/network/helper/application-container.cc b/src/network/helper/application-container.cc index 16eb51088..13affd00a 100644 --- a/src/network/helper/application-container.cc +++ b/src/network/helper/application-container.cc @@ -69,7 +69,7 @@ ApplicationContainer::Get(uint32_t i) const void ApplicationContainer::Add(ApplicationContainer other) { - for (Iterator i = other.Begin(); i != other.End(); i++) + for (auto i = other.Begin(); i != other.End(); i++) { m_applications.push_back(*i); } @@ -91,7 +91,7 @@ ApplicationContainer::Add(std::string name) void ApplicationContainer::Start(Time start) const { - for (Iterator i = Begin(); i != End(); ++i) + for (auto i = Begin(); i != End(); ++i) { Ptr app = *i; app->SetStartTime(start); @@ -101,7 +101,7 @@ ApplicationContainer::Start(Time start) const void ApplicationContainer::StartWithJitter(Time start, Ptr rv) const { - for (Iterator i = Begin(); i != End(); ++i) + for (auto i = Begin(); i != End(); ++i) { Ptr app = *i; double value = rv->GetValue(); @@ -113,7 +113,7 @@ ApplicationContainer::StartWithJitter(Time start, Ptr rv) void ApplicationContainer::Stop(Time stop) const { - for (Iterator i = Begin(); i != End(); ++i) + for (auto i = Begin(); i != End(); ++i) { Ptr app = *i; app->SetStopTime(stop); diff --git a/src/network/helper/net-device-container.cc b/src/network/helper/net-device-container.cc index 9d93f13eb..893d6fbd7 100644 --- a/src/network/helper/net-device-container.cc +++ b/src/network/helper/net-device-container.cc @@ -72,7 +72,7 @@ NetDeviceContainer::Get(uint32_t i) const void NetDeviceContainer::Add(NetDeviceContainer other) { - for (Iterator i = other.Begin(); i != other.End(); i++) + for (auto i = other.Begin(); i != other.End(); i++) { m_devices.push_back(*i); } diff --git a/src/network/helper/node-container.cc b/src/network/helper/node-container.cc index 2a00ae670..5669b8b84 100644 --- a/src/network/helper/node-container.cc +++ b/src/network/helper/node-container.cc @@ -28,7 +28,7 @@ NodeContainer NodeContainer::GetGlobal() { NodeContainer c; - for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) + for (auto i = NodeList::Begin(); i != NodeList::End(); ++i) { c.Add(*i); } @@ -101,7 +101,7 @@ NodeContainer::Create(uint32_t n, uint32_t systemId) void NodeContainer::Add(const NodeContainer& nc) { - for (Iterator i = nc.Begin(); i != nc.End(); i++) + for (auto i = nc.Begin(); i != nc.End(); i++) { m_nodes.push_back(*i); } diff --git a/src/network/helper/packet-socket-helper.cc b/src/network/helper/packet-socket-helper.cc index d417c1ae5..4869e8a68 100644 --- a/src/network/helper/packet-socket-helper.cc +++ b/src/network/helper/packet-socket-helper.cc @@ -28,7 +28,7 @@ namespace ns3 void PacketSocketHelper::Install(NodeContainer c) const { - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Install(*i); } diff --git a/src/network/helper/simple-net-device-helper.cc b/src/network/helper/simple-net-device-helper.cc index 90deaf158..846ed0c5e 100644 --- a/src/network/helper/simple-net-device-helper.cc +++ b/src/network/helper/simple-net-device-helper.cc @@ -99,7 +99,7 @@ SimpleNetDeviceHelper::Install(const NodeContainer& c, Ptr channe { NetDeviceContainer devs; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { devs.Add(InstallPriv(*i, channel)); } diff --git a/src/network/helper/trace-helper.cc b/src/network/helper/trace-helper.cc index f2192fc25..6df8cae70 100644 --- a/src/network/helper/trace-helper.cc +++ b/src/network/helper/trace-helper.cc @@ -438,7 +438,7 @@ PcapHelperForDevice::EnablePcap(std::string prefix, void PcapHelperForDevice::EnablePcap(std::string prefix, NetDeviceContainer d, bool promiscuous) { - for (NetDeviceContainer::Iterator i = d.Begin(); i != d.End(); ++i) + for (auto i = d.Begin(); i != d.End(); ++i) { Ptr dev = *i; EnablePcap(prefix, dev, promiscuous); @@ -449,7 +449,7 @@ void PcapHelperForDevice::EnablePcap(std::string prefix, NodeContainer n, bool promiscuous) { NetDeviceContainer devs; - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; for (uint32_t j = 0; j < node->GetNDevices(); ++j) @@ -474,7 +474,7 @@ PcapHelperForDevice::EnablePcap(std::string prefix, { NodeContainer n = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; if (node->GetId() != nodeid) @@ -567,7 +567,7 @@ AsciiTraceHelperForDevice::EnableAsciiImpl(Ptr stream, std::string prefix, NetDeviceContainer d) { - for (NetDeviceContainer::Iterator i = d.Begin(); i != d.End(); ++i) + for (auto i = d.Begin(); i != d.End(); ++i) { Ptr dev = *i; EnableAsciiInternal(stream, prefix, dev, false); @@ -601,7 +601,7 @@ AsciiTraceHelperForDevice::EnableAsciiImpl(Ptr stream, NodeContainer n) { NetDeviceContainer devs; - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; for (uint32_t j = 0; j < node->GetNDevices(); ++j) @@ -665,7 +665,7 @@ AsciiTraceHelperForDevice::EnableAsciiImpl(Ptr stream, { NodeContainer n = NodeContainer::GetGlobal(); - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; if (node->GetId() != nodeid) diff --git a/src/network/model/buffer.cc b/src/network/model/buffer.cc index 4a0a28cdf..28e591fa2 100644 --- a/src/network/model/buffer.cc +++ b/src/network/model/buffer.cc @@ -88,7 +88,7 @@ Buffer::LocalStaticDestructor::~LocalStaticDestructor() NS_LOG_FUNCTION(this); if (IS_INITIALIZED(g_freeList)) { - for (Buffer::FreeList::iterator i = g_freeList->begin(); i != g_freeList->end(); i++) + for (auto i = g_freeList->begin(); i != g_freeList->end(); i++) { Buffer::Deallocate(*i); } @@ -173,8 +173,8 @@ Buffer::Allocate(uint32_t reqSize) NS_ASSERT(reqSize >= 1); reqSize += ALLOC_OVER_PROVISION; uint32_t size = reqSize - 1 + sizeof(Buffer::Data); - uint8_t* b = new uint8_t[size]; - Buffer::Data* data = reinterpret_cast(b); + auto b = new uint8_t[size]; + auto data = reinterpret_cast(b); data->m_size = reqSize; data->m_count = 1; return data; @@ -185,7 +185,7 @@ Buffer::Deallocate(Buffer::Data* data) { NS_LOG_FUNCTION(data); NS_ASSERT(data->m_count == 0); - uint8_t* buf = reinterpret_cast(data); + auto buf = reinterpret_cast(data); delete[] buf; } @@ -582,7 +582,7 @@ uint32_t Buffer::Serialize(uint8_t* buffer, uint32_t maxSize) const { NS_LOG_FUNCTION(this << &buffer << maxSize); - uint32_t* p = reinterpret_cast(buffer); + auto p = reinterpret_cast(buffer); uint32_t size = 0; // Add the zero data length @@ -654,7 +654,7 @@ uint32_t Buffer::Deserialize(const uint8_t* buffer, uint32_t size) { NS_LOG_FUNCTION(this << &buffer << size); - const uint32_t* p = reinterpret_cast(buffer); + auto p = reinterpret_cast(buffer); uint32_t sizeCheck = size - 4; NS_ASSERT(sizeCheck >= 4); diff --git a/src/network/model/byte-tag-list.cc b/src/network/model/byte-tag-list.cc index 665c177da..412728244 100644 --- a/src/network/model/byte-tag-list.cc +++ b/src/network/model/byte-tag-list.cc @@ -67,9 +67,9 @@ static uint32_t g_maxSize = 0; //!< maximum data size (used for allocation) ByteTagListDataFreeList::~ByteTagListDataFreeList() { NS_LOG_FUNCTION(this); - for (ByteTagListDataFreeList::iterator i = begin(); i != end(); i++) + for (auto i = begin(); i != end(); i++) { - uint8_t* buffer = (uint8_t*)(*i); + auto buffer = (uint8_t*)(*i); delete[] buffer; } } @@ -366,11 +366,11 @@ ByteTagList::Allocate(uint32_t size) data->dirty = 0; return data; } - uint8_t* buffer = (uint8_t*)data; + auto buffer = (uint8_t*)data; delete[] buffer; } - uint8_t* buffer = new uint8_t[std::max(size, g_maxSize) + sizeof(ByteTagListData) - 4]; - ByteTagListData* data = (ByteTagListData*)buffer; + auto buffer = new uint8_t[std::max(size, g_maxSize) + sizeof(ByteTagListData) - 4]; + auto data = (ByteTagListData*)buffer; data->count = 1; data->size = size; data->dirty = 0; @@ -391,7 +391,7 @@ ByteTagList::Deallocate(ByteTagListData* data) { if (g_freeList.size() > FREE_LIST_SIZE || data->size < g_maxSize) { - uint8_t* buffer = (uint8_t*)data; + auto buffer = (uint8_t*)data; delete[] buffer; } else diff --git a/src/network/model/channel-list.cc b/src/network/model/channel-list.cc index bbfcf9cd1..55e397019 100644 --- a/src/network/model/channel-list.cc +++ b/src/network/model/channel-list.cc @@ -162,7 +162,7 @@ void ChannelListPriv::DoDispose() { NS_LOG_FUNCTION(this); - for (std::vector>::iterator i = m_channels.begin(); i != m_channels.end(); i++) + for (auto i = m_channels.begin(); i != m_channels.end(); i++) { Ptr channel = *i; channel->Dispose(); diff --git a/src/network/model/node-list.cc b/src/network/model/node-list.cc index 2e796df3f..a602a6c43 100644 --- a/src/network/model/node-list.cc +++ b/src/network/model/node-list.cc @@ -165,7 +165,7 @@ void NodeListPriv::DoDispose() { NS_LOG_FUNCTION(this); - for (std::vector>::iterator i = m_nodes.begin(); i != m_nodes.end(); i++) + for (auto i = m_nodes.begin(); i != m_nodes.end(); i++) { Ptr node = *i; node->Dispose(); diff --git a/src/network/model/node.cc b/src/network/model/node.cc index 2b465d8f2..886a175fe 100644 --- a/src/network/model/node.cc +++ b/src/network/model/node.cc @@ -199,16 +199,14 @@ Node::DoDispose() NS_LOG_FUNCTION(this); m_deviceAdditionListeners.clear(); m_handlers.clear(); - for (std::vector>::iterator i = m_devices.begin(); i != m_devices.end(); i++) + for (auto i = m_devices.begin(); i != m_devices.end(); i++) { Ptr device = *i; device->Dispose(); *i = nullptr; } m_devices.clear(); - for (std::vector>::iterator i = m_applications.begin(); - i != m_applications.end(); - i++) + for (auto i = m_applications.begin(); i != m_applications.end(); i++) { Ptr application = *i; application->Dispose(); @@ -222,14 +220,12 @@ void Node::DoInitialize() { NS_LOG_FUNCTION(this); - for (std::vector>::iterator i = m_devices.begin(); i != m_devices.end(); i++) + for (auto i = m_devices.begin(); i != m_devices.end(); i++) { Ptr device = *i; device->Initialize(); } - for (std::vector>::iterator i = m_applications.begin(); - i != m_applications.end(); - i++) + for (auto i = m_applications.begin(); i != m_applications.end(); i++) { Ptr application = *i; application->Initialize(); @@ -256,8 +252,7 @@ Node::RegisterProtocolHandler(ProtocolHandler handler, { if (!device) { - for (std::vector>::iterator i = m_devices.begin(); i != m_devices.end(); - i++) + for (auto i = m_devices.begin(); i != m_devices.end(); i++) { Ptr dev = *i; dev->SetPromiscReceiveCallback(MakeCallback(&Node::PromiscReceiveFromDevice, this)); @@ -276,7 +271,7 @@ void Node::UnregisterProtocolHandler(ProtocolHandler handler) { NS_LOG_FUNCTION(this << &handler); - for (ProtocolHandlerList::iterator i = m_handlers.begin(); i != m_handlers.end(); i++) + for (auto i = m_handlers.begin(); i != m_handlers.end(); i++) { if (i->handler.IsEqual(handler)) { @@ -343,7 +338,7 @@ Node::ReceiveFromDevice(Ptr device, << packet->GetUid()); bool found = false; - for (ProtocolHandlerList::iterator i = m_handlers.begin(); i != m_handlers.end(); i++) + for (auto i = m_handlers.begin(); i != m_handlers.end(); i++) { if (!i->device || (i->device == device)) { @@ -366,8 +361,7 @@ Node::RegisterDeviceAdditionListener(DeviceAdditionListener listener) NS_LOG_FUNCTION(this << &listener); m_deviceAdditionListeners.push_back(listener); // and, then, notify the new listener about all existing devices. - for (std::vector>::const_iterator i = m_devices.begin(); i != m_devices.end(); - ++i) + for (auto i = m_devices.begin(); i != m_devices.end(); ++i) { listener(*i); } @@ -377,9 +371,7 @@ void Node::UnregisterDeviceAdditionListener(DeviceAdditionListener listener) { NS_LOG_FUNCTION(this << &listener); - for (DeviceAdditionListenerList::iterator i = m_deviceAdditionListeners.begin(); - i != m_deviceAdditionListeners.end(); - i++) + for (auto i = m_deviceAdditionListeners.begin(); i != m_deviceAdditionListeners.end(); i++) { if ((*i).IsEqual(listener)) { @@ -393,9 +385,7 @@ void Node::NotifyDeviceAdded(Ptr device) { NS_LOG_FUNCTION(this << device); - for (DeviceAdditionListenerList::iterator i = m_deviceAdditionListeners.begin(); - i != m_deviceAdditionListeners.end(); - i++) + for (auto i = m_deviceAdditionListeners.begin(); i != m_deviceAdditionListeners.end(); i++) { (*i)(device); } diff --git a/src/network/model/packet-metadata.cc b/src/network/model/packet-metadata.cc index eb0e96756..b3b0088cc 100644 --- a/src/network/model/packet-metadata.cc +++ b/src/network/model/packet-metadata.cc @@ -44,7 +44,7 @@ PacketMetadata::DataFreeList PacketMetadata::m_freeList; PacketMetadata::DataFreeList::~DataFreeList() { NS_LOG_FUNCTION(this); - for (iterator i = begin(); i != end(); i++) + for (auto i = begin(); i != end(); i++) { PacketMetadata::Deallocate(*i); } @@ -620,8 +620,8 @@ PacketMetadata::Allocate(uint32_t n) n = PACKET_METADATA_DATA_M_DATA_SIZE; } size += n - PACKET_METADATA_DATA_M_DATA_SIZE; - uint8_t* buf = new uint8_t[size]; - PacketMetadata::Data* data = (PacketMetadata::Data*)buf; + auto buf = new uint8_t[size]; + auto data = (PacketMetadata::Data*)buf; data->m_size = n; data->m_count = 1; data->m_dirtyEnd = 0; @@ -632,7 +632,7 @@ void PacketMetadata::Deallocate(PacketMetadata::Data* data) { NS_LOG_FUNCTION(data); - uint8_t* buf = (uint8_t*)data; + auto buf = (uint8_t*)data; delete[] buf; } diff --git a/src/network/model/packet-tag-list.cc b/src/network/model/packet-tag-list.cc index 5db21d72a..3a960df77 100644 --- a/src/network/model/packet-tag-list.cc +++ b/src/network/model/packet-tag-list.cc @@ -47,7 +47,7 @@ PacketTagList::CreateTagData(size_t dataSize) void* p = std::malloc(sizeof(TagData) + dataSize - 1); // The matching frees are in RemoveAll and RemoveWriter - TagData* tag = new (p) TagData; + auto tag = new (p) TagData; tag->size = dataSize; return tag; } diff --git a/src/network/model/packet.cc b/src/network/model/packet.cc index 3b2d37a79..2a1f6d21b 100644 --- a/src/network/model/packet.cc +++ b/src/network/model/packet.cc @@ -490,7 +490,7 @@ Packet::Print(std::ostream& os) const NS_ASSERT(!constructor.IsNull()); ObjectBase* instance = constructor(); NS_ASSERT(instance != nullptr); - Chunk* chunk = dynamic_cast(instance); + auto chunk = dynamic_cast(instance); NS_ASSERT(chunk != nullptr); if (item.type == PacketMetadata::Item::HEADER) { @@ -662,7 +662,7 @@ Packet::GetSerializedSize() const uint32_t Packet::Serialize(uint8_t* buffer, uint32_t maxSize) const { - uint32_t* p = reinterpret_cast(buffer); + auto p = reinterpret_cast(buffer); uint32_t size = 0; // if nix-vector exists, serialize it @@ -825,7 +825,7 @@ Packet::Deserialize(const uint8_t* buffer, uint32_t size) { NS_LOG_FUNCTION(this); - const uint32_t* p = reinterpret_cast(buffer); + auto p = reinterpret_cast(buffer); // read nix-vector NS_ASSERT(!m_nixVector); @@ -934,7 +934,7 @@ void Packet::AddByteTag(const Tag& tag) const { NS_LOG_FUNCTION(this << tag.GetInstanceTypeId().GetName() << tag.GetSerializedSize()); - ByteTagList* list = const_cast(&m_byteTagList); + auto list = const_cast(&m_byteTagList); TagBuffer buffer = list->Add(tag.GetInstanceTypeId(), tag.GetSerializedSize(), 0, GetSize()); tag.Serialize(buffer); } @@ -944,7 +944,7 @@ Packet::AddByteTag(const Tag& tag, uint32_t start, uint32_t end) const { NS_LOG_FUNCTION(this << tag.GetInstanceTypeId().GetName() << tag.GetSerializedSize()); NS_ABORT_MSG_IF(end < start, "Invalid byte range"); - ByteTagList* list = const_cast(&m_byteTagList); + auto list = const_cast(&m_byteTagList); TagBuffer buffer = list->Add(tag.GetInstanceTypeId(), tag.GetSerializedSize(), static_cast(start), diff --git a/src/network/model/tag-buffer.cc b/src/network/model/tag-buffer.cc index 03a7b39c8..2d5ec1690 100644 --- a/src/network/model/tag-buffer.cc +++ b/src/network/model/tag-buffer.cc @@ -118,7 +118,7 @@ void TagBuffer::WriteDouble(double v) { NS_LOG_FUNCTION(this << v); - uint8_t* buf = (uint8_t*)&v; + auto buf = (uint8_t*)&v; for (uint32_t i = 0; i < sizeof(double); ++i, ++buf) { WriteU8(*buf); @@ -171,7 +171,7 @@ TagBuffer::ReadDouble() { NS_LOG_FUNCTION(this); double v; - uint8_t* buf = (uint8_t*)&v; + auto buf = (uint8_t*)&v; for (uint32_t i = 0; i < sizeof(double); ++i, ++buf) { *buf = ReadU8(); diff --git a/src/network/test/buffer-test.cc b/src/network/test/buffer-test.cc index 4f1f81e33..93e201abb 100644 --- a/src/network/test/buffer-test.cc +++ b/src/network/test/buffer-test.cc @@ -363,7 +363,7 @@ BufferTest::DoRun() NS_TEST_ASSERT_MSG_EQ(sizeBuffer, ct.size(), "Buffer bad size"); const uint8_t* evilBuffer = buffer.PeekData(); NS_TEST_ASSERT_MSG_NE(evilBuffer, 0, "Buffer PeekData failed"); - uint8_t* cBuf = (uint8_t*)malloc(sizeBuffer); + auto cBuf = (uint8_t*)malloc(sizeBuffer); uint32_t copyLen = buffer.CopyData(cBuf, sizeBuffer); NS_TEST_ASSERT_MSG_EQ(copyLen, sizeBuffer, "CopyData return bad size"); for (uint32_t i = 0; i < sizeBuffer; i++) diff --git a/src/network/test/packet-metadata-test.cc b/src/network/test/packet-metadata-test.cc index 64b723a08..217b98eae 100644 --- a/src/network/test/packet-metadata-test.cc +++ b/src/network/test/packet-metadata-test.cc @@ -381,7 +381,7 @@ PacketMetadataTest::CheckHistory(Ptr p, uint32_t n, ...) if (item.type == PacketMetadata::Item::HEADER) { Callback constructor = item.tid.GetConstructor(); - HistoryHeaderBase* header = dynamic_cast(constructor()); + auto header = dynamic_cast(constructor()); if (header == nullptr) { goto error; @@ -397,7 +397,7 @@ PacketMetadataTest::CheckHistory(Ptr p, uint32_t n, ...) else if (item.type == PacketMetadata::Item::TRAILER) { Callback constructor = item.tid.GetConstructor(); - HistoryTrailerBase* trailer = dynamic_cast(constructor()); + auto trailer = dynamic_cast(constructor()); if (trailer == nullptr) { goto error; @@ -413,7 +413,7 @@ PacketMetadataTest::CheckHistory(Ptr p, uint32_t n, ...) got.push_back(item.currentSize); } - for (std::list::iterator i = got.begin(), j = expected.begin(); i != got.end(); i++, j++) + for (auto i = got.begin(), j = expected.begin(); i != got.end(); i++, j++) { NS_ASSERT(j != expected.end()); if (*j != *i) @@ -425,12 +425,12 @@ PacketMetadataTest::CheckHistory(Ptr p, uint32_t n, ...) error: std::ostringstream failure; failure << "PacketMetadata error. Got:\""; - for (std::list::iterator i = got.begin(); i != got.end(); i++) + for (auto i = got.begin(); i != got.end(); i++) { failure << *i << ", "; } failure << "\", expected: \""; - for (std::list::iterator j = expected.begin(); j != expected.end(); j++) + for (auto j = expected.begin(); j != expected.end(); j++) { failure << *j << ", "; } @@ -872,7 +872,7 @@ PacketMetadataTest::DoRun() REM_HEADER(p3, 2); CHECK_HISTORY(p3, 1, 11); - uint8_t* buf = new uint8_t[p3->GetSize()]; + auto buf = new uint8_t[p3->GetSize()]; p3->CopyData(buf, p3->GetSize()); std::string msg = std::string(reinterpret_cast(buf), p3->GetSize()); delete[] buf; diff --git a/src/network/test/packet-test-suite.cc b/src/network/test/packet-test-suite.cc index 387f00d8c..a4780e162 100644 --- a/src/network/test/packet-test-suite.cc +++ b/src/network/test/packet-test-suite.cc @@ -632,7 +632,7 @@ PacketTest::DoRun() NS_TEST_EXPECT_MSG_EQ(packet->GetSize(), 11, "trivial"); - uint8_t* buf = new uint8_t[packet->GetSize()]; + auto buf = new uint8_t[packet->GetSize()]; packet->CopyData(buf, packet->GetSize()); std::string msg = std::string(reinterpret_cast(buf), packet->GetSize()); @@ -811,7 +811,7 @@ PacketTest::DoRun() p1->AddPacketTag(c1); uint32_t serializedSize = p1->GetSerializedSize(); - uint8_t* buffer = new uint8_t[serializedSize + 16]; + auto buffer = new uint8_t[serializedSize + 16]; p1->Serialize(buffer, serializedSize); Ptr p2 = Create(buffer, serializedSize, true); @@ -846,7 +846,7 @@ PacketTest::DoRun() CHECK(p1, 3, E(10, 0, 1000), E(11, 0, 1000), E(12, 0, 1000)); uint32_t serializedSize = p1->GetSerializedSize(); - uint8_t* buffer = new uint8_t[serializedSize]; + auto buffer = new uint8_t[serializedSize]; p1->Serialize(buffer, serializedSize); Ptr p2 = Create(buffer, serializedSize, true); diff --git a/src/network/utils/error-channel.cc b/src/network/utils/error-channel.cc index 2a6145178..ffe32c3f0 100644 --- a/src/network/utils/error-channel.cc +++ b/src/network/utils/error-channel.cc @@ -87,9 +87,7 @@ ErrorChannel::Send(Ptr p, Ptr sender) { NS_LOG_FUNCTION(p << protocol << to << from << sender); - for (std::vector>::const_iterator i = m_devices.begin(); - i != m_devices.end(); - ++i) + for (auto i = m_devices.begin(); i != m_devices.end(); ++i) { Ptr tmp = *i; if (tmp == sender) diff --git a/src/network/utils/error-model.cc b/src/network/utils/error-model.cc index 11d8d12ab..0a9c48bc1 100644 --- a/src/network/utils/error-model.cc +++ b/src/network/utils/error-model.cc @@ -471,7 +471,7 @@ ListErrorModel::DoCorrupt(Ptr p) return false; } auto uid = p->GetUid(); - for (PacketListCI i = m_packetList.begin(); i != m_packetList.end(); i++) + for (auto i = m_packetList.begin(); i != m_packetList.end(); i++) { if (uid == *i) { @@ -538,7 +538,7 @@ ReceiveListErrorModel::DoCorrupt(Ptr p) return false; } m_timesInvoked += 1; - for (PacketListCI i = m_packetList.begin(); i != m_packetList.end(); i++) + for (auto i = m_packetList.begin(); i != m_packetList.end(); i++) { if (m_timesInvoked - 1 == *i) { diff --git a/src/network/utils/ipv4-address.cc b/src/network/utils/ipv4-address.cc index fd046d80c..32a2855d6 100644 --- a/src/network/utils/ipv4-address.cc +++ b/src/network/utils/ipv4-address.cc @@ -52,7 +52,7 @@ Ipv4Mask::Ipv4Mask(const char* mask) NS_LOG_FUNCTION(this << mask); if (*mask == '/') { - uint32_t plen = static_cast(std::atoi(++mask)); + auto plen = static_cast(std::atoi(++mask)); NS_ASSERT(plen <= 32); if (plen > 0) { @@ -113,7 +113,7 @@ Ipv4Mask Ipv4Mask::GetLoopback() { NS_LOG_FUNCTION_NOARGS(); - static Ipv4Mask loopback = Ipv4Mask("255.0.0.0"); + static Ipv4Mask loopback("255.0.0.0"); return loopback; } @@ -121,7 +121,7 @@ Ipv4Mask Ipv4Mask::GetZero() { NS_LOG_FUNCTION_NOARGS(); - static Ipv4Mask zero = Ipv4Mask("0.0.0.0"); + static Ipv4Mask zero("0.0.0.0"); return zero; } @@ -129,7 +129,7 @@ Ipv4Mask Ipv4Mask::GetOnes() { NS_LOG_FUNCTION_NOARGS(); - static Ipv4Mask ones = Ipv4Mask("255.255.255.255"); + static Ipv4Mask ones("255.255.255.255"); return ones; } diff --git a/src/network/utils/mac16-address.cc b/src/network/utils/mac16-address.cc index cc2c3c6e0..fcb8472e0 100644 --- a/src/network/utils/mac16-address.cc +++ b/src/network/utils/mac16-address.cc @@ -201,7 +201,7 @@ Mac16Address::GetBroadcast() { NS_LOG_FUNCTION_NOARGS(); - static Mac16Address broadcast = Mac16Address("ff:ff"); + static Mac16Address broadcast("ff:ff"); return broadcast; } diff --git a/src/network/utils/mac48-address.cc b/src/network/utils/mac48-address.cc index a292922e2..924e77ea2 100644 --- a/src/network/utils/mac48-address.cc +++ b/src/network/utils/mac48-address.cc @@ -201,7 +201,7 @@ Mac48Address Mac48Address::GetBroadcast() { NS_LOG_FUNCTION_NOARGS(); - static Mac48Address broadcast = Mac48Address("ff:ff:ff:ff:ff:ff"); + static Mac48Address broadcast("ff:ff:ff:ff:ff:ff"); return broadcast; } @@ -209,7 +209,7 @@ Mac48Address Mac48Address::GetMulticastPrefix() { NS_LOG_FUNCTION_NOARGS(); - static Mac48Address multicast = Mac48Address("01:00:5e:00:00:00"); + static Mac48Address multicast("01:00:5e:00:00:00"); return multicast; } @@ -217,7 +217,7 @@ Mac48Address Mac48Address::GetMulticast6Prefix() { NS_LOG_FUNCTION_NOARGS(); - static Mac48Address multicast = Mac48Address("33:33:00:00:00:00"); + static Mac48Address multicast("33:33:00:00:00:00"); return multicast; } diff --git a/src/network/utils/output-stream-wrapper.cc b/src/network/utils/output-stream-wrapper.cc index 4fb7d9f49..ef509d707 100644 --- a/src/network/utils/output-stream-wrapper.cc +++ b/src/network/utils/output-stream-wrapper.cc @@ -32,7 +32,7 @@ OutputStreamWrapper::OutputStreamWrapper(std::string filename, std::ios::openmod : m_destroyable(true) { NS_LOG_FUNCTION(this << filename << filemode); - std::ofstream* os = new std::ofstream(); + auto os = new std::ofstream(); os->open(filename, filemode); m_ostream = os; FatalImpl::RegisterStream(m_ostream); diff --git a/src/network/utils/packet-burst.cc b/src/network/utils/packet-burst.cc index 675f2929e..9c1bff671 100644 --- a/src/network/utils/packet-burst.cc +++ b/src/network/utils/packet-burst.cc @@ -50,8 +50,7 @@ PacketBurst::PacketBurst() PacketBurst::~PacketBurst() { NS_LOG_FUNCTION(this); - for (std::list>::const_iterator iter = m_packets.begin(); iter != m_packets.end(); - ++iter) + for (auto iter = m_packets.begin(); iter != m_packets.end(); ++iter) { (*iter)->Unref(); } @@ -70,8 +69,7 @@ PacketBurst::Copy() const NS_LOG_FUNCTION(this); Ptr burst = Create(); - for (std::list>::const_iterator iter = m_packets.begin(); iter != m_packets.end(); - ++iter) + for (auto iter = m_packets.begin(); iter != m_packets.end(); ++iter) { Ptr packet = (*iter)->Copy(); burst->AddPacket(packet); @@ -108,8 +106,7 @@ PacketBurst::GetSize() const { NS_LOG_FUNCTION(this); uint32_t size = 0; - for (std::list>::const_iterator iter = m_packets.begin(); iter != m_packets.end(); - ++iter) + for (auto iter = m_packets.begin(); iter != m_packets.end(); ++iter) { Ptr packet = *iter; size += packet->GetSize(); diff --git a/src/network/utils/packet-socket.cc b/src/network/utils/packet-socket.cc index 690efe12a..12c03dc08 100644 --- a/src/network/utils/packet-socket.cc +++ b/src/network/utils/packet-socket.cc @@ -659,7 +659,7 @@ void DeviceNameTag::Serialize(TagBuffer i) const { const char* n = m_deviceName.c_str(); - uint8_t l = (uint8_t)m_deviceName.size(); + auto l = (uint8_t)m_deviceName.size(); i.WriteU8(l); i.Write((uint8_t*)n, (uint32_t)l); diff --git a/src/network/utils/packetbb.cc b/src/network/utils/packetbb.cc index 2a2f14945..f820d7d70 100644 --- a/src/network/utils/packetbb.cc +++ b/src/network/utils/packetbb.cc @@ -182,7 +182,7 @@ void PbbTlvBlock::Clear() { NS_LOG_FUNCTION(this); - for (Iterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { *iter = nullptr; } @@ -195,7 +195,7 @@ PbbTlvBlock::GetSerializedSize() const NS_LOG_FUNCTION(this); /* tlv size */ uint32_t size = 2; - for (ConstIterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { size += (*iter)->GetSerializedSize(); } @@ -216,7 +216,7 @@ PbbTlvBlock::Serialize(Buffer::Iterator& start) const * position. */ Buffer::Iterator tlvsize = start; start.Next(2); - for (ConstIterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { (*iter)->Serialize(start); } @@ -264,7 +264,7 @@ PbbTlvBlock::Print(std::ostream& os, int level) const os << prefix << "\tsize = " << Size() << std::endl; os << prefix << "\tmembers [" << std::endl; - for (ConstIterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { (*iter)->Print(os, level + 2); } @@ -421,7 +421,7 @@ void PbbAddressTlvBlock::Clear() { NS_LOG_FUNCTION(this); - for (Iterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { *iter = nullptr; } @@ -434,7 +434,7 @@ PbbAddressTlvBlock::GetSerializedSize() const NS_LOG_FUNCTION(this); /* tlv size */ uint32_t size = 2; - for (ConstIterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { size += (*iter)->GetSerializedSize(); } @@ -455,7 +455,7 @@ PbbAddressTlvBlock::Serialize(Buffer::Iterator& start) const * position. */ Buffer::Iterator tlvsize = start; start.Next(2); - for (ConstIterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { (*iter)->Serialize(start); } @@ -503,7 +503,7 @@ PbbAddressTlvBlock::Print(std::ostream& os, int level) const os << prefix << "\tsize = " << Size() << std::endl; os << prefix << "\tmembers [" << std::endl; - for (ConstIterator iter = Begin(); iter != End(); iter++) + for (auto iter = Begin(); iter != End(); iter++) { (*iter)->Print(os, level + 2); } @@ -822,7 +822,7 @@ void PbbPacket::MessageClear() { NS_LOG_FUNCTION(this); - for (MessageIterator iter = MessageBegin(); iter != MessageEnd(); iter++) + for (auto iter = MessageBegin(); iter != MessageEnd(); iter++) { *iter = nullptr; } @@ -862,7 +862,7 @@ PbbPacket::GetSerializedSize() const size += m_tlvList.GetSerializedSize(); } - for (ConstMessageIterator iter = MessageBegin(); iter != MessageEnd(); iter++) + for (auto iter = MessageBegin(); iter != MessageEnd(); iter++) { size += (*iter)->GetSerializedSize(); } @@ -897,7 +897,7 @@ PbbPacket::Serialize(Buffer::Iterator start) const bufref.WriteU8(flags); - for (ConstMessageIterator iter = MessageBegin(); iter != MessageEnd(); iter++) + for (auto iter = MessageBegin(); iter != MessageEnd(); iter++) { (*iter)->Serialize(start); } @@ -952,7 +952,7 @@ PbbPacket::Print(std::ostream& os) const m_tlvList.Print(os, 1); - for (ConstMessageIterator iter = MessageBegin(); iter != MessageEnd(); iter++) + for (auto iter = MessageBegin(); iter != MessageEnd(); iter++) { (*iter)->Print(os, 1); } @@ -1383,7 +1383,7 @@ void PbbMessage::AddressBlockClear() { NS_LOG_FUNCTION(this); - for (AddressBlockIterator iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) + for (auto iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) { *iter = nullptr; } @@ -1419,7 +1419,7 @@ PbbMessage::GetSerializedSize() const size += m_tlvList.GetSerializedSize(); - for (ConstAddressBlockIterator iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) + for (auto iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) { size += (*iter)->GetSerializedSize(); } @@ -1474,7 +1474,7 @@ PbbMessage::Serialize(Buffer::Iterator& start) const m_tlvList.Serialize(start); - for (ConstAddressBlockIterator iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) + for (auto iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) { (*iter)->Serialize(start); } @@ -1602,7 +1602,7 @@ PbbMessage::Print(std::ostream& os, int level) const m_tlvList.Print(os, level + 1); - for (ConstAddressBlockIterator iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) + for (auto iter = AddressBlockBegin(); iter != AddressBlockEnd(); iter++) { (*iter)->Print(os, level + 1); } @@ -1722,7 +1722,7 @@ void PbbMessageIpv4::SerializeOriginatorAddress(Buffer::Iterator& start) const { NS_LOG_FUNCTION(this << &start); - uint8_t* buffer = new uint8_t[GetAddressLength() + 1]; + auto buffer = new uint8_t[GetAddressLength() + 1]; Ipv4Address::ConvertFrom(GetOriginatorAddress()).Serialize(buffer); start.Write(buffer, GetAddressLength() + 1); delete[] buffer; @@ -1732,7 +1732,7 @@ Address PbbMessageIpv4::DeserializeOriginatorAddress(Buffer::Iterator& start) const { NS_LOG_FUNCTION(this << &start); - uint8_t* buffer = new uint8_t[GetAddressLength() + 1]; + auto buffer = new uint8_t[GetAddressLength() + 1]; start.Read(buffer, GetAddressLength() + 1); Address result = Ipv4Address::Deserialize(buffer); delete[] buffer; @@ -1773,7 +1773,7 @@ void PbbMessageIpv6::SerializeOriginatorAddress(Buffer::Iterator& start) const { NS_LOG_FUNCTION(this << &start); - uint8_t* buffer = new uint8_t[GetAddressLength() + 1]; + auto buffer = new uint8_t[GetAddressLength() + 1]; Ipv6Address::ConvertFrom(GetOriginatorAddress()).Serialize(buffer); start.Write(buffer, GetAddressLength() + 1); delete[] buffer; @@ -1783,7 +1783,7 @@ Address PbbMessageIpv6::DeserializeOriginatorAddress(Buffer::Iterator& start) const { NS_LOG_FUNCTION(this << &start); - uint8_t* buffer = new uint8_t[GetAddressLength() + 1]; + auto buffer = new uint8_t[GetAddressLength() + 1]; start.Read(buffer, GetAddressLength() + 1); Address res = Ipv6Address::Deserialize(buffer); delete[] buffer; @@ -2175,9 +2175,9 @@ PbbAddressBlock::GetSerializedSize() const } else if (AddressSize() > 0) { - uint8_t* head = new uint8_t[GetAddressLength()]; + auto head = new uint8_t[GetAddressLength()]; uint8_t headlen = 0; - uint8_t* tail = new uint8_t[GetAddressLength()]; + auto tail = new uint8_t[GetAddressLength()]; uint8_t taillen = 0; GetHeadTail(head, headlen, tail, taillen); @@ -2221,7 +2221,7 @@ PbbAddressBlock::Serialize(Buffer::Iterator& start) const if (AddressSize() == 1) { - uint8_t* buf = new uint8_t[GetAddressLength()]; + auto buf = new uint8_t[GetAddressLength()]; SerializeAddress(buf, AddressBegin()); start.Write(buf, GetAddressLength()); @@ -2235,8 +2235,8 @@ PbbAddressBlock::Serialize(Buffer::Iterator& start) const } else if (AddressSize() > 0) { - uint8_t* head = new uint8_t[GetAddressLength()]; - uint8_t* tail = new uint8_t[GetAddressLength()]; + auto head = new uint8_t[GetAddressLength()]; + auto tail = new uint8_t[GetAddressLength()]; uint8_t headlen = 0; uint8_t taillen = 0; @@ -2266,9 +2266,8 @@ PbbAddressBlock::Serialize(Buffer::Iterator& start) const if (headlen + taillen < GetAddressLength()) { - uint8_t* mid = new uint8_t[GetAddressLength()]; - for (PbbAddressBlock::ConstAddressIterator iter = AddressBegin(); iter != AddressEnd(); - iter++) + auto mid = new uint8_t[GetAddressLength()]; + for (auto iter = AddressBegin(); iter != AddressEnd(); iter++) { SerializeAddress(mid, iter); start.Write(mid + headlen, GetAddressLength() - headlen - taillen); @@ -2279,7 +2278,7 @@ PbbAddressBlock::Serialize(Buffer::Iterator& start) const flags |= GetPrefixFlags(); bufref.WriteU8(flags); - for (ConstPrefixIterator iter = PrefixBegin(); iter != PrefixEnd(); iter++) + for (auto iter = PrefixBegin(); iter != PrefixEnd(); iter++) { start.WriteU8(*iter); } @@ -2302,7 +2301,7 @@ PbbAddressBlock::Deserialize(Buffer::Iterator& start) { uint8_t headlen = 0; uint8_t taillen = 0; - uint8_t* addrtmp = new uint8_t[GetAddressLength()]; + auto addrtmp = new uint8_t[GetAddressLength()]; memset(addrtmp, 0, GetAddressLength()); if (flags & AHAS_HEAD) @@ -2364,7 +2363,7 @@ PbbAddressBlock::Print(std::ostream& os, int level) const os << prefix << "PbbAddressBlock {" << std::endl; os << prefix << "\taddresses = " << std::endl; - for (ConstAddressIterator iter = AddressBegin(); iter != AddressEnd(); iter++) + for (auto iter = AddressBegin(); iter != AddressEnd(); iter++) { os << prefix << "\t\t"; PrintAddress(os, iter); @@ -2372,7 +2371,7 @@ PbbAddressBlock::Print(std::ostream& os, int level) const } os << prefix << "\tprefixes = " << std::endl; - for (ConstPrefixIterator iter = PrefixBegin(); iter != PrefixEnd(); iter++) + for (auto iter = PrefixBegin(); iter != PrefixEnd(); iter++) { os << prefix << "\t\t" << (int)(*iter) << std::endl; } @@ -2453,15 +2452,14 @@ PbbAddressBlock::GetHeadTail(uint8_t* head, uint8_t& headlen, uint8_t* tail, uin taillen = headlen; /* Temporary automatic buffers to store serialized addresses */ - uint8_t* buflast = new uint8_t[GetAddressLength()]; - uint8_t* bufcur = new uint8_t[GetAddressLength()]; + auto buflast = new uint8_t[GetAddressLength()]; + auto bufcur = new uint8_t[GetAddressLength()]; uint8_t* tmp; SerializeAddress(buflast, AddressBegin()); /* Skip the first item */ - for (PbbAddressBlock::ConstAddressIterator iter = AddressBegin()++; iter != AddressEnd(); - iter++) + for (auto iter = AddressBegin()++; iter != AddressEnd(); iter++) { SerializeAddress(bufcur, iter); diff --git a/src/network/utils/pcap-file.cc b/src/network/utils/pcap-file.cc index 78094ac15..9470484a7 100644 --- a/src/network/utils/pcap-file.cc +++ b/src/network/utils/pcap-file.cc @@ -552,8 +552,8 @@ PcapFile::Diff(const std::string& f1, return true; } - uint8_t* data1 = new uint8_t[snapLen](); - uint8_t* data2 = new uint8_t[snapLen](); + auto data1 = new uint8_t[snapLen](); + auto data2 = new uint8_t[snapLen](); uint32_t tsSec1 = 0; uint32_t tsSec2 = 0; uint32_t tsUsec1 = 0; diff --git a/src/network/utils/simple-channel.cc b/src/network/utils/simple-channel.cc index 5ba3db453..40e34e6ab 100644 --- a/src/network/utils/simple-channel.cc +++ b/src/network/utils/simple-channel.cc @@ -62,9 +62,7 @@ SimpleChannel::Send(Ptr p, Ptr sender) { NS_LOG_FUNCTION(this << p << protocol << to << from << sender); - for (std::vector>::const_iterator i = m_devices.begin(); - i != m_devices.end(); - ++i) + for (auto i = m_devices.begin(); i != m_devices.end(); ++i) { Ptr tmp = *i; if (tmp == sender) @@ -133,8 +131,7 @@ SimpleChannel::UnBlackList(Ptr from, Ptr to) { if (m_blackListedDevices.find(to) != m_blackListedDevices.end()) { - std::vector>::iterator iter; - iter = find(m_blackListedDevices[to].begin(), m_blackListedDevices[to].end(), from); + auto iter = find(m_blackListedDevices[to].begin(), m_blackListedDevices[to].end(), from); if (iter != m_blackListedDevices[to].end()) { m_blackListedDevices[to].erase(iter); diff --git a/src/nix-vector-routing/examples/nms-p2p-nix.cc b/src/nix-vector-routing/examples/nms-p2p-nix.cc index c44f833e9..7ec60cd43 100644 --- a/src/nix-vector-routing/examples/nms-p2p-nix.cc +++ b/src/nix-vector-routing/examples/nms-p2p-nix.cc @@ -193,7 +193,7 @@ main(int argc, char* argv[]) Array2D nodes_net0(nCN, 3); Array2D nodes_net1(nCN, 6); - NodeContainer* nodes_netLR = new NodeContainer[nCN]; + auto nodes_netLR = new NodeContainer[nCN]; Array2D nodes_net2(nCN, 14); Array3D nodes_net2LAN(nCN, 7, nLANClients); Array2D nodes_net3(nCN, 9); @@ -599,7 +599,7 @@ main(int argc, char* argv[]) if (nCN > 1) { std::cout << "Forming Ring Topology..." << std::endl; - NodeContainer* nodes_ring = new NodeContainer[nCN]; + auto nodes_ring = new NodeContainer[nCN]; for (int z = 0; z < nCN - 1; ++z) { nodes_ring[z].Add(nodes_net0[z][0].Get(0)); @@ -607,7 +607,7 @@ main(int argc, char* argv[]) } nodes_ring[nCN - 1].Add(nodes_net0[nCN - 1][0].Get(0)); nodes_ring[nCN - 1].Add(nodes_net0[0][0].Get(0)); - NetDeviceContainer* ndc_ring = new NetDeviceContainer[nCN]; + auto ndc_ring = new NetDeviceContainer[nCN]; for (int z = 0; z < nCN; ++z) { ndc_ring[z] = p2p_2gb200ms.Install(nodes_ring[z]); diff --git a/src/nix-vector-routing/model/nix-vector-routing.cc b/src/nix-vector-routing/model/nix-vector-routing.cc index b5db26ed3..25bce999c 100644 --- a/src/nix-vector-routing/model/nix-vector-routing.cc +++ b/src/nix-vector-routing/model/nix-vector-routing.cc @@ -151,8 +151,7 @@ NixVectorRouting::FlushGlobalNixRoutingCache() const { NS_LOG_FUNCTION_NOARGS(); - NodeList::Iterator listEnd = NodeList::End(); - for (NodeList::Iterator i = NodeList::Begin(); i != listEnd; i++) + for (auto i = NodeList::Begin(); i != NodeList::End(); i++) { Ptr node = *i; Ptr> rp = node->GetObject(); @@ -248,7 +247,7 @@ NixVectorRouting::GetNixVectorInCache(const IpAddress& address, bool& foundIn CheckCacheStateAndFlush(); - typename NixMap_t::iterator iter = m_nixCache.find(address); + auto iter = m_nixCache.find(address); if (iter != m_nixCache.end()) { NS_LOG_LOGIC("Found Nix-vector in cache."); @@ -269,7 +268,7 @@ NixVectorRouting::GetIpRouteInCache(IpAddress address) CheckCacheStateAndFlush(); - typename IpRouteMap_t::iterator iter = m_ipRouteCache.find(address); + auto iter = m_ipRouteCache.find(address); if (iter != m_ipRouteCache.end()) { NS_LOG_LOGIC("Found IpRoute in cache."); @@ -334,9 +333,7 @@ NixVectorRouting::BuildNixVector(const std::vector>& parentVector, // the index to the nix vector. // the index corresponds to the neighbor index uint32_t offset = 0; - for (NetDeviceContainer::Iterator iter = netDeviceContainer.Begin(); - iter != netDeviceContainer.End(); - iter++) + for (auto iter = netDeviceContainer.Begin(); iter != netDeviceContainer.End(); iter++) { Ptr remoteNode = (*iter)->GetNode(); @@ -466,7 +463,7 @@ NixVectorRouting::BuildIpAddressToNodeMap() const { NS_LOG_FUNCTION_NOARGS(); - for (NodeList::Iterator it = NodeList::Begin(); it != NodeList::End(); ++it) + for (auto it = NodeList::Begin(); it != NodeList::End(); ++it) { Ptr node = *it; Ptr ip = node->GetObject(); @@ -528,7 +525,7 @@ NixVectorRouting::GetNodeByIp(IpAddress dest) const Ptr destNode; - typename IpAddressToNodeMap::iterator iter = g_ipAddressToNodeMap.find(dest); + auto iter = g_ipAddressToNodeMap.find(dest); if (iter == g_ipAddressToNodeMap.end()) { @@ -555,7 +552,7 @@ NixVectorRouting::GetInterfaceByNetDevice(Ptr netDevice) const Ptr ipInterface; - typename NetDeviceToIpInterfaceMap::iterator iter = g_netdeviceToIpInterfaceMap.find(netDevice); + auto iter = g_netdeviceToIpInterfaceMap.find(netDevice); if (iter == g_netdeviceToIpInterfaceMap.end()) { @@ -1021,8 +1018,7 @@ NixVectorRouting::PrintRoutingTable(Ptr stream, Time::Un { *os << std::setw(30) << "Destination"; *os << "NixVector" << std::endl; - for (typename NixMap_t::const_iterator it = m_nixCache.begin(); it != m_nixCache.end(); - it++) + for (auto it = m_nixCache.begin(); it != m_nixCache.end(); it++) { std::ostringstream dest; dest << it->first; @@ -1045,9 +1041,7 @@ NixVectorRouting::PrintRoutingTable(Ptr stream, Time::Un *os << std::setw(30) << "Gateway"; *os << std::setw(30) << "Source"; *os << "OutputDevice" << std::endl; - for (typename IpRouteMap_t::const_iterator it = m_ipRouteCache.begin(); - it != m_ipRouteCache.end(); - it++) + for (auto it = m_ipRouteCache.begin(); it != m_ipRouteCache.end(); it++) { std::ostringstream dest; std::ostringstream gw; @@ -1193,9 +1187,7 @@ NixVectorRouting::BFS(uint32_t numberOfNodes, // and scan through them. We push them // to the greyNode queue, if they aren't // already there. - for (NetDeviceContainer::Iterator iter = netDeviceContainer.Begin(); - iter != netDeviceContainer.End(); - iter++) + for (auto iter = netDeviceContainer.Begin(); iter != netDeviceContainer.End(); iter++) { Ptr remoteNode = (*iter)->GetNode(); Ptr remoteIpInterface = GetInterfaceByNetDevice(*iter); @@ -1257,8 +1249,7 @@ NixVectorRouting::BFS(uint32_t numberOfNodes, // and scan through them. We push them // to the greyNode queue, if they aren't // already there. - for (NetDeviceContainer::Iterator iter = netDeviceContainer.Begin(); - iter != netDeviceContainer.End(); + for (auto iter = netDeviceContainer.Begin(); iter != netDeviceContainer.End(); iter++) { Ptr remoteNode = (*iter)->GetNode(); diff --git a/src/olsr/helper/olsr-helper.cc b/src/olsr/helper/olsr-helper.cc index 38be92fef..38c3c2f4a 100644 --- a/src/olsr/helper/olsr-helper.cc +++ b/src/olsr/helper/olsr-helper.cc @@ -47,7 +47,7 @@ OlsrHelper::Copy() const void OlsrHelper::ExcludeInterface(Ptr node, uint32_t interface) { - std::map, std::set>::iterator it = m_interfaceExclusions.find(node); + auto it = m_interfaceExclusions.find(node); if (it == m_interfaceExclusions.end()) { @@ -67,7 +67,7 @@ OlsrHelper::Create(Ptr node) const { Ptr agent = m_agentFactory.Create(); - std::map, std::set>::const_iterator it = m_interfaceExclusions.find(node); + auto it = m_interfaceExclusions.find(node); if (it != m_interfaceExclusions.end()) { @@ -89,7 +89,7 @@ OlsrHelper::AssignStreams(NodeContainer c, int64_t stream) { int64_t currentStream = stream; Ptr node; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { node = (*i); Ptr ipv4 = node->GetObject(); diff --git a/src/olsr/model/olsr-header.cc b/src/olsr/model/olsr-header.cc index b7c865563..632962aea 100644 --- a/src/olsr/model/olsr-header.cc +++ b/src/olsr/model/olsr-header.cc @@ -352,8 +352,7 @@ MessageHeader::Mid::Serialize(Buffer::Iterator start) const { Buffer::Iterator i = start; - for (std::vector::const_iterator iter = this->interfaceAddresses.begin(); - iter != this->interfaceAddresses.end(); + for (auto iter = this->interfaceAddresses.begin(); iter != this->interfaceAddresses.end(); iter++) { i.WriteHtonU32(iter->Get()); @@ -384,9 +383,7 @@ uint32_t MessageHeader::Hello::GetSerializedSize() const { uint32_t size = 4; - for (std::vector::const_iterator iter = this->linkMessages.begin(); - iter != this->linkMessages.end(); - iter++) + for (auto iter = this->linkMessages.begin(); iter != this->linkMessages.end(); iter++) { const LinkMessage& lm = *iter; size += 4; @@ -432,9 +429,7 @@ MessageHeader::Hello::Serialize(Buffer::Iterator start) const i.WriteU8(this->hTime); i.WriteU8(static_cast(this->willingness)); - for (std::vector::const_iterator iter = this->linkMessages.begin(); - iter != this->linkMessages.end(); - iter++) + for (auto iter = this->linkMessages.begin(); iter != this->linkMessages.end(); iter++) { const LinkMessage& lm = *iter; @@ -447,8 +442,7 @@ MessageHeader::Hello::Serialize(Buffer::Iterator start) const // - the end of the message). i.WriteHtonU16(4 + lm.neighborInterfaceAddresses.size() * IPV4_ADDRESS_SIZE); - for (std::vector::const_iterator neigh_iter = - lm.neighborInterfaceAddresses.begin(); + for (auto neigh_iter = lm.neighborInterfaceAddresses.begin(); neigh_iter != lm.neighborInterfaceAddresses.end(); neigh_iter++) { @@ -530,9 +524,7 @@ MessageHeader::Tc::Serialize(Buffer::Iterator start) const i.WriteHtonU16(this->ansn); i.WriteHtonU16(0); // Reserved - for (std::vector::const_iterator iter = this->neighborAddresses.begin(); - iter != this->neighborAddresses.end(); - iter++) + for (auto iter = this->neighborAddresses.begin(); iter != this->neighborAddresses.end(); iter++) { i.WriteHtonU32(iter->Get()); } diff --git a/src/olsr/model/olsr-header.h b/src/olsr/model/olsr-header.h index 0712d08f6..c60743bda 100644 --- a/src/olsr/model/olsr-header.h +++ b/src/olsr/model/olsr-header.h @@ -706,9 +706,7 @@ inline std::ostream& operator<<(std::ostream& os, const MessageList& messages) { os << "["; - for (std::vector::const_iterator messageIter = messages.begin(); - messageIter != messages.end(); - messageIter++) + for (auto messageIter = messages.begin(); messageIter != messages.end(); messageIter++) { messageIter->Print(os); if (messageIter + 1 != messages.end()) diff --git a/src/olsr/model/olsr-routing-protocol.cc b/src/olsr/model/olsr-routing-protocol.cc index d66472843..58ee4c2c0 100644 --- a/src/olsr/model/olsr-routing-protocol.cc +++ b/src/olsr/model/olsr-routing-protocol.cc @@ -306,9 +306,7 @@ RoutingProtocol::DoDispose() m_recvSocket = nullptr; } - for (std::map, Ipv4InterfaceAddress>::iterator iter = m_sendSockets.begin(); - iter != m_sendSockets.end(); - iter++) + for (auto iter = m_sendSockets.begin(); iter != m_sendSockets.end(); iter++) { iter->first->Close(); } @@ -548,8 +546,7 @@ RoutingProtocol::RecvOlsr(Ptr socket) m_rxPacketTrace(olsrPacketHeader, messages); - for (MessageList::const_iterator messageIter = messages.begin(); messageIter != messages.end(); - messageIter++) + for (auto messageIter = messages.begin(); messageIter != messages.end(); messageIter++) { const MessageHeader& messageHeader = *messageIter; // If ttl is less than or equal to zero, or @@ -622,9 +619,7 @@ RoutingProtocol::RecvOlsr(Ptr socket) // If the message has been considered for forwarding, it should // not be retransmitted again - for (std::vector::const_iterator it = duplicated->ifaceList.begin(); - it != duplicated->ifaceList.end(); - it++) + for (auto it = duplicated->ifaceList.begin(); it != duplicated->ifaceList.end(); it++) { if (*it == receiverIfaceAddr) { @@ -664,8 +659,7 @@ int RoutingProtocol::Degree(const NeighborTuple& tuple) { int degree = 0; - for (TwoHopNeighborSet::const_iterator it = m_state.GetTwoHopNeighbors().begin(); - it != m_state.GetTwoHopNeighbors().end(); + for (auto it = m_state.GetTwoHopNeighbors().begin(); it != m_state.GetTwoHopNeighbors().end(); it++) { const TwoHopNeighborTuple& nb2hop_tuple = *it; @@ -696,8 +690,7 @@ CoverTwoHopNeighbors(Ipv4Address neighborMainAddr, TwoHopNeighborSet& N2) { // first gather all 2-hop neighbors to be removed std::set toRemove; - for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin(); twoHopNeigh != N2.end(); - twoHopNeigh++) + for (auto twoHopNeigh = N2.begin(); twoHopNeigh != N2.end(); twoHopNeigh++) { if (twoHopNeigh->neighborMainAddr == neighborMainAddr) { @@ -705,7 +698,7 @@ CoverTwoHopNeighbors(Ipv4Address neighborMainAddr, TwoHopNeighborSet& N2) } } // Now remove all matching records from N2 - for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin(); twoHopNeigh != N2.end();) + for (auto twoHopNeigh = N2.begin(); twoHopNeigh != N2.end();) { if (toRemove.find(twoHopNeigh->twoHopNeighborAddr) != toRemove.end()) { @@ -731,8 +724,7 @@ RoutingProtocol::MprComputation() // N is the subset of neighbors of the node, which are // neighbor "of the interface I" NeighborSet N; - for (NeighborSet::const_iterator neighbor = m_state.GetNeighbors().begin(); - neighbor != m_state.GetNeighbors().end(); + for (auto neighbor = m_state.GetNeighbors().begin(); neighbor != m_state.GetNeighbors().end(); neighbor++) { if (neighbor->status == NeighborTuple::STATUS_SYM) // I think that we need this check @@ -748,7 +740,7 @@ RoutingProtocol::MprComputation() // (iii) all the symmetric neighbors: the nodes for which there exists a symmetric // link to this node on some interface. TwoHopNeighborSet N2; - for (TwoHopNeighborSet::const_iterator twoHopNeigh = m_state.GetTwoHopNeighbors().begin(); + for (auto twoHopNeigh = m_state.GetTwoHopNeighbors().begin(); twoHopNeigh != m_state.GetTwoHopNeighbors().end(); twoHopNeigh++) { @@ -762,7 +754,7 @@ RoutingProtocol::MprComputation() // excluding: // (i) the nodes only reachable by members of N with willingness Willingness::NEVER bool ok = false; - for (NeighborSet::const_iterator neigh = N.begin(); neigh != N.end(); neigh++) + for (auto neigh = N.begin(); neigh != N.end(); neigh++) { if (neigh->neighborMainAddr == twoHopNeigh->neighborMainAddr) { @@ -778,7 +770,7 @@ RoutingProtocol::MprComputation() // excluding: // (iii) all the symmetric neighbors: the nodes for which there exists a symmetric // link to this node on some interface. - for (NeighborSet::const_iterator neigh = N.begin(); neigh != N.end(); neigh++) + for (auto neigh = N.begin(); neigh != N.end(); neigh++) { if (neigh->neighborMainAddr == twoHopNeigh->twoHopNeighborAddr) { @@ -797,9 +789,9 @@ RoutingProtocol::MprComputation() { std::ostringstream os; os << "["; - for (TwoHopNeighborSet::const_iterator iter = N2.begin(); iter != N2.end(); iter++) + for (auto iter = N2.begin(); iter != N2.end(); iter++) { - TwoHopNeighborSet::const_iterator next = iter; + auto next = iter; next++; os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr; if (next != N2.end()) @@ -814,7 +806,7 @@ RoutingProtocol::MprComputation() // 1. Start with an MPR set made of all members of N with // N_willingness equal to Willingness::ALWAYS - for (NeighborSet::const_iterator neighbor = N.begin(); neighbor != N.end(); neighbor++) + for (auto neighbor = N.begin(); neighbor != N.end(); neighbor++) { if (neighbor->willingness == Willingness::ALWAYS) { @@ -831,14 +823,11 @@ RoutingProtocol::MprComputation() // 3. Add to the MPR set those nodes in N, which are the *only* // nodes to provide reachability to a node in N2. std::set coveredTwoHopNeighbors; - for (TwoHopNeighborSet::const_iterator twoHopNeigh = N2.begin(); twoHopNeigh != N2.end(); - twoHopNeigh++) + for (auto twoHopNeigh = N2.begin(); twoHopNeigh != N2.end(); twoHopNeigh++) { bool onlyOne = true; // try to find another neighbor that can reach twoHopNeigh->twoHopNeighborAddr - for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin(); - otherTwoHopNeigh != N2.end(); - otherTwoHopNeigh++) + for (auto otherTwoHopNeigh = N2.begin(); otherTwoHopNeigh != N2.end(); otherTwoHopNeigh++) { if (otherTwoHopNeigh->twoHopNeighborAddr == twoHopNeigh->twoHopNeighborAddr && otherTwoHopNeigh->neighborMainAddr != twoHopNeigh->neighborMainAddr) @@ -856,8 +845,7 @@ RoutingProtocol::MprComputation() mprSet.insert(twoHopNeigh->neighborMainAddr); // take note of all the 2-hop neighbors reachable by the newly elected MPR - for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin(); - otherTwoHopNeigh != N2.end(); + for (auto otherTwoHopNeigh = N2.begin(); otherTwoHopNeigh != N2.end(); otherTwoHopNeigh++) { if (otherTwoHopNeigh->neighborMainAddr == twoHopNeigh->neighborMainAddr) @@ -868,7 +856,7 @@ RoutingProtocol::MprComputation() } } // Remove the nodes from N2 which are now covered by a node in the MPR set. - for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin(); twoHopNeigh != N2.end();) + for (auto twoHopNeigh = N2.begin(); twoHopNeigh != N2.end();) { if (coveredTwoHopNeighbors.find(twoHopNeigh->twoHopNeighborAddr) != coveredTwoHopNeighbors.end()) @@ -894,9 +882,9 @@ RoutingProtocol::MprComputation() { std::ostringstream os; os << "["; - for (TwoHopNeighborSet::const_iterator iter = N2.begin(); iter != N2.end(); iter++) + for (auto iter = N2.begin(); iter != N2.end(); iter++) { - TwoHopNeighborSet::const_iterator next = iter; + auto next = iter; next++; os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr; if (next != N2.end()) @@ -915,11 +903,11 @@ RoutingProtocol::MprComputation() // through this 1-hop neighbor std::map> reachability; std::set rs; - for (NeighborSet::iterator it = N.begin(); it != N.end(); it++) + for (auto it = N.begin(); it != N.end(); it++) { const NeighborTuple& nb_tuple = *it; int r = 0; - for (TwoHopNeighborSet::iterator it2 = N2.begin(); it2 != N2.end(); it2++) + for (auto it2 = N2.begin(); it2 != N2.end(); it2++) { const TwoHopNeighborTuple& nb2hop_tuple = *it2; if (nb_tuple.neighborMainAddr == nb2hop_tuple.neighborMainAddr) @@ -941,16 +929,14 @@ RoutingProtocol::MprComputation() // by a node in the MPR set. const NeighborTuple* max = nullptr; int max_r = 0; - for (std::set::iterator it = rs.begin(); it != rs.end(); it++) + for (auto it = rs.begin(); it != rs.end(); it++) { int r = *it; if (r == 0) { continue; } - for (std::vector::iterator it2 = reachability[r].begin(); - it2 != reachability[r].end(); - it2++) + for (auto it2 = reachability[r].begin(); it2 != reachability[r].end(); it2++) { const NeighborTuple* nb_tuple = *it2; if (max == nullptr || nb_tuple->willingness > max->willingness) @@ -989,9 +975,9 @@ RoutingProtocol::MprComputation() { std::ostringstream os; os << "["; - for (MprSet::const_iterator iter = mprSet.begin(); iter != mprSet.end(); iter++) + for (auto iter = mprSet.begin(); iter != mprSet.end(); iter++) { - MprSet::const_iterator next = iter; + auto next = iter; next++; os << *iter; if (next != mprSet.end()) @@ -1034,7 +1020,7 @@ RoutingProtocol::RoutingTableComputation() // 2. The new routing entries are added starting with the // symmetric neighbors (h=1) as the destination nodes. const NeighborSet& neighborSet = m_state.GetNeighbors(); - for (NeighborSet::const_iterator it = neighborSet.begin(); it != neighborSet.end(); it++) + for (auto it = neighborSet.begin(); it != neighborSet.end(); it++) { const NeighborTuple& nb_tuple = *it; NS_LOG_DEBUG("Looking at neighbor tuple: " << nb_tuple); @@ -1043,7 +1029,7 @@ RoutingProtocol::RoutingTableComputation() bool nb_main_addr = false; const LinkTuple* lt = nullptr; const LinkSet& linkSet = m_state.GetLinks(); - for (LinkSet::const_iterator it2 = linkSet.begin(); it2 != linkSet.end(); it2++) + for (auto it2 = linkSet.begin(); it2 != linkSet.end(); it2++) { const LinkTuple& link_tuple = *it2; NS_LOG_DEBUG("Looking at link tuple: " @@ -1099,9 +1085,7 @@ RoutingProtocol::RoutingTableComputation() // N_neighbor_main_addr correspond to a neighbor node with // willingness different of Willingness::NEVER, const TwoHopNeighborSet& twoHopNeighbors = m_state.GetTwoHopNeighbors(); - for (TwoHopNeighborSet::const_iterator it = twoHopNeighbors.begin(); - it != twoHopNeighbors.end(); - it++) + for (auto it = twoHopNeighbors.begin(); it != twoHopNeighbors.end(); it++) { const TwoHopNeighborTuple& nb2hop_tuple = *it; @@ -1124,9 +1108,7 @@ RoutingProtocol::RoutingTableComputation() // neighbor set where N_neighbor_main_addr correspond to a // neighbor node with willingness different of Willingness::NEVER... bool nb2hopOk = false; - for (NeighborSet::const_iterator neighbor = neighborSet.begin(); - neighbor != neighborSet.end(); - neighbor++) + for (auto neighbor = neighborSet.begin(); neighbor != neighborSet.end(); neighbor++) { if (neighbor->neighborMainAddr == nb2hop_tuple.neighborMainAddr && neighbor->willingness != Willingness::NEVER) @@ -1180,7 +1162,7 @@ RoutingProtocol::RoutingTableComputation() // is equal to h, then a new route entry MUST be recorded in // the routing table (if it does not already exist) const TopologySet& topology = m_state.GetTopologySet(); - for (TopologySet::const_iterator it = topology.begin(); it != topology.end(); it++) + for (auto it = topology.begin(); it != topology.end(); it++) { const TopologyTuple& topology_tuple = *it; NS_LOG_LOGIC("Looking at topology tuple: " << topology_tuple); @@ -1230,7 +1212,7 @@ RoutingProtocol::RoutingTableComputation() // AND there is no routing entry such that: // R_dest_addr == I_iface_addr const IfaceAssocSet& ifaceAssocSet = m_state.GetIfaceAssocSet(); - for (IfaceAssocSet::const_iterator it = ifaceAssocSet.begin(); it != ifaceAssocSet.end(); it++) + for (auto it = ifaceAssocSet.begin(); it != ifaceAssocSet.end(); it++) { const IfaceAssocTuple& tuple = *it; RoutingTableEntry entry1; @@ -1262,8 +1244,7 @@ RoutingProtocol::RoutingTableComputation() m_hnaRoutingTable->RemoveRoute(0); } - for (AssociationSet::const_iterator it = associationSet.begin(); it != associationSet.end(); - it++) + for (auto it = associationSet.begin(); it != associationSet.end(); it++) { const AssociationTuple& tuple = *it; @@ -1273,7 +1254,7 @@ RoutingProtocol::RoutingTableComputation() bool goToNextAssociationTuple = false; const Associations& localHnaAssociations = m_state.GetAssociations(); NS_LOG_DEBUG("Nb local associations: " << localHnaAssociations.size()); - for (Associations::const_iterator assocIterator = localHnaAssociations.begin(); + for (auto assocIterator = localHnaAssociations.begin(); assocIterator != localHnaAssociations.end(); assocIterator++) { @@ -1350,7 +1331,7 @@ RoutingProtocol::ProcessHello(const olsr::MessageHeader& msg, const LinkSet& links = m_state.GetLinks(); NS_LOG_DEBUG(Simulator::Now().As(Time::S) << " ** BEGIN dump Link Set for OLSR Node " << m_mainAddress); - for (LinkSet::const_iterator link = links.begin(); link != links.end(); link++) + for (auto link = links.begin(); link != links.end(); link++) { NS_LOG_DEBUG(*link); } @@ -1359,8 +1340,7 @@ RoutingProtocol::ProcessHello(const olsr::MessageHeader& msg, const NeighborSet& neighbors = m_state.GetNeighbors(); NS_LOG_DEBUG(Simulator::Now().As(Time::S) << " ** BEGIN dump Neighbor Set for OLSR Node " << m_mainAddress); - for (NeighborSet::const_iterator neighbor = neighbors.begin(); neighbor != neighbors.end(); - neighbor++) + for (auto neighbor = neighbors.begin(); neighbor != neighbors.end(); neighbor++) { NS_LOG_DEBUG(*neighbor); } @@ -1376,9 +1356,7 @@ RoutingProtocol::ProcessHello(const olsr::MessageHeader& msg, const TwoHopNeighborSet& twoHopNeighbors = m_state.GetTwoHopNeighbors(); NS_LOG_DEBUG(Simulator::Now().As(Time::S) << " ** BEGIN dump TwoHopNeighbor Set for OLSR Node " << m_mainAddress); - for (TwoHopNeighborSet::const_iterator tuple = twoHopNeighbors.begin(); - tuple != twoHopNeighbors.end(); - tuple++) + for (auto tuple = twoHopNeighbors.begin(); tuple != twoHopNeighbors.end(); tuple++) { NS_LOG_DEBUG(*tuple); } @@ -1424,9 +1402,7 @@ RoutingProtocol::ProcessTc(const olsr::MessageHeader& msg, const Ipv4Address& se // 4. For each of the advertised neighbor main address received in // the TC message: - for (std::vector::const_iterator i = tc.neighborAddresses.begin(); - i != tc.neighborAddresses.end(); - i++) + for (auto i = tc.neighborAddresses.begin(); i != tc.neighborAddresses.end(); i++) { const Ipv4Address& addr = *i; // 4.1. If there exist some tuple in the topology set where: @@ -1469,7 +1445,7 @@ RoutingProtocol::ProcessTc(const olsr::MessageHeader& msg, const Ipv4Address& se const TopologySet& topology = m_state.GetTopologySet(); NS_LOG_DEBUG(Simulator::Now().As(Time::S) << " ** BEGIN dump TopologySet for OLSR Node " << m_mainAddress); - for (TopologySet::const_iterator tuple = topology.begin(); tuple != topology.end(); tuple++) + for (auto tuple = topology.begin(); tuple != topology.end(); tuple++) { NS_LOG_DEBUG(*tuple); } @@ -1498,13 +1474,11 @@ RoutingProtocol::ProcessMid(const olsr::MessageHeader& msg, const Ipv4Address& s } // 2. For each interface address listed in the MID message - for (std::vector::const_iterator i = mid.interfaceAddresses.begin(); - i != mid.interfaceAddresses.end(); - i++) + for (auto i = mid.interfaceAddresses.begin(); i != mid.interfaceAddresses.end(); i++) { bool updated = false; IfaceAssocSet& ifaceAssoc = m_state.GetIfaceAssocSetMutable(); - for (IfaceAssocSet::iterator tuple = ifaceAssoc.begin(); tuple != ifaceAssoc.end(); tuple++) + for (auto tuple = ifaceAssoc.begin(); tuple != ifaceAssoc.end(); tuple++) { if (tuple->ifaceAddr == *i && tuple->mainAddr == msg.GetOriginatorAddress()) { @@ -1533,15 +1507,13 @@ RoutingProtocol::ProcessMid(const olsr::MessageHeader& msg, const Ipv4Address& s // TwoHopNeighborTuples, update the neighbor addresses taking into account // the new MID information. NeighborSet& neighbors = m_state.GetNeighbors(); - for (NeighborSet::iterator neighbor = neighbors.begin(); neighbor != neighbors.end(); - neighbor++) + for (auto neighbor = neighbors.begin(); neighbor != neighbors.end(); neighbor++) { neighbor->neighborMainAddr = GetMainAddress(neighbor->neighborMainAddr); } TwoHopNeighborSet& twoHopNeighbors = m_state.GetTwoHopNeighbors(); - for (TwoHopNeighborSet::iterator twoHopNeighbor = twoHopNeighbors.begin(); - twoHopNeighbor != twoHopNeighbors.end(); + for (auto twoHopNeighbor = twoHopNeighbors.begin(); twoHopNeighbor != twoHopNeighbors.end(); twoHopNeighbor++) { twoHopNeighbor->neighborMainAddr = GetMainAddress(twoHopNeighbor->neighborMainAddr); @@ -1567,10 +1539,7 @@ RoutingProtocol::ProcessHna(const olsr::MessageHeader& msg, const Ipv4Address& s // 2. Otherwise, for each (network address, netmask) pair in the // message: - for (std::vector::const_iterator it = - hna.associations.begin(); - it != hna.associations.end(); - it++) + for (auto it = hna.associations.begin(); it != hna.associations.end(); it++) { AssociationTuple* tuple = m_state.FindAssociationTuple(msg.GetOriginatorAddress(), it->address, it->mask); @@ -1709,9 +1678,7 @@ RoutingProtocol::SendPacket(Ptr packet, const MessageList& containedMess m_txPacketTrace(header, containedMessages); // Send it - for (std::map, Ipv4InterfaceAddress>::const_iterator i = m_sendSockets.begin(); - i != m_sendSockets.end(); - i++) + for (auto i = m_sendSockets.begin(); i != m_sendSockets.end(); i++) { Ptr pkt = packet->Copy(); Ipv4Address bcast = i->second.GetLocal().GetSubnetDirectedBroadcast(i->second.GetMask()); @@ -1729,9 +1696,7 @@ RoutingProtocol::SendQueuedMessages() MessageList msglist; - for (std::vector::const_iterator message = m_queuedMessages.begin(); - message != m_queuedMessages.end(); - message++) + for (auto message = m_queuedMessages.begin(); message != m_queuedMessages.end(); message++) { Ptr p = Create(); p->AddHeader(*message); @@ -1776,8 +1741,7 @@ RoutingProtocol::SendHello() std::vector& linkMessages = hello.linkMessages; const LinkSet& links = m_state.GetLinks(); - for (LinkSet::const_iterator link_tuple = links.begin(); link_tuple != links.end(); - link_tuple++) + for (auto link_tuple = links.begin(); link_tuple != links.end(); link_tuple++) { if (!(GetMainAddress(link_tuple->localIfaceAddr) == m_mainAddress && link_tuple->time >= now)) @@ -1811,7 +1775,7 @@ RoutingProtocol::SendHello() else { bool ok = false; - for (NeighborSet::const_iterator nb_tuple = m_state.GetNeighbors().begin(); + for (auto nb_tuple = m_state.GetNeighbors().begin(); nb_tuple != m_state.GetNeighbors().end(); nb_tuple++) { @@ -1882,7 +1846,7 @@ RoutingProtocol::SendTc() olsr::MessageHeader::Tc& tc = msg.GetTc(); tc.ansn = m_ansn; - for (MprSelectorSet::const_iterator mprsel_tuple = m_state.GetMprSelectors().begin(); + for (auto mprsel_tuple = m_state.GetMprSelectors().begin(); mprsel_tuple != m_state.GetMprSelectors().end(); mprsel_tuple++) { @@ -1953,9 +1917,7 @@ RoutingProtocol::SendHna() // Add all local HNA associations to the HNA message const Associations& localHnaAssociations = m_state.GetAssociations(); - for (Associations::const_iterator it = localHnaAssociations.begin(); - it != localHnaAssociations.end(); - it++) + for (auto it = localHnaAssociations.begin(); it != localHnaAssociations.end(); it++) { olsr::MessageHeader::Hna::Association assoc = {it->networkAddr, it->netmask}; associations.push_back(assoc); @@ -1976,7 +1938,7 @@ RoutingProtocol::AddHostNetworkAssociation(Ipv4Address networkAddr, Ipv4Mask net // Check if the (networkAddr, netmask) tuple already exist // in the list of local HNA associations const Associations& localHnaAssociations = m_state.GetAssociations(); - for (Associations::const_iterator assocIterator = localHnaAssociations.begin(); + for (auto assocIterator = localHnaAssociations.begin(); assocIterator != localHnaAssociations.end(); assocIterator++) { @@ -2050,7 +2012,7 @@ RoutingProtocol::SetRoutingTableAssociation(Ptr routingTable) bool RoutingProtocol::UsesNonOlsrOutgoingInterface(const Ipv4RoutingTableEntry& route) { - std::set::const_iterator ci = m_interfaceExclusions.find(route.GetInterface()); + auto ci = m_interfaceExclusions.find(route.GetInterface()); // The outgoing interface is a non-OLSR interface if a match is found // before reaching the end of the list of excluded interfaces return ci != m_interfaceExclusions.end(); @@ -2090,13 +2052,11 @@ RoutingProtocol::LinkSensing(const olsr::MessageHeader& msg, } link_tuple->asymTime = now + msg.GetVTime(); - for (std::vector::const_iterator linkMessage = - hello.linkMessages.begin(); - linkMessage != hello.linkMessages.end(); + for (auto linkMessage = hello.linkMessages.begin(); linkMessage != hello.linkMessages.end(); linkMessage++) { - LinkType linkType = LinkType(linkMessage->linkCode & 0x03); - NeighborType neighborType = NeighborType((linkMessage->linkCode >> 2) & 0x03); + auto linkType = LinkType(linkMessage->linkCode & 0x03); + auto neighborType = NeighborType((linkMessage->linkCode >> 2) & 0x03); NS_LOG_DEBUG("Looking at HELLO link messages with Link Type " << linkType << " and Neighbor Type " << neighborType); @@ -2110,8 +2070,7 @@ RoutingProtocol::LinkSensing(const olsr::MessageHeader& msg, continue; } - for (std::vector::const_iterator neighIfaceAddr = - linkMessage->neighborInterfaceAddresses.begin(); + for (auto neighIfaceAddr = linkMessage->neighborInterfaceAddresses.begin(); neighIfaceAddr != linkMessage->neighborInterfaceAddresses.end(); neighIfaceAddr++) { @@ -2186,8 +2145,7 @@ RoutingProtocol::PopulateTwoHopNeighborSet(const olsr::MessageHeader& msg, NS_LOG_DEBUG("Olsr node " << m_mainAddress << ": PopulateTwoHopNeighborSet BEGIN"); - for (LinkSet::const_iterator link_tuple = m_state.GetLinks().begin(); - link_tuple != m_state.GetLinks().end(); + for (auto link_tuple = m_state.GetLinks().begin(); link_tuple != m_state.GetLinks().end(); link_tuple++) { NS_LOG_LOGIC("Looking at link tuple: " << *link_tuple); @@ -2210,16 +2168,14 @@ RoutingProtocol::PopulateTwoHopNeighborSet(const olsr::MessageHeader& msg, } typedef std::vector LinkMessageVec; - for (LinkMessageVec::const_iterator linkMessage = hello.linkMessages.begin(); - linkMessage != hello.linkMessages.end(); + for (auto linkMessage = hello.linkMessages.begin(); linkMessage != hello.linkMessages.end(); linkMessage++) { - NeighborType neighborType = NeighborType((linkMessage->linkCode >> 2) & 0x3); + auto neighborType = NeighborType((linkMessage->linkCode >> 2) & 0x3); NS_LOG_DEBUG( "Looking at Link Message from HELLO message: neighborType=" << neighborType); - for (std::vector::const_iterator nb2hop_addr_iter = - linkMessage->neighborInterfaceAddresses.begin(); + for (auto nb2hop_addr_iter = linkMessage->neighborInterfaceAddresses.begin(); nb2hop_addr_iter != linkMessage->neighborInterfaceAddresses.end(); nb2hop_addr_iter++) { @@ -2295,17 +2251,15 @@ RoutingProtocol::PopulateMprSelectorSet(const olsr::MessageHeader& msg, Time now = Simulator::Now(); typedef std::vector LinkMessageVec; - for (LinkMessageVec::const_iterator linkMessage = hello.linkMessages.begin(); - linkMessage != hello.linkMessages.end(); + for (auto linkMessage = hello.linkMessages.begin(); linkMessage != hello.linkMessages.end(); linkMessage++) { - NeighborType neighborType = NeighborType(linkMessage->linkCode >> 2); + auto neighborType = NeighborType(linkMessage->linkCode >> 2); if (neighborType == NeighborType::MPR_NEIGH) { NS_LOG_DEBUG("Processing a link message with neighbor type MPR_NEIGH"); - for (std::vector::const_iterator nb_iface_addr = - linkMessage->neighborInterfaceAddresses.begin(); + for (auto nb_iface_addr = linkMessage->neighborInterfaceAddresses.begin(); nb_iface_addr != linkMessage->neighborInterfaceAddresses.end(); nb_iface_addr++) { @@ -2468,7 +2422,7 @@ RoutingProtocol::LinkTupleUpdated(const LinkTuple& tuple, Willingness willingnes bool hasSymmetricLink = false; const LinkSet& linkSet = m_state.GetLinks(); - for (LinkSet::const_iterator it = linkSet.begin(); it != linkSet.end(); it++) + for (auto it = linkSet.begin(); it != linkSet.end(); it++) { const LinkTuple& link_tuple = *it; if (GetMainAddress(link_tuple.neighborIfaceAddr) == nb_tuple->neighborMainAddr && @@ -2888,7 +2842,7 @@ bool RoutingProtocol::Lookup(const Ipv4Address& dest, RoutingTableEntry& outEntry) const { // Get the iterator at "dest" position - std::map::const_iterator it = m_table.find(dest); + auto it = m_table.find(dest); // If there is no route to "dest", return NULL if (it == m_table.end()) { @@ -3100,9 +3054,7 @@ RoutingProtocol::RouteInput(Ptr p, << ": RouteInput for dest=" << header.GetDestination() << " --> NOT FOUND; ** Dumping routing table..."); - for (std::map::const_iterator iter = m_table.begin(); - iter != m_table.end(); - iter++) + for (auto iter = m_table.begin(); iter != m_table.end(); iter++) { NS_LOG_DEBUG("dest=" << iter->first << " --> next=" << iter->second.nextAddr << " via interface " << iter->second.interface); @@ -3186,9 +3138,7 @@ std::vector RoutingProtocol::GetRoutingTableEntries() const { std::vector retval; - for (std::map::const_iterator iter = m_table.begin(); - iter != m_table.end(); - iter++) + for (auto iter = m_table.begin(); iter != m_table.end(); iter++) { retval.push_back(iter->second); } @@ -3242,8 +3192,7 @@ RoutingProtocol::AssignStreams(int64_t stream) bool RoutingProtocol::IsMyOwnAddress(const Ipv4Address& a) const { - std::map, Ipv4InterfaceAddress>::const_iterator j; - for (j = m_sendSockets.begin(); j != m_sendSockets.end(); ++j) + for (auto j = m_sendSockets.begin(); j != m_sendSockets.end(); ++j) { Ipv4InterfaceAddress iface = j->second; if (a == iface.GetLocal()) @@ -3261,14 +3210,12 @@ RoutingProtocol::Dump() Time now = Simulator::Now(); NS_LOG_DEBUG("Dumping for node with main address " << m_mainAddress); NS_LOG_DEBUG(" Neighbor set"); - for (NeighborSet::const_iterator iter = m_state.GetNeighbors().begin(); - iter != m_state.GetNeighbors().end(); - iter++) + for (auto iter = m_state.GetNeighbors().begin(); iter != m_state.GetNeighbors().end(); iter++) { NS_LOG_DEBUG(" " << *iter); } NS_LOG_DEBUG(" Two-hop neighbor set"); - for (TwoHopNeighborSet::const_iterator iter = m_state.GetTwoHopNeighbors().begin(); + for (auto iter = m_state.GetTwoHopNeighbors().begin(); iter != m_state.GetTwoHopNeighbors().end(); iter++) { @@ -3278,9 +3225,7 @@ RoutingProtocol::Dump() } } NS_LOG_DEBUG(" Routing table"); - for (std::map::const_iterator iter = m_table.begin(); - iter != m_table.end(); - iter++) + for (auto iter = m_table.begin(); iter != m_table.end(); iter++) { NS_LOG_DEBUG(" dest=" << iter->first << " --> next=" << iter->second.nextAddr << " via interface " << iter->second.interface); diff --git a/src/olsr/model/olsr-state.cc b/src/olsr/model/olsr-state.cc index ebc318796..5a2874323 100644 --- a/src/olsr/model/olsr-state.cc +++ b/src/olsr/model/olsr-state.cc @@ -37,7 +37,7 @@ namespace olsr MprSelectorTuple* OlsrState::FindMprSelectorTuple(const Ipv4Address& mainAddr) { - for (MprSelectorSet::iterator it = m_mprSelectorSet.begin(); it != m_mprSelectorSet.end(); it++) + for (auto it = m_mprSelectorSet.begin(); it != m_mprSelectorSet.end(); it++) { if (it->mainAddr == mainAddr) { @@ -50,7 +50,7 @@ OlsrState::FindMprSelectorTuple(const Ipv4Address& mainAddr) void OlsrState::EraseMprSelectorTuple(const MprSelectorTuple& tuple) { - for (MprSelectorSet::iterator it = m_mprSelectorSet.begin(); it != m_mprSelectorSet.end(); it++) + for (auto it = m_mprSelectorSet.begin(); it != m_mprSelectorSet.end(); it++) { if (*it == tuple) { @@ -63,7 +63,7 @@ OlsrState::EraseMprSelectorTuple(const MprSelectorTuple& tuple) void OlsrState::EraseMprSelectorTuples(const Ipv4Address& mainAddr) { - for (MprSelectorSet::iterator it = m_mprSelectorSet.begin(); it != m_mprSelectorSet.end();) + for (auto it = m_mprSelectorSet.begin(); it != m_mprSelectorSet.end();) { if (it->mainAddr == mainAddr) { @@ -87,11 +87,9 @@ OlsrState::PrintMprSelectorSet() const { std::ostringstream os; os << "["; - for (MprSelectorSet::const_iterator iter = m_mprSelectorSet.begin(); - iter != m_mprSelectorSet.end(); - iter++) + for (auto iter = m_mprSelectorSet.begin(); iter != m_mprSelectorSet.end(); iter++) { - MprSelectorSet::const_iterator next = iter; + auto next = iter; next++; os << iter->mainAddr; if (next != m_mprSelectorSet.end()) @@ -108,7 +106,7 @@ OlsrState::PrintMprSelectorSet() const NeighborTuple* OlsrState::FindNeighborTuple(const Ipv4Address& mainAddr) { - for (NeighborSet::iterator it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) + for (auto it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) { if (it->neighborMainAddr == mainAddr) { @@ -121,7 +119,7 @@ OlsrState::FindNeighborTuple(const Ipv4Address& mainAddr) const NeighborTuple* OlsrState::FindSymNeighborTuple(const Ipv4Address& mainAddr) const { - for (NeighborSet::const_iterator it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) + for (auto it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) { if (it->neighborMainAddr == mainAddr && it->status == NeighborTuple::STATUS_SYM) { @@ -134,7 +132,7 @@ OlsrState::FindSymNeighborTuple(const Ipv4Address& mainAddr) const NeighborTuple* OlsrState::FindNeighborTuple(const Ipv4Address& mainAddr, Willingness willingness) { - for (NeighborSet::iterator it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) + for (auto it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) { if (it->neighborMainAddr == mainAddr && it->willingness == willingness) { @@ -147,7 +145,7 @@ OlsrState::FindNeighborTuple(const Ipv4Address& mainAddr, Willingness willingnes void OlsrState::EraseNeighborTuple(const NeighborTuple& tuple) { - for (NeighborSet::iterator it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) + for (auto it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) { if (*it == tuple) { @@ -160,7 +158,7 @@ OlsrState::EraseNeighborTuple(const NeighborTuple& tuple) void OlsrState::EraseNeighborTuple(const Ipv4Address& mainAddr) { - for (NeighborSet::iterator it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) + for (auto it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) { if (it->neighborMainAddr == mainAddr) { @@ -173,7 +171,7 @@ OlsrState::EraseNeighborTuple(const Ipv4Address& mainAddr) void OlsrState::InsertNeighborTuple(const NeighborTuple& tuple) { - for (NeighborSet::iterator it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) + for (auto it = m_neighborSet.begin(); it != m_neighborSet.end(); it++) { if (it->neighborMainAddr == tuple.neighborMainAddr) { @@ -191,9 +189,7 @@ TwoHopNeighborTuple* OlsrState::FindTwoHopNeighborTuple(const Ipv4Address& neighborMainAddr, const Ipv4Address& twoHopNeighborAddr) { - for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin(); - it != m_twoHopNeighborSet.end(); - it++) + for (auto it = m_twoHopNeighborSet.begin(); it != m_twoHopNeighborSet.end(); it++) { if (it->neighborMainAddr == neighborMainAddr && it->twoHopNeighborAddr == twoHopNeighborAddr) @@ -207,9 +203,7 @@ OlsrState::FindTwoHopNeighborTuple(const Ipv4Address& neighborMainAddr, void OlsrState::EraseTwoHopNeighborTuple(const TwoHopNeighborTuple& tuple) { - for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin(); - it != m_twoHopNeighborSet.end(); - it++) + for (auto it = m_twoHopNeighborSet.begin(); it != m_twoHopNeighborSet.end(); it++) { if (*it == tuple) { @@ -223,8 +217,7 @@ void OlsrState::EraseTwoHopNeighborTuples(const Ipv4Address& neighborMainAddr, const Ipv4Address& twoHopNeighborAddr) { - for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin(); - it != m_twoHopNeighborSet.end();) + for (auto it = m_twoHopNeighborSet.begin(); it != m_twoHopNeighborSet.end();) { if (it->neighborMainAddr == neighborMainAddr && it->twoHopNeighborAddr == twoHopNeighborAddr) @@ -241,8 +234,7 @@ OlsrState::EraseTwoHopNeighborTuples(const Ipv4Address& neighborMainAddr, void OlsrState::EraseTwoHopNeighborTuples(const Ipv4Address& neighborMainAddr) { - for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin(); - it != m_twoHopNeighborSet.end();) + for (auto it = m_twoHopNeighborSet.begin(); it != m_twoHopNeighborSet.end();) { if (it->neighborMainAddr == neighborMainAddr) { @@ -266,7 +258,7 @@ OlsrState::InsertTwoHopNeighborTuple(const TwoHopNeighborTuple& tuple) bool OlsrState::FindMprAddress(const Ipv4Address& addr) { - MprSet::iterator it = m_mprSet.find(addr); + auto it = m_mprSet.find(addr); return (it != m_mprSet.end()); } @@ -287,7 +279,7 @@ OlsrState::GetMprSet() const DuplicateTuple* OlsrState::FindDuplicateTuple(const Ipv4Address& addr, uint16_t sequenceNumber) { - for (DuplicateSet::iterator it = m_duplicateSet.begin(); it != m_duplicateSet.end(); it++) + for (auto it = m_duplicateSet.begin(); it != m_duplicateSet.end(); it++) { if (it->address == addr && it->sequenceNumber == sequenceNumber) { @@ -300,7 +292,7 @@ OlsrState::FindDuplicateTuple(const Ipv4Address& addr, uint16_t sequenceNumber) void OlsrState::EraseDuplicateTuple(const DuplicateTuple& tuple) { - for (DuplicateSet::iterator it = m_duplicateSet.begin(); it != m_duplicateSet.end(); it++) + for (auto it = m_duplicateSet.begin(); it != m_duplicateSet.end(); it++) { if (*it == tuple) { @@ -321,7 +313,7 @@ OlsrState::InsertDuplicateTuple(const DuplicateTuple& tuple) LinkTuple* OlsrState::FindLinkTuple(const Ipv4Address& ifaceAddr) { - for (LinkSet::iterator it = m_linkSet.begin(); it != m_linkSet.end(); it++) + for (auto it = m_linkSet.begin(); it != m_linkSet.end(); it++) { if (it->neighborIfaceAddr == ifaceAddr) { @@ -334,7 +326,7 @@ OlsrState::FindLinkTuple(const Ipv4Address& ifaceAddr) LinkTuple* OlsrState::FindSymLinkTuple(const Ipv4Address& ifaceAddr, Time now) { - for (LinkSet::iterator it = m_linkSet.begin(); it != m_linkSet.end(); it++) + for (auto it = m_linkSet.begin(); it != m_linkSet.end(); it++) { if (it->neighborIfaceAddr == ifaceAddr) { @@ -354,7 +346,7 @@ OlsrState::FindSymLinkTuple(const Ipv4Address& ifaceAddr, Time now) void OlsrState::EraseLinkTuple(const LinkTuple& tuple) { - for (LinkSet::iterator it = m_linkSet.begin(); it != m_linkSet.end(); it++) + for (auto it = m_linkSet.begin(); it != m_linkSet.end(); it++) { if (*it == tuple) { @@ -376,7 +368,7 @@ OlsrState::InsertLinkTuple(const LinkTuple& tuple) TopologyTuple* OlsrState::FindTopologyTuple(const Ipv4Address& destAddr, const Ipv4Address& lastAddr) { - for (TopologySet::iterator it = m_topologySet.begin(); it != m_topologySet.end(); it++) + for (auto it = m_topologySet.begin(); it != m_topologySet.end(); it++) { if (it->destAddr == destAddr && it->lastAddr == lastAddr) { @@ -389,7 +381,7 @@ OlsrState::FindTopologyTuple(const Ipv4Address& destAddr, const Ipv4Address& las TopologyTuple* OlsrState::FindNewerTopologyTuple(const Ipv4Address& lastAddr, uint16_t ansn) { - for (TopologySet::iterator it = m_topologySet.begin(); it != m_topologySet.end(); it++) + for (auto it = m_topologySet.begin(); it != m_topologySet.end(); it++) { if (it->lastAddr == lastAddr && it->sequenceNumber > ansn) { @@ -402,7 +394,7 @@ OlsrState::FindNewerTopologyTuple(const Ipv4Address& lastAddr, uint16_t ansn) void OlsrState::EraseTopologyTuple(const TopologyTuple& tuple) { - for (TopologySet::iterator it = m_topologySet.begin(); it != m_topologySet.end(); it++) + for (auto it = m_topologySet.begin(); it != m_topologySet.end(); it++) { if (*it == tuple) { @@ -415,7 +407,7 @@ OlsrState::EraseTopologyTuple(const TopologyTuple& tuple) void OlsrState::EraseOlderTopologyTuples(const Ipv4Address& lastAddr, uint16_t ansn) { - for (TopologySet::iterator it = m_topologySet.begin(); it != m_topologySet.end();) + for (auto it = m_topologySet.begin(); it != m_topologySet.end();) { if (it->lastAddr == lastAddr && it->sequenceNumber < ansn) { @@ -439,7 +431,7 @@ OlsrState::InsertTopologyTuple(const TopologyTuple& tuple) IfaceAssocTuple* OlsrState::FindIfaceAssocTuple(const Ipv4Address& ifaceAddr) { - for (IfaceAssocSet::iterator it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); it++) + for (auto it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); it++) { if (it->ifaceAddr == ifaceAddr) { @@ -452,8 +444,7 @@ OlsrState::FindIfaceAssocTuple(const Ipv4Address& ifaceAddr) const IfaceAssocTuple* OlsrState::FindIfaceAssocTuple(const Ipv4Address& ifaceAddr) const { - for (IfaceAssocSet::const_iterator it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); - it++) + for (auto it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); it++) { if (it->ifaceAddr == ifaceAddr) { @@ -466,7 +457,7 @@ OlsrState::FindIfaceAssocTuple(const Ipv4Address& ifaceAddr) const void OlsrState::EraseIfaceAssocTuple(const IfaceAssocTuple& tuple) { - for (IfaceAssocSet::iterator it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); it++) + for (auto it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); it++) { if (*it == tuple) { @@ -486,8 +477,7 @@ std::vector OlsrState::FindNeighborInterfaces(const Ipv4Address& neighborMainAddr) const { std::vector retval; - for (IfaceAssocSet::const_iterator it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); - it++) + for (auto it = m_ifaceAssocSet.begin(); it != m_ifaceAssocSet.end(); it++) { if (it->mainAddr == neighborMainAddr) { @@ -504,7 +494,7 @@ OlsrState::FindAssociationTuple(const Ipv4Address& gatewayAddr, const Ipv4Address& networkAddr, const Ipv4Mask& netmask) { - for (AssociationSet::iterator it = m_associationSet.begin(); it != m_associationSet.end(); it++) + for (auto it = m_associationSet.begin(); it != m_associationSet.end(); it++) { if (it->gatewayAddr == gatewayAddr and it->networkAddr == networkAddr and it->netmask == netmask) @@ -518,7 +508,7 @@ OlsrState::FindAssociationTuple(const Ipv4Address& gatewayAddr, void OlsrState::EraseAssociationTuple(const AssociationTuple& tuple) { - for (AssociationSet::iterator it = m_associationSet.begin(); it != m_associationSet.end(); it++) + for (auto it = m_associationSet.begin(); it != m_associationSet.end(); it++) { if (*it == tuple) { @@ -537,7 +527,7 @@ OlsrState::InsertAssociationTuple(const AssociationTuple& tuple) void OlsrState::EraseAssociation(const Association& tuple) { - for (Associations::iterator it = m_associations.begin(); it != m_associations.end(); it++) + for (auto it = m_associations.begin(); it != m_associations.end(); it++) { if (*it == tuple) { diff --git a/src/olsr/test/hello-regression-test.cc b/src/olsr/test/hello-regression-test.cc index 4af8deca5..e359a7a54 100644 --- a/src/olsr/test/hello-regression-test.cc +++ b/src/olsr/test/hello-regression-test.cc @@ -139,8 +139,7 @@ HelloRegressionTest::ReceivePktProbeA(Ptr socket) "One Link message on the second and third Hello."); } - std::vector::const_iterator iter; - for (iter = hello.linkMessages.begin(); iter != hello.linkMessages.end(); iter++) + for (auto iter = hello.linkMessages.begin(); iter != hello.linkMessages.end(); iter++) { if (m_countA == 1) { @@ -193,8 +192,7 @@ HelloRegressionTest::ReceivePktProbeB(Ptr socket) "One Link message on the second and third Hello."); } - std::vector::const_iterator iter; - for (iter = hello.linkMessages.begin(); iter != hello.linkMessages.end(); iter++) + for (auto iter = hello.linkMessages.begin(); iter != hello.linkMessages.end(); iter++) { if (m_countA == 1) { diff --git a/src/openflow/model/openflow-interface.cc b/src/openflow/model/openflow-interface.cc index 7481073b1..a74c1e70e 100644 --- a/src/openflow/model/openflow-interface.cc +++ b/src/openflow/model/openflow-interface.cc @@ -158,7 +158,7 @@ int Stats::FlowStatsInit(const void* body, int body_len, void** state) { const ofp_flow_stats_request* fsr = (ofp_flow_stats_request*)body; - FlowStatsState* s = (FlowStatsState*)xmalloc(sizeof *s); + auto s = (FlowStatsState*)xmalloc(sizeof *s); s->table_idx = fsr->table_id == 0xff ? 0 : fsr->table_id; memset(&s->position, 0, sizeof s->position); @@ -170,7 +170,7 @@ Stats::FlowStatsInit(const void* body, int body_len, void** state) int Stats_FlowDumpCallback(sw_flow* flow, void* state) { - Stats::FlowStatsState* s = (Stats::FlowStatsState*)state; + auto s = (Stats::FlowStatsState*)state; // Fill Flow Stats ofp_flow_stats* ofs; @@ -325,7 +325,7 @@ Stats::PortTableStatsDump(Ptr swtch, void* state, ofpbu int Stats::PortStatsInit(const void* body, int body_len, void** state) { - PortStatsState* s = (PortStatsState*)xmalloc(sizeof *s); + auto s = (PortStatsState*)xmalloc(sizeof *s); // the body contains a list of port numbers s->ports = (uint32_t*)xmalloc(body_len); @@ -878,7 +878,7 @@ LearningController::ReceiveFromSwitch(Ptr swtch, ofpbuf dst_addr.CopyFrom(key.flow.dl_dst); if (!dst_addr.IsBroadcast()) { - LearnState_t::iterator st = m_learnState.find(dst_addr); + auto st = m_learnState.find(dst_addr); if (st != m_learnState.end()) { out_port = st->second.port; @@ -915,7 +915,7 @@ LearningController::ReceiveFromSwitch(Ptr swtch, ofpbuf // We can learn a specific port for the source address for future use. Mac48Address src_addr; src_addr.CopyFrom(key.flow.dl_src); - LearnState_t::iterator st = m_learnState.find(src_addr); + auto st = m_learnState.find(src_addr); if (st == m_learnState.end()) // We haven't learned our source MAC yet. { LearnedState ls; @@ -963,7 +963,7 @@ ExecuteActions(Ptr swtch, int prev_port; size_t max_len = 0; // Initialize to make compiler happy uint16_t in_port = key->flow.in_port; // ntohs(key->flow.in_port); - uint8_t* p = (uint8_t*)actions; + auto p = (uint8_t*)actions; prev_port = -1; @@ -1022,7 +1022,7 @@ ExecuteActions(Ptr swtch, uint16_t ValidateActions(const sw_flow_key* key, const ofp_action_header* actions, size_t actions_len) { - uint8_t* p = (uint8_t*)actions; + auto p = (uint8_t*)actions; int err; while (actions_len >= sizeof(ofp_action_header)) @@ -1088,7 +1088,7 @@ ExecuteVPortActions(Ptr swtch, int prev_port; size_t max_len = 0; // Initialize to make compiler happy uint16_t in_port = ntohs(key->flow.in_port); - uint8_t* p = (uint8_t*)actions; + auto p = (uint8_t*)actions; uint16_t type; ofp_action_output* oa; @@ -1130,7 +1130,7 @@ ExecuteVPortActions(Ptr swtch, uint16_t ValidateVPortActions(const ofp_action_header* actions, size_t actions_len) { - uint8_t* p = (uint8_t*)actions; + auto p = (uint8_t*)actions; int err; while (actions_len >= sizeof(ofp_action_header)) diff --git a/src/openflow/model/openflow-switch-net-device.cc b/src/openflow/model/openflow-switch-net-device.cc index 822c3fa86..e546c9d0b 100644 --- a/src/openflow/model/openflow-switch-net-device.cc +++ b/src/openflow/model/openflow-switch-net-device.cc @@ -137,7 +137,7 @@ OpenFlowSwitchNetDevice::DoDispose() { NS_LOG_FUNCTION_NOARGS(); - for (Ports_t::iterator b = m_ports.begin(), e = m_ports.end(); b != e; b++) + for (auto b = m_ports.begin(), e = m_ports.end(); b != e; b++) { SendPortStatus(*b, OFPPR_DELETE); b->netdev = nullptr; diff --git a/src/point-to-point-layout/model/point-to-point-dumbbell.cc b/src/point-to-point-layout/model/point-to-point-dumbbell.cc index 52432c3f2..4dbfee001 100644 --- a/src/point-to-point-layout/model/point-to-point-dumbbell.cc +++ b/src/point-to-point-layout/model/point-to-point-dumbbell.cc @@ -191,7 +191,7 @@ PointToPointDumbbellHelper::AssignIpv6Addresses(Ipv6Address addrBase, Ipv6Prefix ndc.Add(m_leftLeafDevices.Get(i)); ndc.Add(m_leftRouterDevices.Get(i)); Ipv6InterfaceContainer ifc = addressHelper.Assign(ndc); - Ipv6InterfaceContainer::Iterator it = ifc.Begin(); + auto it = ifc.Begin(); m_leftLeafInterfaces6.Add((*it).first, (*it).second); it++; m_leftRouterInterfaces6.Add((*it).first, (*it).second); @@ -207,7 +207,7 @@ PointToPointDumbbellHelper::AssignIpv6Addresses(Ipv6Address addrBase, Ipv6Prefix ndc.Add(m_rightLeafDevices.Get(i)); ndc.Add(m_rightRouterDevices.Get(i)); Ipv6InterfaceContainer ifc = addressHelper.Assign(ndc); - Ipv6InterfaceContainer::Iterator it = ifc.Begin(); + auto it = ifc.Begin(); m_rightLeafInterfaces6.Add((*it).first, (*it).second); it++; m_rightRouterInterfaces6.Add((*it).first, (*it).second); diff --git a/src/propagation/examples/main-propagation-loss.cc b/src/propagation/examples/main-propagation-loss.cc index fc68317aa..53a12d2f8 100644 --- a/src/propagation/examples/main-propagation-loss.cc +++ b/src/propagation/examples/main-propagation-loss.cc @@ -174,7 +174,7 @@ TestProbabilistic(Ptr model, Simulator::Run(); } - for (rxPowerMapType::const_iterator i = rxPowerMap.begin(); i != rxPowerMap.end(); ++i) + for (auto i = rxPowerMap.begin(); i != rxPowerMap.end(); ++i) { dataset.Add(distance, i->first, (double)i->second / (double)samples); } diff --git a/src/propagation/model/propagation-cache.h b/src/propagation/model/propagation-cache.h index 526bd3ee7..a05c5623c 100644 --- a/src/propagation/model/propagation-cache.h +++ b/src/propagation/model/propagation-cache.h @@ -48,7 +48,7 @@ class PropagationCache Ptr GetPathData(Ptr a, Ptr b, uint32_t modelUid) { PropagationPathIdentifier key = PropagationPathIdentifier(a, b, modelUid); - typename PathCache::iterator it = m_pathCache.find(key); + auto it = m_pathCache.find(key); if (it == m_pathCache.end()) { return nullptr; diff --git a/src/propagation/model/propagation-loss-model.cc b/src/propagation/model/propagation-loss-model.cc index 116149a55..309e60fbb 100644 --- a/src/propagation/model/propagation-loss-model.cc +++ b/src/propagation/model/propagation-loss-model.cc @@ -747,7 +747,7 @@ NakagamiPropagationLossModel::DoCalcRxPower(double txPowerDbm, // switch between Erlang- and Gamma distributions: this is only for // speed. (Gamma is equal to Erlang for any positive integer m.) - unsigned int int_m = static_cast(std::floor(m)); + auto int_m = static_cast(std::floor(m)); if (int_m == m) { @@ -869,7 +869,7 @@ MatrixPropagationLossModel::SetLoss(Ptr ma, NS_ASSERT(ma && mb); MobilityPair p = std::make_pair(ma, mb); - std::map::iterator i = m_loss.find(p); + auto i = m_loss.find(p); if (i == m_loss.end()) { @@ -891,7 +891,7 @@ MatrixPropagationLossModel::DoCalcRxPower(double txPowerDbm, Ptr a, Ptr b) const { - std::map::const_iterator i = m_loss.find(std::make_pair(a, b)); + auto i = m_loss.find(std::make_pair(a, b)); if (i != m_loss.end()) { diff --git a/src/sixlowpan/helper/sixlowpan-helper.cc b/src/sixlowpan/helper/sixlowpan-helper.cc index 74ab70a60..703808b4f 100644 --- a/src/sixlowpan/helper/sixlowpan-helper.cc +++ b/src/sixlowpan/helper/sixlowpan-helper.cc @@ -140,7 +140,7 @@ SixLowPanHelper::AssignStreams(NetDeviceContainer c, int64_t stream) { int64_t currentStream = stream; Ptr netDevice; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { netDevice = (*i); Ptr dev = DynamicCast(netDevice); diff --git a/src/sixlowpan/model/sixlowpan-net-device.cc b/src/sixlowpan/model/sixlowpan-net-device.cc index 080cb7a9c..c509b61c0 100644 --- a/src/sixlowpan/model/sixlowpan-net-device.cc +++ b/src/sixlowpan/model/sixlowpan-net-device.cc @@ -192,7 +192,7 @@ SixLowPanNetDevice::DoDispose() m_timeoutEvent.Cancel(); } - for (MapFragmentsI_t iter = m_fragments.begin(); iter != m_fragments.end(); iter++) + for (auto iter = m_fragments.begin(); iter != m_fragments.end(); iter++) { iter->second = nullptr; } @@ -666,9 +666,8 @@ SixLowPanNetDevice::DoSend(Ptr packet, // fragment std::list> fragmentList; DoFragmentation(packet, origPacketSize, origHdrSize, extraHdrSize, fragmentList); - std::list>::iterator it; bool success = true; - for (it = fragmentList.begin(); it != fragmentList.end(); it++) + for (auto it = fragmentList.begin(); it != fragmentList.end(); it++) { NS_LOG_DEBUG("SixLowPanNetDevice::Send (Fragment) " << **it); m_txTrace(*it, this, GetIfIndex()); @@ -2343,7 +2342,7 @@ SixLowPanNetDevice::DoFragmentation(Ptr packet, uint32_t packetSize = packet->GetSize(); uint32_t compressedHeaderSize = packetSize - (origPacketSize - origHdrSize); - uint16_t tag = uint16_t(m_rng->GetValue(0, 65535)); + auto tag = static_cast(m_rng->GetValue(0, 65535)); NS_LOG_LOGIC("random tag " << tag << " - test " << packetSize); // first fragment @@ -2474,18 +2473,17 @@ SixLowPanNetDevice::ProcessFragment(Ptr& packet, Ptr fragments; - MapFragments_t::iterator it = m_fragments.find(key); + auto it = m_fragments.find(key); if (it == m_fragments.end()) { // erase the oldest packet. if (m_fragmentReassemblyListSize && (m_fragments.size() >= m_fragmentReassemblyListSize)) { - FragmentsTimeoutsListI_t iter = m_timeoutEventList.begin(); + auto iter = m_timeoutEventList.begin(); FragmentKey_t oldestKey = std::get<1>(*iter); std::list> storedFragments = m_fragments[oldestKey]->GetFragments(); - for (std::list>::iterator fragIter = storedFragments.begin(); - fragIter != storedFragments.end(); + for (auto fragIter = storedFragments.begin(); fragIter != storedFragments.end(); fragIter++) { m_dropTrace(DROP_FRAGMENT_BUFFER_FULL, *fragIter, this, GetIfIndex()); @@ -2500,7 +2498,7 @@ SixLowPanNetDevice::ProcessFragment(Ptr& packet, m_fragments.insert(std::make_pair(key, fragments)); uint32_t ifIndex = GetIfIndex(); - FragmentsTimeoutsListI_t iter = SetTimeout(key, ifIndex); + auto iter = SetTimeout(key, ifIndex); fragments->SetTimeoutIter(iter); } else @@ -2592,9 +2590,7 @@ SixLowPanNetDevice::Fragments::IsEntire() const if (ret) { - for (std::list, uint16_t>>::const_iterator it = m_fragments.begin(); - it != m_fragments.end(); - it++) + for (auto it = m_fragments.begin(); it != m_fragments.end(); it++) { // overlapping fragments should not exist NS_LOG_LOGIC("Checking overlaps " << lastEndOffset << " - " << it->second); @@ -2618,7 +2614,7 @@ SixLowPanNetDevice::Fragments::GetPacket() const { NS_LOG_FUNCTION(this); - std::list, uint16_t>>::const_iterator it = m_fragments.begin(); + auto it = m_fragments.begin(); Ptr p = Create(); uint16_t lastEndOffset = 0; @@ -2655,8 +2651,7 @@ std::list> SixLowPanNetDevice::Fragments::GetFragments() const { std::list> fragments; - std::list, uint16_t>>::const_iterator iter; - for (iter = m_fragments.begin(); iter != m_fragments.end(); iter++) + for (auto iter = m_fragments.begin(); iter != m_fragments.end(); iter++) { fragments.push_back(iter->first); } @@ -2680,11 +2675,9 @@ SixLowPanNetDevice::HandleFragmentsTimeout(FragmentKey_t key, uint32_t iif) { NS_LOG_FUNCTION(this); - MapFragments_t::iterator it = m_fragments.find(key); + auto it = m_fragments.find(key); std::list> storedFragments = it->second->GetFragments(); - for (std::list>::iterator fragIter = storedFragments.begin(); - fragIter != storedFragments.end(); - fragIter++) + for (auto fragIter = storedFragments.begin(); fragIter != storedFragments.end(); fragIter++) { m_dropTrace(DROP_FRAGMENT_TIMEOUT, *fragIter, this, iif); } @@ -2719,7 +2712,7 @@ SixLowPanNetDevice::SetTimeout(FragmentKey_t key, uint32_t iif) } m_timeoutEventList.emplace_back(Simulator::Now() + m_fragmentExpirationTimeout, key, iif); - SixLowPanNetDevice::FragmentsTimeoutsListI_t iter = --m_timeoutEventList.end(); + auto iter = --m_timeoutEventList.end(); return (iter); } diff --git a/src/spectrum/examples/adhoc-aloha-ideal-phy-matrix-propagation-loss-model.cc b/src/spectrum/examples/adhoc-aloha-ideal-phy-matrix-propagation-loss-model.cc index 22ac384a2..b49b2bf2b 100644 --- a/src/spectrum/examples/adhoc-aloha-ideal-phy-matrix-propagation-loss-model.cc +++ b/src/spectrum/examples/adhoc-aloha-ideal-phy-matrix-propagation-loss-model.cc @@ -110,14 +110,9 @@ GlobalPathlossDatabase::UpdatePathloss(std::string context, void GlobalPathlossDatabase::Print() { - for (std::map>::const_iterator txit = - m_pathlossMap.begin(); - txit != m_pathlossMap.end(); - ++txit) + for (auto txit = m_pathlossMap.begin(); txit != m_pathlossMap.end(); ++txit) { - for (std::map::const_iterator rxit = txit->second.begin(); - rxit != txit->second.end(); - ++rxit) + for (auto rxit = txit->second.begin(); rxit != txit->second.end(); ++rxit) { std::cout << txit->first << " --> " << rxit->first << " : " << rxit->second << " dB" << std::endl; diff --git a/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.cc b/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.cc index 02e3ab28d..0180995fc 100644 --- a/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.cc +++ b/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.cc @@ -91,7 +91,7 @@ NetDeviceContainer AdhocAlohaNoackIdealPhyHelper::Install(NodeContainer c) const { NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; diff --git a/src/spectrum/helper/spectrum-analyzer-helper.cc b/src/spectrum/helper/spectrum-analyzer-helper.cc index bba571203..a4d74f981 100644 --- a/src/spectrum/helper/spectrum-analyzer-helper.cc +++ b/src/spectrum/helper/spectrum-analyzer-helper.cc @@ -51,8 +51,8 @@ WriteAveragePowerSpectralDensityReport(Ptr streamWrapper, std::ostream* ostream = streamWrapper->GetStream(); if (ostream->good()) { - Bands::const_iterator fi = avgPowerSpectralDensity->ConstBandsBegin(); - Values::const_iterator vi = avgPowerSpectralDensity->ConstValuesBegin(); + auto fi = avgPowerSpectralDensity->ConstBandsBegin(); + auto vi = avgPowerSpectralDensity->ConstValuesBegin(); while (fi != avgPowerSpectralDensity->ConstBandsEnd()) { NS_ASSERT(vi != avgPowerSpectralDensity->ConstValuesEnd()); @@ -126,7 +126,7 @@ SpectrumAnalyzerHelper::Install(NodeContainer c) const { NS_LOG_FUNCTION(this); NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; diff --git a/src/spectrum/helper/tv-spectrum-transmitter-helper.cc b/src/spectrum/helper/tv-spectrum-transmitter-helper.cc index 36161452f..311206a39 100644 --- a/src/spectrum/helper/tv-spectrum-transmitter-helper.cc +++ b/src/spectrum/helper/tv-spectrum-transmitter-helper.cc @@ -133,7 +133,7 @@ TvSpectrumTransmitterHelper::Install(NodeContainer nodeCont) NS_LOG_FUNCTION(this); NetDeviceContainer devCont; // iterate over node container to make one transmitter for each given node - for (NodeContainer::Iterator i = nodeCont.Begin(); i != nodeCont.End(); ++i) + for (auto i = nodeCont.Begin(); i != nodeCont.End(); ++i) { Ptr node = *i; Ptr phy = m_factory.Create()->GetObject(); @@ -193,7 +193,7 @@ TvSpectrumTransmitterHelper::Install(NodeContainer nodeCont, Region region, uint japanEndFrequencies[channelNumber] - japanStartFrequencies[channelNumber]; } // iterate over node container to make one transmitter for each given node - for (NodeContainer::Iterator i = nodeCont.Begin(); i != nodeCont.End(); ++i) + for (auto i = nodeCont.Begin(); i != nodeCont.End(); ++i) { Ptr node = *i; Ptr phy = m_factory.Create()->GetObject(); @@ -226,7 +226,7 @@ TvSpectrumTransmitterHelper::InstallAdjacent(NodeContainer nodeCont) DoubleValue startFrequency; DoubleValue channelBandwidth; // iterate over node container to make one transmitter for each given node - for (NodeContainer::Iterator i = nodeCont.Begin(); i != nodeCont.End(); ++i) + for (auto i = nodeCont.Begin(); i != nodeCont.End(); ++i) { Ptr node = *i; Ptr phy = m_factory.Create()->GetObject(); @@ -265,7 +265,7 @@ TvSpectrumTransmitterHelper::InstallAdjacent(NodeContainer nodeCont, uint16_t currChannelNumber; int index = 0; // iterate over node container to make one transmitter for each given node - for (NodeContainer::Iterator i = nodeCont.Begin(); i != nodeCont.End(); ++i) + for (auto i = nodeCont.Begin(); i != nodeCont.End(); ++i) { currChannelNumber = channelNumber + index; if (region == REGION_NORTH_AMERICA) @@ -461,7 +461,7 @@ TvSpectrumTransmitterHelper::InstallRandomRegionalTransmitters( tvNode.Create(1); mobility.Install(tvNode); // set channel number for this transmitter - uint16_t channelNumber = (uint16_t)transmitterIndicesToCreate.front(); + auto channelNumber = (uint16_t)transmitterIndicesToCreate.front(); Install(tvNode, region, channelNumber); // install tv transmitter transmitterLocations.pop_front(); // remove created transmitter location transmitterIndicesToCreate.pop_front(); // remove created transmitter index diff --git a/src/spectrum/helper/waveform-generator-helper.cc b/src/spectrum/helper/waveform-generator-helper.cc index ccd6e4506..5b91d40cf 100644 --- a/src/spectrum/helper/waveform-generator-helper.cc +++ b/src/spectrum/helper/waveform-generator-helper.cc @@ -82,7 +82,7 @@ NetDeviceContainer WaveformGeneratorHelper::Install(NodeContainer c) const { NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Ptr node = *i; diff --git a/src/spectrum/model/constant-spectrum-propagation-loss.cc b/src/spectrum/model/constant-spectrum-propagation-loss.cc index 06928622a..8e1b60306 100644 --- a/src/spectrum/model/constant-spectrum-propagation-loss.cc +++ b/src/spectrum/model/constant-spectrum-propagation-loss.cc @@ -84,8 +84,8 @@ ConstantSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity( NS_LOG_FUNCTION(this); Ptr rxPsd = Copy(params->psd); - Values::iterator vit = rxPsd->ValuesBegin(); - Bands::const_iterator fit = rxPsd->ConstBandsBegin(); + auto vit = rxPsd->ValuesBegin(); + auto fit = rxPsd->ConstBandsBegin(); while (vit != rxPsd->ValuesEnd()) { diff --git a/src/spectrum/model/friis-spectrum-propagation-loss.cc b/src/spectrum/model/friis-spectrum-propagation-loss.cc index 92fd489c8..dddb2090c 100644 --- a/src/spectrum/model/friis-spectrum-propagation-loss.cc +++ b/src/spectrum/model/friis-spectrum-propagation-loss.cc @@ -55,8 +55,8 @@ FriisSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity( Ptr b) const { Ptr rxPsd = Copy(params->psd); - Values::iterator vit = rxPsd->ValuesBegin(); - Bands::const_iterator fit = rxPsd->ConstBandsBegin(); + auto vit = rxPsd->ValuesBegin(); + auto fit = rxPsd->ConstBandsBegin(); NS_ASSERT(a); NS_ASSERT(b); diff --git a/src/spectrum/model/multi-model-spectrum-channel.cc b/src/spectrum/model/multi-model-spectrum-channel.cc index 00df775da..19031abf8 100644 --- a/src/spectrum/model/multi-model-spectrum-channel.cc +++ b/src/spectrum/model/multi-model-spectrum-channel.cc @@ -58,10 +58,9 @@ NS_OBJECT_ENSURE_REGISTERED(MultiModelSpectrumChannel); std::ostream& operator<<(std::ostream& lhs, TxSpectrumModelInfoMap_t& rhs) { - for (TxSpectrumModelInfoMap_t::iterator it = rhs.begin(); it != rhs.end(); ++it) + for (auto it = rhs.begin(); it != rhs.end(); ++it) { - SpectrumConverterMap_t::iterator jt; - for (jt = it->second.m_spectrumConverterMap.begin(); + for (auto jt = it->second.m_spectrumConverterMap.begin(); jt != it->second.m_spectrumConverterMap.end(); ++jt) { @@ -117,7 +116,7 @@ MultiModelSpectrumChannel::RemoveRx(Ptr phy) // we need to scan for all rxSpectrumModel values since we don't // know which spectrum model the phy had when it was previously added // (it's probably different than the current one) - for (RxSpectrumModelInfoMap_t::iterator rxInfoIterator = m_rxSpectrumModelInfoMap.begin(); + for (auto rxInfoIterator = m_rxSpectrumModelInfoMap.begin(); rxInfoIterator != m_rxSpectrumModelInfoMap.end(); ++rxInfoIterator) { @@ -160,7 +159,7 @@ MultiModelSpectrumChannel::AddRx(Ptr phy) if (inserted) { // create the necessary converters for all the TX spectrum models that we know of - for (TxSpectrumModelInfoMap_t::iterator txInfoIterator = m_txSpectrumModelInfoMap.begin(); + for (auto txInfoIterator = m_txSpectrumModelInfoMap.begin(); txInfoIterator != m_txSpectrumModelInfoMap.end(); ++txInfoIterator) { @@ -173,8 +172,7 @@ MultiModelSpectrumChannel::AddRx(Ptr phy) NS_LOG_LOGIC("Creating converter between SpectrumModelUid " << txSpectrumModel->GetUid() << " and " << rxSpectrumModelUid); SpectrumConverter converter(txSpectrumModel, rxSpectrumModel); - std::pair ret2; - ret2 = txInfoIterator->second.m_spectrumConverterMap.insert( + auto ret2 = txInfoIterator->second.m_spectrumConverterMap.insert( std::make_pair(rxSpectrumModelUid, converter)); NS_ASSERT(ret2.second); } @@ -188,22 +186,19 @@ MultiModelSpectrumChannel::FindAndEventuallyAddTxSpectrumModel( { NS_LOG_FUNCTION(this << txSpectrumModel); SpectrumModelUid_t txSpectrumModelUid = txSpectrumModel->GetUid(); - TxSpectrumModelInfoMap_t::iterator txInfoIterator = - m_txSpectrumModelInfoMap.find(txSpectrumModelUid); + auto txInfoIterator = m_txSpectrumModelInfoMap.find(txSpectrumModelUid); if (txInfoIterator == m_txSpectrumModelInfoMap.end()) { // first time we see this TX SpectrumModel // we add it to the list - std::pair ret; - ret = m_txSpectrumModelInfoMap.insert( + auto ret = m_txSpectrumModelInfoMap.insert( std::make_pair(txSpectrumModelUid, TxSpectrumModelInfo(txSpectrumModel))); NS_ASSERT(ret.second); txInfoIterator = ret.first; // and we create the converters for all the RX SpectrumModels that we know of - for (RxSpectrumModelInfoMap_t::const_iterator rxInfoIterator = - m_rxSpectrumModelInfoMap.begin(); + for (auto rxInfoIterator = m_rxSpectrumModelInfoMap.begin(); rxInfoIterator != m_rxSpectrumModelInfoMap.end(); ++rxInfoIterator) { @@ -217,8 +212,7 @@ MultiModelSpectrumChannel::FindAndEventuallyAddTxSpectrumModel( << txSpectrumModelUid << " and " << rxSpectrumModelUid); SpectrumConverter converter(txSpectrumModel, rxSpectrumModel); - std::pair ret2; - ret2 = txInfoIterator->second.m_spectrumConverterMap.insert( + auto ret2 = txInfoIterator->second.m_spectrumConverterMap.insert( std::make_pair(rxSpectrumModelUid, converter)); NS_ASSERT(ret2.second); } @@ -248,7 +242,7 @@ MultiModelSpectrumChannel::StartTx(Ptr txParams) NS_LOG_LOGIC("txSpectrumModelUid " << txSpectrumModelUid); // - TxSpectrumModelInfoMap_t::const_iterator txInfoIteratorerator = + auto txInfoIteratorerator = FindAndEventuallyAddTxSpectrumModel(txParams->psd->GetSpectrumModel()); NS_ASSERT(txInfoIteratorerator != m_txSpectrumModelInfoMap.end()); @@ -258,7 +252,7 @@ MultiModelSpectrumChannel::StartTx(Ptr txParams) NS_LOG_LOGIC("converter map first element: " << txInfoIteratorerator->second.m_spectrumConverterMap.begin()->first); - for (RxSpectrumModelInfoMap_t::const_iterator rxInfoIterator = m_rxSpectrumModelInfoMap.begin(); + for (auto rxInfoIterator = m_rxSpectrumModelInfoMap.begin(); rxInfoIterator != m_rxSpectrumModelInfoMap.end(); ++rxInfoIterator) { @@ -275,7 +269,7 @@ MultiModelSpectrumChannel::StartTx(Ptr txParams) { NS_LOG_LOGIC("converting txPowerSpectrum SpectrumModelUids " << txSpectrumModelUid << " --> " << rxSpectrumModelUid); - SpectrumConverterMap_t::const_iterator rxConverterIterator = + auto rxConverterIterator = txInfoIteratorerator->second.m_spectrumConverterMap.find(rxSpectrumModelUid); if (rxConverterIterator == txInfoIteratorerator->second.m_spectrumConverterMap.end()) { @@ -452,7 +446,7 @@ MultiModelSpectrumChannel::GetDevice(std::size_t i) const // On the other hand, having slow SpectrumModel conversion would be // less acceptable. std::size_t j = 0; - for (RxSpectrumModelInfoMap_t::const_iterator rxInfoIterator = m_rxSpectrumModelInfoMap.begin(); + for (auto rxInfoIterator = m_rxSpectrumModelInfoMap.begin(); rxInfoIterator != m_rxSpectrumModelInfoMap.end(); ++rxInfoIterator) { diff --git a/src/spectrum/model/multi-model-spectrum-channel.h b/src/spectrum/model/multi-model-spectrum-channel.h index deeb88b1e..b485eb96e 100644 --- a/src/spectrum/model/multi-model-spectrum-channel.h +++ b/src/spectrum/model/multi-model-spectrum-channel.h @@ -128,7 +128,7 @@ class MultiModelSpectrumChannel : public SpectrumChannel * This method checks if m_rxSpectrumModelInfoMap contains an entry * for the given TX SpectrumModel. If such entry exists, it returns * an iterator pointing to it. If not, it creates a new entry in - * m_txSpectrumMpodelInfoMap, and returns an iterator to it. + * m_txSpectrumModelInfoMap, and returns an iterator to it. * * \param txSpectrumModel The TX SpectrumModel being considered * diff --git a/src/spectrum/model/single-model-spectrum-channel.cc b/src/spectrum/model/single-model-spectrum-channel.cc index 5ecab6398..e4c93dafc 100644 --- a/src/spectrum/model/single-model-spectrum-channel.cc +++ b/src/spectrum/model/single-model-spectrum-channel.cc @@ -119,9 +119,7 @@ SingleModelSpectrumChannel::StartTx(Ptr txParams) Ptr senderMobility = txParams->txPhy->GetMobility(); - for (PhyList::const_iterator rxPhyIterator = m_phyList.begin(); - rxPhyIterator != m_phyList.end(); - ++rxPhyIterator) + for (auto rxPhyIterator = m_phyList.begin(); rxPhyIterator != m_phyList.end(); ++rxPhyIterator) { Ptr rxNetDevice = (*rxPhyIterator)->GetDevice(); Ptr txNetDevice = txParams->txPhy->GetDevice(); diff --git a/src/spectrum/model/spectrum-converter.cc b/src/spectrum/model/spectrum-converter.cc index 7b8f9f9c9..cd737e855 100644 --- a/src/spectrum/model/spectrum-converter.cc +++ b/src/spectrum/model/spectrum-converter.cc @@ -41,13 +41,10 @@ SpectrumConverter::SpectrumConverter(Ptr fromSpectrumModel, m_toSpectrumModel = toSpectrumModel; size_t rowPtr = 0; - for (Bands::const_iterator toit = toSpectrumModel->Begin(); toit != toSpectrumModel->End(); - ++toit) + for (auto toit = toSpectrumModel->Begin(); toit != toSpectrumModel->End(); ++toit) { size_t colInd = 0; - for (Bands::const_iterator fromit = fromSpectrumModel->Begin(); - fromit != fromSpectrumModel->End(); - ++fromit) + for (auto fromit = fromSpectrumModel->Begin(); fromit != fromSpectrumModel->End(); ++fromit) { double c = GetCoefficient(*fromit, *toit); NS_LOG_LOGIC("(" << fromit->fl << "," << fromit->fh << ")" @@ -83,12 +80,10 @@ SpectrumConverter::Convert(Ptr fvvf) const Ptr tvvf = Create(m_toSpectrumModel); - Values::iterator tvit = tvvf->ValuesBegin(); + auto tvit = tvvf->ValuesBegin(); size_t i = 0; // Index of conversion coefficient - for (std::vector::const_iterator convIt = m_conversionRowPtr.begin(); - convIt != m_conversionRowPtr.end(); - ++convIt) + for (auto convIt = m_conversionRowPtr.begin(); convIt != m_conversionRowPtr.end(); ++convIt) { double sum = 0; while (i < *convIt) diff --git a/src/spectrum/model/spectrum-error-model.cc b/src/spectrum/model/spectrum-error-model.cc index 3cd7db2be..8bad21200 100644 --- a/src/spectrum/model/spectrum-error-model.cc +++ b/src/spectrum/model/spectrum-error-model.cc @@ -79,8 +79,8 @@ ShannonSpectrumErrorModel::EvaluateChunk(const SpectrumValue& sinr, Time duratio SpectrumValue CapacityPerHertz = Log2(1 + sinr); double capacity = 0; - Bands::const_iterator bi = CapacityPerHertz.ConstBandsBegin(); - Values::const_iterator vi = CapacityPerHertz.ConstValuesBegin(); + auto bi = CapacityPerHertz.ConstBandsBegin(); + auto vi = CapacityPerHertz.ConstValuesBegin(); while (bi != CapacityPerHertz.ConstBandsEnd()) { diff --git a/src/spectrum/model/spectrum-model.cc b/src/spectrum/model/spectrum-model.cc index 548f33847..caf688852 100644 --- a/src/spectrum/model/spectrum-model.cc +++ b/src/spectrum/model/spectrum-model.cc @@ -44,8 +44,7 @@ SpectrumModel::SpectrumModel(const std::vector& centerFreqs) NS_ASSERT(centerFreqs.size() > 1); m_uid = ++m_uidCount; - for (std::vector::const_iterator it = centerFreqs.begin(); it != centerFreqs.end(); - ++it) + for (auto it = centerFreqs.begin(); it != centerFreqs.end(); ++it) { BandInfo e; e.fc = *it; @@ -111,9 +110,9 @@ SpectrumModel::GetUid() const bool SpectrumModel::IsOrthogonal(const SpectrumModel& other) const { - for (Bands::const_iterator myIt = Begin(); myIt != End(); ++myIt) + for (auto myIt = Begin(); myIt != End(); ++myIt) { - for (Bands::const_iterator otherIt = other.Begin(); otherIt != other.End(); ++otherIt) + for (auto otherIt = other.Begin(); otherIt != other.End(); ++otherIt) { if (std::max(myIt->fl, otherIt->fl) < std::min(myIt->fh, otherIt->fh)) { diff --git a/src/spectrum/model/spectrum-value.cc b/src/spectrum/model/spectrum-value.cc index 922e6c487..47134bfe9 100644 --- a/src/spectrum/model/spectrum-value.cc +++ b/src/spectrum/model/spectrum-value.cc @@ -101,8 +101,8 @@ SpectrumValue::ConstBandsEnd() const void SpectrumValue::Add(const SpectrumValue& x) { - Values::iterator it1 = m_values.begin(); - Values::const_iterator it2 = x.m_values.begin(); + auto it1 = m_values.begin(); + auto it2 = x.m_values.begin(); NS_ASSERT(m_spectrumModel == x.m_spectrumModel); NS_ASSERT(m_values.size() == x.m_values.size()); @@ -118,7 +118,7 @@ SpectrumValue::Add(const SpectrumValue& x) void SpectrumValue::Add(double s) { - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -130,8 +130,8 @@ SpectrumValue::Add(double s) void SpectrumValue::Subtract(const SpectrumValue& x) { - Values::iterator it1 = m_values.begin(); - Values::const_iterator it2 = x.m_values.begin(); + auto it1 = m_values.begin(); + auto it2 = x.m_values.begin(); NS_ASSERT(m_spectrumModel == x.m_spectrumModel); NS_ASSERT(m_values.size() == x.m_values.size()); @@ -153,8 +153,8 @@ SpectrumValue::Subtract(double s) void SpectrumValue::Multiply(const SpectrumValue& x) { - Values::iterator it1 = m_values.begin(); - Values::const_iterator it2 = x.m_values.begin(); + auto it1 = m_values.begin(); + auto it2 = x.m_values.begin(); NS_ASSERT(m_spectrumModel == x.m_spectrumModel); NS_ASSERT(m_values.size() == x.m_values.size()); @@ -170,7 +170,7 @@ SpectrumValue::Multiply(const SpectrumValue& x) void SpectrumValue::Multiply(double s) { - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -182,8 +182,8 @@ SpectrumValue::Multiply(double s) void SpectrumValue::Divide(const SpectrumValue& x) { - Values::iterator it1 = m_values.begin(); - Values::const_iterator it2 = x.m_values.begin(); + auto it1 = m_values.begin(); + auto it2 = x.m_values.begin(); NS_ASSERT(m_spectrumModel == x.m_spectrumModel); NS_ASSERT(m_values.size() == x.m_values.size()); @@ -200,7 +200,7 @@ void SpectrumValue::Divide(double s) { NS_LOG_FUNCTION(this << s); - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -212,7 +212,7 @@ SpectrumValue::Divide(double s) void SpectrumValue::ChangeSign() { - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -257,7 +257,7 @@ void SpectrumValue::Pow(double exp) { NS_LOG_FUNCTION(this << exp); - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -270,7 +270,7 @@ void SpectrumValue::Exp(double base) { NS_LOG_FUNCTION(this << base); - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -283,7 +283,7 @@ void SpectrumValue::Log10() { NS_LOG_FUNCTION(this); - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -296,7 +296,7 @@ void SpectrumValue::Log2() { NS_LOG_FUNCTION(this); - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -309,7 +309,7 @@ void SpectrumValue::Log() { NS_LOG_FUNCTION(this); - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { @@ -322,7 +322,7 @@ double Norm(const SpectrumValue& x) { double s = 0; - Values::const_iterator it1 = x.ConstValuesBegin(); + auto it1 = x.ConstValuesBegin(); while (it1 != x.ConstValuesEnd()) { s += (*it1) * (*it1); @@ -335,7 +335,7 @@ double Sum(const SpectrumValue& x) { double s = 0; - Values::const_iterator it1 = x.ConstValuesBegin(); + auto it1 = x.ConstValuesBegin(); while (it1 != x.ConstValuesEnd()) { s += (*it1); @@ -348,7 +348,7 @@ double Prod(const SpectrumValue& x) { double s = 0; - Values::const_iterator it1 = x.ConstValuesBegin(); + auto it1 = x.ConstValuesBegin(); while (it1 != x.ConstValuesEnd()) { s *= (*it1); @@ -361,8 +361,8 @@ double Integral(const SpectrumValue& arg) { double i = 0; - Values::const_iterator vit = arg.ConstValuesBegin(); - Bands::const_iterator bit = arg.ConstBandsBegin(); + auto vit = arg.ConstValuesBegin(); + auto bit = arg.ConstBandsBegin(); while (vit != arg.ConstValuesEnd()) { NS_ASSERT(bit != arg.ConstBandsEnd()); @@ -393,7 +393,7 @@ SpectrumValue::Copy() const std::ostream& operator<<(std::ostream& os, const SpectrumValue& pvf) { - Values::const_iterator it1 = pvf.ConstValuesBegin(); + auto it1 = pvf.ConstValuesBegin(); while (it1 != pvf.ConstValuesEnd()) { os << *it1 << " "; @@ -613,7 +613,7 @@ SpectrumValue::operator/=(double rhs) SpectrumValue& SpectrumValue::operator=(double rhs) { - Values::iterator it1 = m_values.begin(); + auto it1 = m_values.begin(); while (it1 != m_values.end()) { diff --git a/src/spectrum/model/trace-fading-loss-model.cc b/src/spectrum/model/trace-fading-loss-model.cc index 20cafc194..e0e284501 100644 --- a/src/spectrum/model/trace-fading-loss-model.cc +++ b/src/spectrum/model/trace-fading-loss-model.cc @@ -153,9 +153,8 @@ TraceFadingLossModel::DoCalcRxPowerSpectralDensity(Ptrpsd << a << b); - std::map::iterator itOff; ChannelRealizationId_t mobilityPair = std::make_pair(a, b); - itOff = m_windowOffsetsMap.find(mobilityPair); + auto itOff = m_windowOffsetsMap.find(mobilityPair); if (itOff != m_windowOffsetsMap.end()) { if (Simulator::Now().GetSeconds() >= @@ -163,11 +162,10 @@ TraceFadingLossModel::DoCalcRxPowerSpectralDensity(Ptr::iterator itOff2; - for (itOff2 = m_windowOffsetsMap.begin(); itOff2 != m_windowOffsetsMap.end(); itOff2++) + for (auto itOff2 = m_windowOffsetsMap.begin(); itOff2 != m_windowOffsetsMap.end(); + itOff2++) { - std::map>::iterator itVar; - itVar = m_startVariableMap.find((*itOff2).first); + auto itVar = m_startVariableMap.find((*itOff2).first); (*itOff2).second = (*itVar).second->GetValue(); } m_lastWindowUpdate = Simulator::Now(); @@ -199,7 +197,7 @@ TraceFadingLossModel::DoCalcRxPowerSpectralDensity(Ptr rxPsd = Copy(params->psd); - Values::iterator vit = rxPsd->ValuesBegin(); + auto vit = rxPsd->ValuesBegin(); // Vector aSpeedVector = a->GetVelocity (); // Vector bSpeedVector = b->GetVelocity (); @@ -247,8 +245,7 @@ TraceFadingLossModel::AssignStreams(int64_t stream) m_streamsAssigned = true; m_currentStream = stream; m_lastStream = stream + m_streamSetSize - 1; - std::map>::iterator itVar; - itVar = m_startVariableMap.begin(); + auto itVar = m_startVariableMap.begin(); // the following loop is for eventually pre-existing ChannelRealization instances // note that more instances are expected to be created at run time while (itVar != m_startVariableMap.end()) diff --git a/src/spectrum/model/tv-spectrum-transmitter.cc b/src/spectrum/model/tv-spectrum-transmitter.cc index 9802ac8f9..53ab65cde 100644 --- a/src/spectrum/model/tv-spectrum-transmitter.cc +++ b/src/spectrum/model/tv-spectrum-transmitter.cc @@ -246,7 +246,7 @@ TvSpectrumTransmitter::CreateTvPsd() NS_ASSERT(m_channelBandwidth != 0); Ptr model; TvSpectrumModelId key(m_startFrequency, m_channelBandwidth); - std::map>::iterator iter = g_tvSpectrumModelMap.find(key); + auto iter = g_tvSpectrumModelMap.find(key); if (iter != g_tvSpectrumModelMap.end()) { model = iter->second; // set SpectrumModel to previously created one diff --git a/src/spectrum/model/wifi-spectrum-value-helper.cc b/src/spectrum/model/wifi-spectrum-value-helper.cc index 7ba35919e..5fb9244ac 100644 --- a/src/spectrum/model/wifi-spectrum-value-helper.cc +++ b/src/spectrum/model/wifi-spectrum-value-helper.cc @@ -77,8 +77,7 @@ WifiSpectrumValueHelper::GetSpectrumModel(uint32_t centerFrequency, NS_LOG_FUNCTION(centerFrequency << channelWidth << carrierSpacing << guardBandwidth); Ptr ret; WifiSpectrumModelId key{centerFrequency, channelWidth, carrierSpacing, guardBandwidth}; - std::map>::iterator it = - g_wifiSpectrumModelMap.find(key); + auto it = g_wifiSpectrumModelMap.find(key); if (it != g_wifiSpectrumModelMap.end()) { ret = it->second; @@ -89,7 +88,7 @@ WifiSpectrumValueHelper::GetSpectrumModel(uint32_t centerFrequency, double centerFrequencyHz = centerFrequency * 1e6; double bandwidth = (channelWidth + (2.0 * guardBandwidth)) * 1e6; // For OFDM, the center subcarrier is null (at center frequency) - uint32_t numBands = static_cast((bandwidth / carrierSpacing) + 0.5); + auto numBands = static_cast((bandwidth / carrierSpacing) + 0.5); NS_ASSERT(numBands > 0); if (numBands % 2 == 0) { @@ -134,11 +133,10 @@ WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity(uint32_t centerFrequen uint32_t carrierSpacing = 312500; Ptr c = Create( GetSpectrumModel(centerFrequency, channelWidth, carrierSpacing, guardBandwidth)); - Values::iterator vit = c->ValuesBegin(); - Bands::const_iterator bit = c->ConstBandsBegin(); - uint32_t nGuardBands = - static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); - uint32_t nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); + auto vit = c->ValuesBegin(); + auto bit = c->ConstBandsBegin(); + auto nGuardBands = static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); + auto nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); NS_ASSERT(c->GetSpectrumModel()->GetNumBands() == (nAllocatedBands + nGuardBands + 1)); // Evenly spread power across 22 MHz double txPowerPerBand = txPowerW / nAllocatedBands; @@ -188,9 +186,8 @@ WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity(uint32_t centerFrequen Ptr c = Create( GetSpectrumModel(centerFrequency, channelWidth, carrierSpacing, guardBandwidth)); - uint32_t nGuardBands = - static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); - uint32_t nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); + auto nGuardBands = static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); + auto nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); NS_ASSERT_MSG(c->GetSpectrumModel()->GetNumBands() == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel()->GetNumBands()); // 52 subcarriers (48 data + 4 pilot) @@ -240,9 +237,8 @@ WifiSpectrumValueHelper::CreateDuplicated20MhzTxPowerSpectralDensity( uint32_t carrierSpacing = 312500; Ptr c = Create( GetSpectrumModel(centerFrequency, channelWidth, carrierSpacing, guardBandwidth)); - uint32_t nGuardBands = - static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); - uint32_t nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); + auto nGuardBands = static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); + auto nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); NS_ASSERT_MSG(c->GetSpectrumModel()->GetNumBands() == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel()->GetNumBands()); std::size_t num20MhzBands = channelWidth / 20; @@ -281,7 +277,7 @@ WifiSpectrumValueHelper::CreateDuplicated20MhzTxPowerSpectralDensity( } // Prepare spectrum mask specific variables - uint32_t innerSlopeWidth = static_cast( + auto innerSlopeWidth = static_cast( (2e6 / carrierSpacing) + 0.5); // size in number of subcarriers of the 0dBr<->20dBr slope (2MHz for HT/VHT) WifiSpectrumBandIndices maskBand(0, nAllocatedBands + nGuardBands); @@ -315,9 +311,8 @@ WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity(uint32_t centerFrequ uint32_t carrierSpacing = 312500; Ptr c = Create( GetSpectrumModel(centerFrequency, channelWidth, carrierSpacing, guardBandwidth)); - uint32_t nGuardBands = - static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); - uint32_t nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); + auto nGuardBands = static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); + auto nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); NS_ASSERT_MSG(c->GetSpectrumModel()->GetNumBands() == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel()->GetNumBands()); std::size_t num20MhzBands = channelWidth / 20; @@ -347,7 +342,7 @@ WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity(uint32_t centerFrequ } // Prepare spectrum mask specific variables - uint32_t innerSlopeWidth = static_cast( + auto innerSlopeWidth = static_cast( (2e6 / carrierSpacing) + 0.5); // size in number of subcarriers of the inner band (2MHz for HT/VHT) WifiSpectrumBandIndices maskBand(0, nAllocatedBands + nGuardBands); @@ -383,9 +378,8 @@ WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity( uint32_t carrierSpacing = 78125; Ptr c = Create( GetSpectrumModel(centerFrequency, channelWidth, carrierSpacing, guardBandwidth)); - uint32_t nGuardBands = - static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); - uint32_t nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); + auto nGuardBands = static_cast(((2 * guardBandwidth * 1e6) / carrierSpacing) + 0.5); + auto nAllocatedBands = static_cast(((channelWidth * 1e6) / carrierSpacing) + 0.5); NS_ASSERT_MSG(c->GetSpectrumModel()->GetNumBands() == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel()->GetNumBands()); double txPowerPerBandW = 0.0; @@ -398,7 +392,7 @@ WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity( uint32_t start4; uint32_t stop4; // Prepare spectrum mask specific variables - uint32_t innerSlopeWidth = static_cast( + auto innerSlopeWidth = static_cast( (1e6 / carrierSpacing) + 0.5); // size in number of subcarriers of the inner band std::vector subBands; // list of data/pilot-containing subBands (sent at 0dBr) @@ -468,7 +462,7 @@ WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity( } // Create punctured bands - uint32_t puncturedSlopeWidth = + auto puncturedSlopeWidth = static_cast((500e3 / carrierSpacing) + 0.5); // size in number of subcarriers of the punctured slope band std::vector puncturedBands; @@ -516,8 +510,8 @@ WifiSpectrumValueHelper::CreateHeMuOfdmTxPowerSpectralDensity(uint32_t centerFre GetSpectrumModel(centerFrequency, channelWidth, carrierSpacing, guardBandwidth)); // Build spectrum mask - Values::iterator vit = c->ValuesBegin(); - Bands::const_iterator bit = c->ConstBandsBegin(); + auto vit = c->ValuesBegin(); + auto bit = c->ConstBandsBegin(); double txPowerPerBandW = (txPowerW / (ru.second - ru.first + 1)); // FIXME: null subcarriers uint32_t numBands = c->GetSpectrumModel()->GetNumBands(); for (size_t i = 0; i < numBands; i++, vit++, bit++) @@ -655,8 +649,8 @@ WifiSpectrumValueHelper::CreateSpectrumMaskForOfdm( double puncturedSlope = (-1 * minInnerBandDbr) / puncturedSlopeWidth; // Build spectrum mask - Values::iterator vit = c->ValuesBegin(); - Bands::const_iterator bit = c->ConstBandsBegin(); + auto vit = c->ValuesBegin(); + auto bit = c->ConstBandsBegin(); double txPowerW = 0.0; double previousTxPowerW = 0.0; for (size_t i = 0; i < numBands; i++, vit++, bit++) @@ -780,7 +774,7 @@ WifiSpectrumValueHelper::NormalizeSpectrumMask(Ptr c, double txPo double normalizationRatio = currentTxPowerW / txPowerW; NS_LOG_LOGIC("Current power: " << currentTxPowerW << "W vs expected power: " << txPowerW << "W" << " -> ratio (C/E) = " << normalizationRatio); - Values::iterator vit = c->ValuesBegin(); + auto vit = c->ValuesBegin(); for (size_t i = 0; i < c->GetSpectrumModel()->GetNumBands(); i++, vit++) { *vit = (*vit) / normalizationRatio; diff --git a/src/spectrum/test/spectrum-test.h b/src/spectrum/test/spectrum-test.h index 2552c2d33..0ea9120ef 100644 --- a/src/spectrum/test/spectrum-test.h +++ b/src/spectrum/test/spectrum-test.h @@ -48,8 +48,8 @@ #define NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL(actual, expected, tol, msg) \ do \ { \ - Bands::const_iterator i = (actual).Begin(); \ - Bands::const_iterator j = (expected).Begin(); \ + auto i = (actual).Begin(); \ + auto j = (expected).Begin(); \ uint32_t k = 0; \ while (i != (actual).End() && j != (expected).End()) \ { \ @@ -113,8 +113,8 @@ #define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(actual, expected, tol, msg) \ do \ { \ - Values::const_iterator i = (actual).ConstValuesBegin(); \ - Values::const_iterator j = (expected).ConstValuesBegin(); \ + auto i = (actual).ConstValuesBegin(); \ + auto j = (expected).ConstValuesBegin(); \ uint32_t k = 0; \ while (i != (actual).ConstValuesEnd() && j != (expected).ConstValuesEnd()) \ { \ diff --git a/src/spectrum/test/tv-spectrum-transmitter-test.cc b/src/spectrum/test/tv-spectrum-transmitter-test.cc index 3f5b5079f..ec6b553ff 100644 --- a/src/spectrum/test/tv-spectrum-transmitter-test.cc +++ b/src/spectrum/test/tv-spectrum-transmitter-test.cc @@ -124,7 +124,7 @@ TvSpectrumTransmitterTestCase::DoRun() /* Test max PSD value */ Ptr psd = phy->GetTxPsd(); - Values::const_iterator psdIter = psd->ConstValuesBegin(); + auto psdIter = psd->ConstValuesBegin(); double maxValue = 0; while (psdIter != psd->ConstValuesEnd()) { @@ -154,8 +154,8 @@ TvSpectrumTransmitterTestCase::DoRun() } /* Test frequency range */ - Bands::const_iterator bandStart = psd->ConstBandsBegin(); - Bands::const_iterator bandEnd = psd->ConstBandsEnd(); + auto bandStart = psd->ConstBandsBegin(); + auto bandEnd = psd->ConstBandsEnd(); epsilon = TOLERANCE * std::max(1.0, std::max((*bandStart).fc, m_startFrequency)); NS_TEST_ASSERT_MSG_EQ_TOL((*bandStart).fc, m_startFrequency, diff --git a/src/stats/helper/file-helper.cc b/src/stats/helper/file-helper.cc index 45ebbe2ff..c3e0405fb 100644 --- a/src/stats/helper/file-helper.cc +++ b/src/stats/helper/file-helper.cc @@ -288,8 +288,7 @@ FileHelper::GetProbe(std::string probeName) const NS_LOG_FUNCTION(this << probeName); // Look for the probe. - std::map, std::string>>::const_iterator mapIterator = - m_probeMap.find(probeName); + auto mapIterator = m_probeMap.find(probeName); // Return the probe if it has been added. if (mapIterator != m_probeMap.end()) diff --git a/src/stats/helper/gnuplot-helper.cc b/src/stats/helper/gnuplot-helper.cc index 9de14be21..476467a4c 100644 --- a/src/stats/helper/gnuplot-helper.cc +++ b/src/stats/helper/gnuplot-helper.cc @@ -257,8 +257,7 @@ Ptr GnuplotHelper::GetProbe(std::string probeName) const { // Look for the probe. - std::map, std::string>>::const_iterator mapIterator = - m_probeMap.find(probeName); + auto mapIterator = m_probeMap.find(probeName); // Return the probe if it has been added. if (mapIterator != m_probeMap.end()) diff --git a/src/stats/model/gnuplot.cc b/src/stats/model/gnuplot.cc index 3b7891418..2ba37f9a2 100644 --- a/src/stats/model/gnuplot.cc +++ b/src/stats/model/gnuplot.cc @@ -293,7 +293,7 @@ Gnuplot2dDataset::Data2d::PrintExpression(std::ostream& os, void Gnuplot2dDataset::Data2d::PrintDataFile(std::ostream& os, bool generateOneOutputFile) const { - for (PointSet::const_iterator i = m_pointset.begin(); i != m_pointset.end(); ++i) + for (auto i = m_pointset.begin(); i != m_pointset.end(); ++i) { if (i->empty) { @@ -578,7 +578,7 @@ Gnuplot3dDataset::Data3d::PrintExpression(std::ostream& os, void Gnuplot3dDataset::Data3d::PrintDataFile(std::ostream& os, bool generateOneOutputFile) const { - for (PointSet::const_iterator i = m_pointset.begin(); i != m_pointset.end(); ++i) + for (auto i = m_pointset.begin(); i != m_pointset.end(); ++i) { if (i->empty) { @@ -852,7 +852,7 @@ Gnuplot::GenerateOutput(std::ostream& osControl, std::ostream& osData, std::stri std::string command = m_datasets.begin()->m_data->GetCommand(); - for (Datasets::const_iterator i = m_datasets.begin() + 1; i != m_datasets.end(); ++i) + for (auto i = m_datasets.begin() + 1; i != m_datasets.end(); ++i) { NS_ASSERT_MSG(command == i->m_data->GetCommand(), "Cannot mix 'plot' and 'splot' GnuplotDatasets."); @@ -863,7 +863,7 @@ Gnuplot::GenerateOutput(std::ostream& osControl, std::ostream& osData, std::stri // Print all dataset expressions bool isDataEmpty; - for (Datasets::const_iterator i = m_datasets.begin(); i != m_datasets.end();) + for (auto i = m_datasets.begin(); i != m_datasets.end();) { // Only print the dataset if it's not empty. isDataEmpty = i->m_data->IsEmpty(); @@ -889,7 +889,7 @@ Gnuplot::GenerateOutput(std::ostream& osControl, std::ostream& osData, std::stri // followed by the inline datafile. - for (Datasets::const_iterator i = m_datasets.begin(); i != m_datasets.end(); i++) + for (auto i = m_datasets.begin(); i != m_datasets.end(); i++) { i->m_data->PrintDataFile(osData, m_generateOneOutputFile); } @@ -950,7 +950,7 @@ GnuplotCollection::GenerateOutput(std::ostream& os) os << "set output \"" << m_outputFilename << "\"" << std::endl; } - for (Plots::iterator i = m_plots.begin(); i != m_plots.end(); ++i) + for (auto i = m_plots.begin(); i != m_plots.end(); ++i) { i->GenerateOutput(os); } @@ -974,7 +974,7 @@ GnuplotCollection::GenerateOutput(std::ostream& osControl, osControl << "set output \"" << m_outputFilename << "\"" << std::endl; } - for (Plots::iterator i = m_plots.begin(); i != m_plots.end(); ++i) + for (auto i = m_plots.begin(); i != m_plots.end(); ++i) { i->GenerateOutput(osControl, osData, dataFileName); } diff --git a/src/stats/model/histogram.cc b/src/stats/model/histogram.cc index b91e11982..1b0b3f9f6 100644 --- a/src/stats/model/histogram.cc +++ b/src/stats/model/histogram.cc @@ -80,7 +80,7 @@ Histogram::GetBinCount(uint32_t index) const void Histogram::AddValue(double value) { - uint32_t index = (uint32_t)std::floor(value / m_binWidth); + auto index = (uint32_t)std::floor(value / m_binWidth); // check if we need to resize the vector NS_LOG_DEBUG("AddValue: index=" << index << ", m_histogram.size()=" << m_histogram.size()); diff --git a/src/stats/model/omnet-data-output.cc b/src/stats/model/omnet-data-output.cc index b889f00d2..77e99be0e 100644 --- a/src/stats/model/omnet-data-output.cc +++ b/src/stats/model/omnet-data-output.cc @@ -75,7 +75,7 @@ isNumeric(const std::string& s) bool exponentSeen = false; char last = '\0'; - for (std::string::const_iterator it = s.begin(); it != s.end(); it++) + for (auto it = s.begin(); it != s.end(); it++) { if ((*it == '.') && (decimalPtSeen)) { @@ -120,7 +120,7 @@ OmnetDataOutput::Output(DataCollector& dc) scalarFile << "attr measurement \"" << dc.GetInputLabel() << "\"" << std::endl; scalarFile << "attr description \"" << dc.GetDescription() << "\"" << std::endl; - for (MetadataList::iterator i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++) + for (auto i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++) { std::pair blob = (*i); scalarFile << "attr \"" << blob.first << "\" \"" << blob.second << "\"" << std::endl; @@ -131,7 +131,7 @@ OmnetDataOutput::Output(DataCollector& dc) { scalarFile << "scalar . measurement \"" << dc.GetInputLabel() << "\"" << std::endl; } - for (MetadataList::iterator i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++) + for (auto i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++) { std::pair blob = (*i); if (isNumeric(blob.second)) @@ -142,8 +142,7 @@ OmnetDataOutput::Output(DataCollector& dc) } OmnetOutputCallback callback(&scalarFile); - for (DataCalculatorList::iterator i = dc.DataCalculatorBegin(); i != dc.DataCalculatorEnd(); - i++) + for (auto i = dc.DataCalculatorBegin(); i != dc.DataCalculatorEnd(); i++) { (*i)->Output(callback); } diff --git a/src/stats/model/sqlite-data-output.cc b/src/stats/model/sqlite-data-output.cc index 2d36baee8..66a69753b 100644 --- a/src/stats/model/sqlite-data-output.cc +++ b/src/stats/model/sqlite-data-output.cc @@ -116,7 +116,7 @@ SqliteDataOutput::Output(DataCollector& dc) "values (?, ?, ?)"); NS_ASSERT(res); - for (MetadataList::iterator i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++) + for (auto i = dc.MetadataBegin(); i != dc.MetadataEnd(); i++) { std::pair blob = (*i); m_sqliteOut->SpinReset(stmt); @@ -130,8 +130,7 @@ SqliteDataOutput::Output(DataCollector& dc) m_sqliteOut->SpinExec("BEGIN"); SqliteOutputCallback callback(m_sqliteOut, run); - for (DataCalculatorList::iterator i = dc.DataCalculatorBegin(); i != dc.DataCalculatorEnd(); - i++) + for (auto i = dc.DataCalculatorBegin(); i != dc.DataCalculatorEnd(); i++) { (*i)->Output(callback); } diff --git a/src/tap-bridge/model/tap-bridge.cc b/src/tap-bridge/model/tap-bridge.cc index 13b6b7e03..3c711af7f 100644 --- a/src/tap-bridge/model/tap-bridge.cc +++ b/src/tap-bridge/model/tap-bridge.cc @@ -57,7 +57,7 @@ TapBridgeFdReader::DoRead() NS_LOG_FUNCTION(this); uint32_t bufferSize = 65536; - uint8_t* buf = (uint8_t*)std::malloc(bufferSize); + auto buf = (uint8_t*)std::malloc(bufferSize); NS_ABORT_MSG_IF(buf == nullptr, "malloc() failed"); NS_LOG_LOGIC("Calling read on tap device fd " << m_fd); diff --git a/src/test/csma-system-test-suite.cc b/src/test/csma-system-test-suite.cc index a710da265..bc8c3977d 100644 --- a/src/test/csma-system-test-suite.cc +++ b/src/test/csma-system-test-suite.cc @@ -870,7 +870,7 @@ CsmaPingTestCase::DoRun() // Make packets be sent about every DefaultPacketSize / DataRate = // 4096 bits / (5000 bits/second) = 0.82 second. Config::SetDefault("ns3::Ipv4RawSocketImpl::Protocol", StringValue("2")); - InetSocketAddress dst = InetSocketAddress(addresses.GetAddress(3)); + InetSocketAddress dst(addresses.GetAddress(3)); OnOffHelper onoff = OnOffHelper("ns3::Ipv4RawSocketFactory", dst); onoff.SetConstantRate(DataRate(5000)); @@ -1004,7 +1004,7 @@ CsmaRawIpSocketTestCase::DoRun() // Make packets be sent about every DefaultPacketSize / DataRate = // 4096 bits / (5000 bits/second) = 0.82 second. Config::SetDefault("ns3::Ipv4RawSocketImpl::Protocol", StringValue("2")); - InetSocketAddress dst = InetSocketAddress(addresses.GetAddress(3)); + InetSocketAddress dst(addresses.GetAddress(3)); OnOffHelper onoff = OnOffHelper("ns3::Ipv4RawSocketFactory", dst); onoff.SetConstantRate(DataRate(5000)); diff --git a/src/test/ns3tc/pfifo-fast-queue-disc-test-suite.cc b/src/test/ns3tc/pfifo-fast-queue-disc-test-suite.cc index 39438598d..25d3dda0e 100644 --- a/src/test/ns3tc/pfifo-fast-queue-disc-test-suite.cc +++ b/src/test/ns3tc/pfifo-fast-queue-disc-test-suite.cc @@ -369,7 +369,7 @@ PfifoFastQueueDiscNoPriority::DoRun() 2, "unexpected queue depth"); p = Create(100); - uint8_t* buf = new uint8_t[100]; + auto buf = new uint8_t[100]; uint8_t counter = 0; for (uint32_t i = 0; i < 100; i++) { diff --git a/src/test/ns3tcp/ns3tcp-loss-test-suite.cc b/src/test/ns3tcp/ns3tcp-loss-test-suite.cc index 13c5a783e..9f9d96119 100644 --- a/src/test/ns3tcp/ns3tcp-loss-test-suite.cc +++ b/src/test/ns3tcp/ns3tcp-loss-test-suite.cc @@ -246,7 +246,7 @@ Ns3TcpLossTestCase::Ipv4L3Tx(std::string, Ptr packet, Ptr, u NS_LOG_INFO("read " << readLen << " bytes"); - uint8_t* actual = new uint8_t[readLen]; + auto actual = new uint8_t[readLen]; received->CopyData(actual, readLen); int result = memcmp(actual, expectedBuffer, readLen); diff --git a/src/test/ns3tcp/ns3tcp-state-test-suite.cc b/src/test/ns3tcp/ns3tcp-state-test-suite.cc index a6fa1203e..3da311d1c 100644 --- a/src/test/ns3tcp/ns3tcp-state-test-suite.cc +++ b/src/test/ns3tcp/ns3tcp-state-test-suite.cc @@ -252,7 +252,7 @@ Ns3TcpStateTestCase::Ipv4L3Tx(std::string, Ptr packet, Ptr, NS_LOG_INFO("read " << readLen << " bytes"); - uint8_t* actual = new uint8_t[readLen]; + auto actual = new uint8_t[readLen]; received->CopyData(actual, readLen); int result = memcmp(actual, expectedBuffer, readLen); diff --git a/src/topology-read/examples/topology-example-sim.cc b/src/topology-read/examples/topology-example-sim.cc index 07321bcfb..710dc9704 100644 --- a/src/topology-read/examples/topology-example-sim.cc +++ b/src/topology-read/examples/topology-example-sim.cc @@ -122,7 +122,7 @@ main(int argc, char* argv[]) int totlinks = inFile->LinksSize(); NS_LOG_INFO("creating node containers"); - NodeContainer* nc = new NodeContainer[totlinks]; + auto nc = new NodeContainer[totlinks]; TopologyReader::ConstLinksIterator iter; int i = 0; for (iter = inFile->LinksBegin(); iter != inFile->LinksEnd(); iter++, i++) @@ -131,7 +131,7 @@ main(int argc, char* argv[]) } NS_LOG_INFO("creating net device containers"); - NetDeviceContainer* ndc = new NetDeviceContainer[totlinks]; + auto ndc = new NetDeviceContainer[totlinks]; PointToPointHelper p2p; for (int i = 0; i < totlinks; i++) { @@ -143,7 +143,7 @@ main(int argc, char* argv[]) // it crates little subnets, one for each couple of nodes. NS_LOG_INFO("creating IPv4 interfaces"); - Ipv4InterfaceContainer* ipic = new Ipv4InterfaceContainer[totlinks]; + auto ipic = new Ipv4InterfaceContainer[totlinks]; for (int i = 0; i < totlinks; i++) { ipic[i] = address.Assign(ndc[i]); @@ -166,7 +166,7 @@ main(int argc, char* argv[]) // -- Send around packets to check the ttl // -------------------------------------------- Config::SetDefault("ns3::Ipv4RawSocketImpl::Protocol", StringValue("2")); - InetSocketAddress dst = InetSocketAddress(ipv4AddrServer); + InetSocketAddress dst(ipv4AddrServer); OnOffHelper onoff = OnOffHelper("ns3::Ipv4RawSocketFactory", dst); onoff.SetConstantRate(DataRate(15000)); diff --git a/src/traffic-control/helper/queue-disc-container.cc b/src/traffic-control/helper/queue-disc-container.cc index 5c342e0d9..20571e7c9 100644 --- a/src/traffic-control/helper/queue-disc-container.cc +++ b/src/traffic-control/helper/queue-disc-container.cc @@ -58,7 +58,7 @@ QueueDiscContainer::Get(std::size_t i) const void QueueDiscContainer::Add(QueueDiscContainer other) { - for (ConstIterator i = other.Begin(); i != other.End(); i++) + for (auto i = other.Begin(); i != other.End(); i++) { m_queueDiscs.push_back(*i); } diff --git a/src/traffic-control/helper/traffic-control-helper.cc b/src/traffic-control/helper/traffic-control-helper.cc index d009cdaf5..b5be24053 100644 --- a/src/traffic-control/helper/traffic-control-helper.cc +++ b/src/traffic-control/helper/traffic-control-helper.cc @@ -71,17 +71,13 @@ QueueDiscFactory::CreateQueueDisc(const std::vector>& queueDiscs) Ptr qd = m_queueDiscFactory.Create(); // create and add the internal queues - for (std::vector::iterator i = m_internalQueuesFactory.begin(); - i != m_internalQueuesFactory.end(); - i++) + for (auto i = m_internalQueuesFactory.begin(); i != m_internalQueuesFactory.end(); i++) { qd->AddInternalQueue(i->Create()); } // create and add the packet filters - for (std::vector::iterator i = m_packetFiltersFactory.begin(); - i != m_packetFiltersFactory.end(); - i++) + for (auto i = m_packetFiltersFactory.begin(); i != m_packetFiltersFactory.end(); i++) { qd->AddPacketFilter(i->Create()); } @@ -182,7 +178,7 @@ TrafficControlHelper::DoAddChildQueueDisc(uint16_t handle, uint16_t classId, Obj NS_ABORT_MSG_IF(handle >= m_queueDiscFactory.size(), "A queue disc with handle " << handle << " does not exist"); - uint16_t childHandle = static_cast(m_queueDiscFactory.size()); + auto childHandle = static_cast(m_queueDiscFactory.size()); m_queueDiscFactory.emplace_back(factory); m_queueDiscFactory[handle].SetChildQueueDisc(classId, childHandle); @@ -195,7 +191,7 @@ TrafficControlHelper::DoAddChildQueueDiscs(uint16_t handle, ObjectFactory factory) { HandleList list; - for (ClassIdList::const_iterator c = classes.begin(); c != classes.end(); c++) + for (auto c = classes.begin(); c != classes.end(); c++) { uint16_t childHandle = DoAddChildQueueDisc(handle, *c, factory); list.push_back(childHandle); @@ -254,7 +250,7 @@ TrafficControlHelper::Install(NetDeviceContainer c) { QueueDiscContainer container; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { container.Add(Install(*i)); } @@ -283,7 +279,7 @@ TrafficControlHelper::Uninstall(Ptr d) void TrafficControlHelper::Uninstall(NetDeviceContainer c) { - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { Uninstall(*i); } diff --git a/src/traffic-control/model/pie-queue-disc.cc b/src/traffic-control/model/pie-queue-disc.cc index 01d1b7f04..d701f727a 100644 --- a/src/traffic-control/model/pie-queue-disc.cc +++ b/src/traffic-control/model/pie-queue-disc.cc @@ -437,7 +437,7 @@ PieQueueDisc::CalculateP() m_burstAllowance -= m_tUpdate; } - uint32_t burstResetLimit = static_cast(BURST_RESET_TIMEOUT / m_tUpdate.GetSeconds()); + auto burstResetLimit = static_cast(BURST_RESET_TIMEOUT / m_tUpdate.GetSeconds()); if ((qDelay.GetSeconds() < 0.5 * m_qDelayRef.GetSeconds()) && (m_qDelayOld.GetSeconds() < (0.5 * m_qDelayRef.GetSeconds())) && (m_dropProb == 0) && !missingInitFlag) diff --git a/src/traffic-control/model/queue-disc.cc b/src/traffic-control/model/queue-disc.cc index 0db2a831f..cad4f3b3a 100644 --- a/src/traffic-control/model/queue-disc.cc +++ b/src/traffic-control/model/queue-disc.cc @@ -178,9 +178,6 @@ QueueDisc::Stats::GetNMarkedBytes(std::string reason) const void QueueDisc::Stats::Print(std::ostream& os) const { - std::map::const_iterator itp; - std::map::const_iterator itb; - os << std::endl << "Packets/Bytes received: " << nTotalReceivedPackets << " / " << nTotalReceivedBytes << std::endl @@ -195,8 +192,8 @@ QueueDisc::Stats::Print(std::ostream& os) const << "Packets/Bytes dropped before enqueue: " << nTotalDroppedPacketsBeforeEnqueue << " / " << nTotalDroppedBytesBeforeEnqueue; - itp = nDroppedPacketsBeforeEnqueue.begin(); - itb = nDroppedBytesBeforeEnqueue.begin(); + auto itp = nDroppedPacketsBeforeEnqueue.begin(); + auto itb = nDroppedBytesBeforeEnqueue.begin(); while (itp != nDroppedPacketsBeforeEnqueue.end() && itb != nDroppedBytesBeforeEnqueue.end()) { @@ -403,8 +400,7 @@ QueueDisc::DoInitialize() InitializeParams(); // Check the configuration and initialize the parameters of the child queue discs - for (std::vector>::iterator cl = m_classes.begin(); cl != m_classes.end(); - cl++) + for (auto cl = m_classes.begin(); cl != m_classes.end(); cl++) { (*cl)->GetQueueDisc()->Initialize(); } @@ -673,9 +669,7 @@ QueueDisc::Classify(Ptr item) NS_LOG_FUNCTION(this << item); int32_t ret = PacketFilter::PF_NO_MATCH; - for (std::vector>::iterator f = m_filters.begin(); - f != m_filters.end() && ret == PacketFilter::PF_NO_MATCH; - f++) + for (auto f = m_filters.begin(); f != m_filters.end() && ret == PacketFilter::PF_NO_MATCH; f++) { ret = (*f)->Classify(item); } @@ -733,8 +727,7 @@ QueueDisc::DropBeforeEnqueue(Ptr item, const char* reason) m_stats.nTotalDroppedBytesBeforeEnqueue += item->GetSize(); // update the number of packets dropped for the given reason - std::map::iterator itp = - m_stats.nDroppedPacketsBeforeEnqueue.find(reason); + auto itp = m_stats.nDroppedPacketsBeforeEnqueue.find(reason); if (itp != m_stats.nDroppedPacketsBeforeEnqueue.end()) { itp->second++; @@ -744,7 +737,7 @@ QueueDisc::DropBeforeEnqueue(Ptr item, const char* reason) m_stats.nDroppedPacketsBeforeEnqueue[reason] = 1; } // update the amount of bytes dropped for the given reason - std::map::iterator itb = m_stats.nDroppedBytesBeforeEnqueue.find(reason); + auto itb = m_stats.nDroppedBytesBeforeEnqueue.find(reason); if (itb != m_stats.nDroppedBytesBeforeEnqueue.end()) { itb->second += item->GetSize(); @@ -773,8 +766,7 @@ QueueDisc::DropAfterDequeue(Ptr item, const char* reason) m_stats.nTotalDroppedBytesAfterDequeue += item->GetSize(); // update the number of packets dropped for the given reason - std::map::iterator itp = - m_stats.nDroppedPacketsAfterDequeue.find(reason); + auto itp = m_stats.nDroppedPacketsAfterDequeue.find(reason); if (itp != m_stats.nDroppedPacketsAfterDequeue.end()) { itp->second++; @@ -784,7 +776,7 @@ QueueDisc::DropAfterDequeue(Ptr item, const char* reason) m_stats.nDroppedPacketsAfterDequeue[reason] = 1; } // update the amount of bytes dropped for the given reason - std::map::iterator itb = m_stats.nDroppedBytesAfterDequeue.find(reason); + auto itb = m_stats.nDroppedBytesAfterDequeue.find(reason); if (itb != m_stats.nDroppedBytesAfterDequeue.end()) { itb->second += item->GetSize(); @@ -829,7 +821,7 @@ QueueDisc::Mark(Ptr item, const char* reason) m_stats.nTotalMarkedBytes += item->GetSize(); // update the number of packets marked for the given reason - std::map::iterator itp = m_stats.nMarkedPackets.find(reason); + auto itp = m_stats.nMarkedPackets.find(reason); if (itp != m_stats.nMarkedPackets.end()) { itp->second++; @@ -839,7 +831,7 @@ QueueDisc::Mark(Ptr item, const char* reason) m_stats.nMarkedPackets[reason] = 1; } // update the amount of bytes marked for the given reason - std::map::iterator itb = m_stats.nMarkedBytes.find(reason); + auto itb = m_stats.nMarkedBytes.find(reason); if (itb != m_stats.nMarkedBytes.end()) { itb->second += item->GetSize(); diff --git a/src/traffic-control/model/red-queue-disc.cc b/src/traffic-control/model/red-queue-disc.cc index 423b53ca7..b6372745c 100644 --- a/src/traffic-control/model/red-queue-disc.cc +++ b/src/traffic-control/model/red-queue-disc.cc @@ -763,7 +763,7 @@ double RedQueueDisc::ModifyP(double p, uint32_t size) { NS_LOG_FUNCTION(this << p << size); - double count1 = (double)m_count; + auto count1 = (double)m_count; if (GetMaxSize().GetUnit() == QueueSizeUnit::BYTES) { diff --git a/src/traffic-control/model/traffic-control-layer.cc b/src/traffic-control/model/traffic-control-layer.cc index 3bfb0010a..63b79860b 100644 --- a/src/traffic-control/model/traffic-control-layer.cc +++ b/src/traffic-control/model/traffic-control-layer.cc @@ -143,7 +143,7 @@ TrafficControlLayer::ScanDevices() Ptr ndqi = dev->GetObject(); NS_LOG_DEBUG("Pointer to NetDeviceQueueInterface: " << ndqi); - std::map, NetDeviceInfo>::iterator ndi = m_netDevices.find(dev); + auto ndi = m_netDevices.find(dev); if (ndi != m_netDevices.end()) { @@ -222,7 +222,7 @@ TrafficControlLayer::SetRootQueueDiscOnDevice(Ptr device, Ptr, NetDeviceInfo>::iterator ndi = m_netDevices.find(device); + auto ndi = m_netDevices.find(device); if (ndi == m_netDevices.end()) { @@ -244,7 +244,7 @@ TrafficControlLayer::GetRootQueueDiscOnDevice(Ptr device) const { NS_LOG_FUNCTION(this << device); - std::map, NetDeviceInfo>::const_iterator ndi = m_netDevices.find(device); + auto ndi = m_netDevices.find(device); if (ndi == m_netDevices.end()) { @@ -265,7 +265,7 @@ TrafficControlLayer::DeleteRootQueueDiscOnDevice(Ptr device) { NS_LOG_FUNCTION(this << device); - std::map, NetDeviceInfo>::iterator ndi = m_netDevices.find(device); + auto ndi = m_netDevices.find(device); NS_ASSERT_MSG(ndi != m_netDevices.end() && ndi->second.m_rootQueueDisc, "No root queue disc installed on device " << device); @@ -337,7 +337,7 @@ TrafficControlLayer::Receive(Ptr device, bool found = false; - for (ProtocolHandlerList::iterator i = m_handlers.begin(); i != m_handlers.end(); i++) + for (auto i = m_handlers.begin(); i != m_handlers.end(); i++) { if (!i->device || (i->device == device)) { @@ -365,7 +365,7 @@ TrafficControlLayer::Send(Ptr device, Ptr item) NS_LOG_DEBUG("Send packet to device " << device << " protocol number " << item->GetProtocol()); Ptr devQueueIface; - std::map, NetDeviceInfo>::iterator ndi = m_netDevices.find(device); + auto ndi = m_netDevices.find(device); if (ndi != m_netDevices.end()) { diff --git a/src/uan/examples/uan-6lowpan-example.cc b/src/uan/examples/uan-6lowpan-example.cc index 8b49a3f9d..4644cc0fb 100644 --- a/src/uan/examples/uan-6lowpan-example.cc +++ b/src/uan/examples/uan-6lowpan-example.cc @@ -131,7 +131,7 @@ UanExperiment::SetupCommunications() UanHelper uanHelper; NetDeviceContainer netDeviceContainer = uanHelper.Install(m_nodes, channel); EnergySourceContainer energySourceContainer; - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); while (node != m_nodes.End()) { energySourceContainer.Add((*node)->GetObject()->Get(0)); @@ -185,7 +185,7 @@ UanExperiment::PrintReceivedPacket(Ptr socket) void UanExperiment::SetupApplications() { - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); while (node != m_nodes.End()) { m_sockets[*node] = @@ -206,7 +206,7 @@ UanExperiment::SendPackets() { Ptr uniformRandomVariable = CreateObject(); - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); Ipv6Address dst = (*node)->GetObject()->GetInterface(1)->GetAddress(1).GetAddress(); node++; @@ -247,9 +247,7 @@ UanExperiment::Prepare() void UanExperiment::Teardown() { - std::map, Ptr>::iterator socket; - - for (socket = m_sockets.begin(); socket != m_sockets.end(); socket++) + for (auto socket = m_sockets.begin(); socket != m_sockets.end(); socket++) { socket->second->Close(); } diff --git a/src/uan/examples/uan-cw-example.cc b/src/uan/examples/uan-cw-example.cc index 658d96a36..4a617b2a4 100644 --- a/src/uan/examples/uan-cw-example.cc +++ b/src/uan/examples/uan-cw-example.cc @@ -106,7 +106,7 @@ void Experiment::UpdatePositions(NodeContainer& nodes) const { NS_LOG_DEBUG(Now().As(Time::S) << " Updating positions"); - NodeContainer::Iterator it = nodes.Begin(); + auto it = nodes.Begin(); Ptr uv = CreateObject(); for (; it != nodes.End(); it++) { diff --git a/src/uan/examples/uan-ipv4-example.cc b/src/uan/examples/uan-ipv4-example.cc index d4db2016a..b1343bc14 100644 --- a/src/uan/examples/uan-ipv4-example.cc +++ b/src/uan/examples/uan-ipv4-example.cc @@ -129,7 +129,7 @@ UanExperiment::SetupCommunications() UanHelper uanHelper; NetDeviceContainer netDeviceContainer = uanHelper.Install(m_nodes, channel); EnergySourceContainer energySourceContainer; - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); while (node != m_nodes.End()) { energySourceContainer.Add((*node)->GetObject()->Get(0)); @@ -176,7 +176,7 @@ UanExperiment::PrintReceivedPacket(Ptr socket) void UanExperiment::SetupApplications() { - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); while (node != m_nodes.End()) { m_sockets[*node] = @@ -197,7 +197,7 @@ UanExperiment::SendPackets() { Ptr uniformRandomVariable = CreateObject(); - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); Ipv4Address dst = (*node)->GetObject()->GetInterface(1)->GetAddress(0).GetLocal(); node++; @@ -238,9 +238,7 @@ UanExperiment::Prepare() void UanExperiment::Teardown() { - std::map, Ptr>::iterator socket; - - for (socket = m_sockets.begin(); socket != m_sockets.end(); socket++) + for (auto socket = m_sockets.begin(); socket != m_sockets.end(); socket++) { socket->second->Close(); } diff --git a/src/uan/examples/uan-ipv6-example.cc b/src/uan/examples/uan-ipv6-example.cc index 79e92a6e2..ed44d93ff 100644 --- a/src/uan/examples/uan-ipv6-example.cc +++ b/src/uan/examples/uan-ipv6-example.cc @@ -129,7 +129,7 @@ UanExperiment::SetupCommunications() UanHelper uanHelper; NetDeviceContainer netDeviceContainer = uanHelper.Install(m_nodes, channel); EnergySourceContainer energySourceContainer; - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); while (node != m_nodes.End()) { energySourceContainer.Add((*node)->GetObject()->Get(0)); @@ -180,7 +180,7 @@ UanExperiment::PrintReceivedPacket(Ptr socket) void UanExperiment::SetupApplications() { - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); while (node != m_nodes.End()) { m_sockets[*node] = @@ -201,7 +201,7 @@ UanExperiment::SendPackets() { Ptr uniformRandomVariable = CreateObject(); - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); Ipv6Address dst = (*node)->GetObject()->GetInterface(1)->GetAddress(1).GetAddress(); node++; @@ -242,9 +242,7 @@ UanExperiment::Prepare() void UanExperiment::Teardown() { - std::map, Ptr>::iterator socket; - - for (socket = m_sockets.begin(); socket != m_sockets.end(); socket++) + for (auto socket = m_sockets.begin(); socket != m_sockets.end(); socket++) { socket->second->Close(); } diff --git a/src/uan/examples/uan-raw-example.cc b/src/uan/examples/uan-raw-example.cc index a1e2c5dbb..ee58b382c 100644 --- a/src/uan/examples/uan-raw-example.cc +++ b/src/uan/examples/uan-raw-example.cc @@ -131,7 +131,7 @@ UanExperiment::SetupCommunications() UanHelper uanHelper; NetDeviceContainer netDeviceContainer = uanHelper.Install(m_nodes, channel); EnergySourceContainer energySourceContainer; - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); while (node != m_nodes.End()) { energySourceContainer.Add((*node)->GetObject()->Get(0)); @@ -165,7 +165,7 @@ UanExperiment::PrintReceivedPacket(Ptr socket) void UanExperiment::SetupApplications() { - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); PacketSocketHelper packetSocketHelper; while (node != m_nodes.End()) { @@ -187,7 +187,7 @@ UanExperiment::SendPackets() { Ptr uniformRandomVariable = CreateObject(); - NodeContainer::Iterator node = m_nodes.Begin(); + auto node = m_nodes.Begin(); Mac8Address dst = Mac8Address::ConvertFrom((*node)->GetDevice(0)->GetAddress()); node++; while (node != m_nodes.End()) @@ -230,9 +230,7 @@ UanExperiment::Prepare() void UanExperiment::Teardown() { - std::map, Ptr>::iterator socket; - - for (socket = m_sockets.begin(); socket != m_sockets.end(); socket++) + for (auto socket = m_sockets.begin(); socket != m_sockets.end(); socket++) { socket->second->Close(); } diff --git a/src/uan/helper/uan-helper.cc b/src/uan/helper/uan-helper.cc index 1c6992a87..1975540b6 100644 --- a/src/uan/helper/uan-helper.cc +++ b/src/uan/helper/uan-helper.cc @@ -113,7 +113,7 @@ UanHelper::EnableAscii(std::ostream& os, uint32_t nodeid, uint32_t deviceid) void UanHelper::EnableAscii(std::ostream& os, NetDeviceContainer d) { - for (NetDeviceContainer::Iterator i = d.Begin(); i != d.End(); ++i) + for (auto i = d.Begin(); i != d.End(); ++i) { Ptr dev = *i; EnableAscii(os, dev->GetNode()->GetId(), dev->GetIfIndex()); @@ -124,7 +124,7 @@ void UanHelper::EnableAscii(std::ostream& os, NodeContainer n) { NetDeviceContainer devs; - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; for (uint32_t j = 0; j < node->GetNDevices(); ++j) @@ -156,7 +156,7 @@ NetDeviceContainer UanHelper::Install(NodeContainer c, Ptr channel) const { NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { Ptr node = *i; @@ -193,7 +193,7 @@ UanHelper::AssignStreams(NetDeviceContainer c, int64_t stream) { int64_t currentStream = stream; Ptr netDevice; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { netDevice = (*i); Ptr uan = DynamicCast(netDevice); diff --git a/src/uan/model/uan-channel.cc b/src/uan/model/uan-channel.cc index 402e0da1c..8278ec9ee 100644 --- a/src/uan/model/uan-channel.cc +++ b/src/uan/model/uan-channel.cc @@ -84,7 +84,7 @@ UanChannel::Clear() return; } m_cleared = true; - UanDeviceList::iterator it = m_devList.begin(); + auto it = m_devList.begin(); for (; it != m_devList.end(); it++) { if (it->first) @@ -150,7 +150,7 @@ UanChannel::TxPacket(Ptr src, Ptr packet, double txPowerD Ptr senderMobility = nullptr; NS_LOG_DEBUG("Channel scheduling"); - for (UanDeviceList::const_iterator i = m_devList.begin(); i != m_devList.end(); i++) + for (auto i = m_devList.begin(); i != m_devList.end(); i++) { if (src == i->second) { @@ -160,7 +160,7 @@ UanChannel::TxPacket(Ptr src, Ptr packet, double txPowerD } NS_ASSERT(senderMobility); uint32_t j = 0; - UanDeviceList::const_iterator i = m_devList.begin(); + auto i = m_devList.begin(); for (; i != m_devList.end(); i++) { if (src != i->second) diff --git a/src/uan/model/uan-header-rc.cc b/src/uan/model/uan-header-rc.cc index ef992d4b0..f355fba80 100644 --- a/src/uan/model/uan-header-rc.cc +++ b/src/uan/model/uan-header-rc.cc @@ -607,7 +607,7 @@ UanHeaderRcAck::Serialize(Buffer::Iterator start) const { start.WriteU8(m_frameNo); start.WriteU8(GetNoNacks()); - std::set::iterator it = m_nackedFrames.begin(); + auto it = m_nackedFrames.begin(); for (; it != m_nackedFrames.end(); it++) { start.WriteU8(*it); @@ -635,7 +635,7 @@ UanHeaderRcAck::Print(std::ostream& os) const << " Nacked: "; if (GetNoNacks() > 0) { - std::set::iterator it = m_nackedFrames.begin(); + auto it = m_nackedFrames.begin(); os << (uint32_t)*it; it++; for (; it != m_nackedFrames.end(); it++) diff --git a/src/uan/model/uan-mac-cw.cc b/src/uan/model/uan-mac-cw.cc index 8cc84ec3b..fe906a903 100644 --- a/src/uan/model/uan-mac-cw.cc +++ b/src/uan/model/uan-mac-cw.cc @@ -151,7 +151,7 @@ UanMacCw::Enqueue(Ptr packet, uint16_t protocolNumber, const Address& de m_pktTx = packet; m_pktTxProt = GetTxModeIndex(); m_state = CCABUSY; - uint32_t cw = (uint32_t)m_rv->GetValue(0, m_cw); + auto cw = (uint32_t)m_rv->GetValue(0, m_cw); m_savedDelayS = cw * m_slotTime; m_sendTime = Simulator::Now() + m_savedDelayS; NS_LOG_DEBUG("Time " << Now().As(Time::S) << ": Addr " << GetAddress() diff --git a/src/uan/model/uan-mac-rc-gw.cc b/src/uan/model/uan-mac-rc-gw.cc index 5bd9141bc..1df6b5814 100644 --- a/src/uan/model/uan-mac-rc-gw.cc +++ b/src/uan/model/uan-mac-rc-gw.cc @@ -84,7 +84,7 @@ UanMacRcGw::Clear() m_phy = nullptr; } m_propDelay.clear(); - std::map::iterator it = m_ackData.begin(); + auto it = m_ackData.begin(); for (; it != m_ackData.end(); it++) { it->second.rxFrames.clear(); @@ -262,7 +262,7 @@ UanMacRcGw::ReceivePacket(Ptr pkt, double /* sinr */, UanTxMode mode) NS_LOG_DEBUG(Now().As(Time::S) << " GW storing reservation from " << ch.GetSrc() << " with length " << req.length); m_requests.insert(std::make_pair(ch.GetSrc(), req)); - std::map::iterator it = m_propDelay.find(ch.GetSrc()); + auto it = m_propDelay.find(ch.GetSrc()); if (it == m_propDelay.end()) { m_sortedRes.insert(std::make_pair(m_maxDelta, ch.GetSrc())); @@ -292,7 +292,7 @@ UanMacRcGw::ReceivePacket(Ptr pkt, double /* sinr */, UanTxMode mode) void UanMacRcGw::StartCycle() { - uint32_t numRts = static_cast(m_sortedRes.size()); + auto numRts = static_cast(m_sortedRes.size()); if (numRts) { @@ -309,7 +309,7 @@ UanMacRcGw::StartCycle() Time pDelay = Seconds(0); if (numRts > 0) { - std::map::iterator rit = m_requests.begin(); + auto rit = m_requests.begin(); for (; rit != m_requests.end(); rit++) { totalBytes += (*rit).second.length; @@ -408,7 +408,7 @@ UanMacRcGw::StartCycle() m_state = CTSING; Simulator::Schedule(nextEarliest, &UanMacRcGw::CycleStarted, this); - std::set>::iterator it = m_sortedRes.begin(); + auto it = m_sortedRes.begin(); Time minPdelay = (*it).first; Ptr cts = Create(); @@ -487,7 +487,7 @@ UanMacRcGw::EndCycle() Time ackTime = Seconds(m_ackSize * 8.0 / m_phy->GetMode(m_currentRateNum).GetDataRateBps()); - std::map::iterator it = m_ackData.begin(); + auto it = m_ackData.begin(); for (; it != m_ackData.end(); it++) { Mac8Address dest = (*it).first; @@ -507,7 +507,7 @@ UanMacRcGw::EndCycle() ch.SetType(UanMacRc::TYPE_ACK); UanHeaderRcAck ah; ah.SetFrameNo(data.frameNo); - std::list::iterator nit = toNack.begin(); + auto nit = toNack.begin(); for (; nit != toNack.end(); nit++) { ah.AddNackedFrame(static_cast(*nit)); @@ -598,7 +598,7 @@ UanMacRcGw::GetExpPdk() { uint32_t n = m_numNodes; std::vector pds; - std::map::iterator pdit = m_propDelay.begin(); + auto pdit = m_propDelay.begin(); for (; pdit != m_propDelay.end(); pdit++) { @@ -664,7 +664,7 @@ UanMacRcGw::CompExpMinIndex(uint32_t n, uint32_t k) double sum = 0; for (uint32_t i = 1; i <= n - k + 1; i++) { - double nChK = static_cast(NchooseK(n, k)); + auto nChK = static_cast(NchooseK(n, k)); double p = (nChK > 0) ? (static_cast(NchooseK(n - i, k - 1)) / nChK) : DBL_MAX; sum += p * i; } @@ -674,7 +674,7 @@ UanMacRcGw::CompExpMinIndex(uint32_t n, uint32_t k) double UanMacRcGw::ComputePiK(uint32_t a, uint32_t n, uint32_t k) { - double nck = (double)NchooseK(n, k); + auto nck = (double)NchooseK(n, k); return nck * std::pow((std::exp((double)a / (double)n) - 1.0), (double)k) * std::exp(-((double)a)); } diff --git a/src/uan/model/uan-mac-rc.cc b/src/uan/model/uan-mac-rc.cc index 4ef45b9eb..f6a5abbfc 100644 --- a/src/uan/model/uan-mac-rc.cc +++ b/src/uan/model/uan-mac-rc.cc @@ -73,8 +73,7 @@ Reservation::Reservation(std::list, Mac8Address>>& list, Reservation::~Reservation() { - std::list, Mac8Address>>::iterator it; - for (it = m_pktList.begin(); it != m_pktList.end(); it++) + for (auto it = m_pktList.begin(); it != m_pktList.end(); it++) { it->first = Ptr((Packet*)nullptr); } @@ -185,8 +184,7 @@ UanMacRc::Clear() m_phy->Clear(); m_phy = nullptr; } - std::list, Mac8Address>>::iterator it; - for (it = m_pktQueue.begin(); it != m_pktQueue.end(); it++) + for (auto it = m_pktQueue.begin(); it != m_pktQueue.end(); it++) { it->first = nullptr; } @@ -424,7 +422,7 @@ UanMacRc::ScheduleData(const UanHeaderRcCts& ctsh, { NS_ASSERT(m_state == RTSSENT || m_state == GWPSENT); - std::list::iterator it = m_resList.begin(); + auto it = m_resList.begin(); for (; it != m_resList.end(); it++) { if (it->GetFrameNo() == ctsh.GetFrameNo()) @@ -455,8 +453,7 @@ UanMacRc::ScheduleData(const UanHeaderRcCts& ctsh, Time frameDelay = Seconds(0); const std::list, Mac8Address>> l = it->GetPktList(); - std::list, Mac8Address>>::const_iterator pit; - pit = l.begin(); + auto pit = l.begin(); for (uint8_t i = 0; i < it->GetNoFrames(); i++, pit++) { @@ -544,7 +541,7 @@ UanMacRc::ProcessAck(Ptr ack) UanHeaderRcAck ah; ack->RemoveHeader(ah); - std::list::iterator it = m_resList.begin(); + auto it = m_resList.begin(); for (; it != m_resList.end(); it++) { if (it->GetFrameNo() == ah.GetFrameNo()) @@ -565,11 +562,10 @@ UanMacRc::ProcessAck(Ptr ack) if (ah.GetNoNacks() > 0) { const std::list, Mac8Address>> l = it->GetPktList(); - std::list, Mac8Address>>::const_iterator pit; - pit = l.begin(); + auto pit = l.begin(); const std::set& nacks = ah.GetNackedFrames(); - std::set::iterator nit = nacks.begin(); + auto nit = nacks.begin(); uint8_t pnum = 0; for (; nit != nacks.end(); nit++) { diff --git a/src/uan/model/uan-phy-dual.cc b/src/uan/model/uan-phy-dual.cc index 52a4aa190..4985b5e09 100644 --- a/src/uan/model/uan-phy-dual.cc +++ b/src/uan/model/uan-phy-dual.cc @@ -79,7 +79,7 @@ UanPhyCalcSinrDual::CalcSinrDb(Ptr pkt, } double intKp = -DbToKp(rxPowerDb); // This packet is in the arrivalList - UanTransducer::ArrivalList::const_iterator it = arrivalList.begin(); + auto it = arrivalList.begin(); for (; it != arrivalList.end(); it++) { // Only count interference if there is overlap in incoming frequency diff --git a/src/uan/model/uan-phy-gen.cc b/src/uan/model/uan-phy-gen.cc index 506d27853..257a4f5a2 100644 --- a/src/uan/model/uan-phy-gen.cc +++ b/src/uan/model/uan-phy-gen.cc @@ -83,7 +83,7 @@ UanPhyCalcSinrDefault::CalcSinrDb(Ptr pkt, } double intKp = -DbToKp(rxPowerDb); // This packet is in the arrivalList - UanTransducer::ArrivalList::const_iterator it = arrivalList.begin(); + auto it = arrivalList.begin(); for (; it != arrivalList.end(); it++) { intKp += DbToKp(it->GetRxPowerDb()); @@ -143,7 +143,7 @@ UanPhyCalcSinrFhFsk::CalcSinrDb(Ptr pkt, // Get maximum arrival offset double maxAmp = -1; Time maxTapDelay(0); - UanPdp::Iterator pit = pdp.GetBegin(); + auto pit = pdp.GetBegin(); for (; pit != pdp.GetEnd(); pit++) { if (std::abs(pit->GetAmp()) > maxAmp) @@ -161,7 +161,7 @@ UanPhyCalcSinrFhFsk::CalcSinrDb(Ptr pkt, // eq. 14 double isiUpa = DbToKp(rxPowerDb) * pdp.SumTapsFromMaxNc(ts + clearingTime, ts); // added DpToKp() - UanTransducer::ArrivalList::const_iterator it = arrivalList.begin(); + auto it = arrivalList.begin(); double intKp = -DbToKp(effRxPowerDb); for (; it != arrivalList.end(); it++) { @@ -312,7 +312,7 @@ UanPhyPerCommonModes::CalcPer(Ptr pkt, double sinrDb, UanTxMode mode) // generic EbNo EbNo *= mode.GetDataRateBps() / mode.GetBandwidthHz(); - double M = (double)mode.GetConstellationSize(); + auto M = (double)mode.GetConstellationSize(); // standard squared quantized QAM, even number of bits per symbol supported int log2sqrtM = (int)::std::log2(sqrt(M)); @@ -1086,7 +1086,7 @@ UanPhyGen::GetInterferenceDb(Ptr pkt) { const UanTransducer::ArrivalList& arrivalList = m_transducer->GetArrivalList(); - UanTransducer::ArrivalList::const_iterator it = arrivalList.begin(); + auto it = arrivalList.begin(); double interfPower = 0; @@ -1116,7 +1116,7 @@ UanPhyGen::KpToDb(double kp) void UanPhyGen::NotifyListenersRxStart() { - ListenerList::const_iterator it = m_listeners.begin(); + auto it = m_listeners.begin(); for (; it != m_listeners.end(); it++) { (*it)->NotifyRxStart(); @@ -1126,7 +1126,7 @@ UanPhyGen::NotifyListenersRxStart() void UanPhyGen::NotifyListenersRxGood() { - ListenerList::const_iterator it = m_listeners.begin(); + auto it = m_listeners.begin(); for (; it != m_listeners.end(); it++) { (*it)->NotifyRxEndOk(); @@ -1136,7 +1136,7 @@ UanPhyGen::NotifyListenersRxGood() void UanPhyGen::NotifyListenersRxBad() { - ListenerList::const_iterator it = m_listeners.begin(); + auto it = m_listeners.begin(); for (; it != m_listeners.end(); it++) { (*it)->NotifyRxEndError(); @@ -1146,7 +1146,7 @@ UanPhyGen::NotifyListenersRxBad() void UanPhyGen::NotifyListenersCcaStart() { - ListenerList::const_iterator it = m_listeners.begin(); + auto it = m_listeners.begin(); for (; it != m_listeners.end(); it++) { (*it)->NotifyCcaStart(); @@ -1156,7 +1156,7 @@ UanPhyGen::NotifyListenersCcaStart() void UanPhyGen::NotifyListenersCcaEnd() { - ListenerList::const_iterator it = m_listeners.begin(); + auto it = m_listeners.begin(); for (; it != m_listeners.end(); it++) { (*it)->NotifyCcaEnd(); @@ -1166,7 +1166,7 @@ UanPhyGen::NotifyListenersCcaEnd() void UanPhyGen::NotifyListenersTxStart(Time duration) { - ListenerList::const_iterator it = m_listeners.begin(); + auto it = m_listeners.begin(); for (; it != m_listeners.end(); it++) { (*it)->NotifyTxStart(duration); @@ -1176,7 +1176,7 @@ UanPhyGen::NotifyListenersTxStart(Time duration) void UanPhyGen::NotifyListenersTxEnd() { - ListenerList::const_iterator it = m_listeners.begin(); + auto it = m_listeners.begin(); for (; it != m_listeners.end(); it++) { (*it)->NotifyTxEnd(); diff --git a/src/uan/model/uan-prop-model.cc b/src/uan/model/uan-prop-model.cc index d077128f5..bfdd582d9 100644 --- a/src/uan/model/uan-prop-model.cc +++ b/src/uan/model/uan-prop-model.cc @@ -33,7 +33,7 @@ operator<<(std::ostream& os, const UanPdp& pdp) os << pdp.GetNTaps() << '|'; os << pdp.GetResolution().GetSeconds() << '|'; - UanPdp::Iterator it = pdp.m_taps.begin(); + auto it = pdp.m_taps.begin(); for (; it != pdp.m_taps.end(); it++) { os << (*it).GetAmp() << '|'; diff --git a/src/uan/model/uan-transducer-hd.cc b/src/uan/model/uan-transducer-hd.cc index 90dbf1469..d7897e0c5 100644 --- a/src/uan/model/uan-transducer-hd.cc +++ b/src/uan/model/uan-transducer-hd.cc @@ -62,7 +62,7 @@ UanTransducerHd::Clear() m_channel = nullptr; } - UanPhyList::iterator it = m_phyList.begin(); + auto it = m_phyList.begin(); for (; it != m_phyList.end(); it++) { if (*it) @@ -71,7 +71,7 @@ UanTransducerHd::Clear() *it = nullptr; } } - ArrivalList::iterator ait = m_arrivalList.begin(); + auto ait = m_arrivalList.begin(); for (; ait != m_arrivalList.end(); ait++) { ait->GetPacket() = nullptr; @@ -164,7 +164,7 @@ UanTransducerHd::Receive(Ptr packet, double rxPowerDb, UanTxMode txMode, if (m_state == RX) { NS_LOG_DEBUG("Transducer state = RX"); - UanPhyList::const_iterator it = m_phyList.begin(); + auto it = m_phyList.begin(); for (; it != m_phyList.end(); it++) { NS_LOG_DEBUG("Calling StartRx"); @@ -191,7 +191,7 @@ UanTransducerHd::Transmit(Ptr src, Ptr packet, double txPowerDb, NS_LOG_DEBUG("Transducer transmitting: TX delay = " << delay << " seconds for packet size " << packet->GetSize() << " bytes and rate = " << txMode.GetDataRateBps() << " bps"); - UanPhyList::const_iterator it = m_phyList.begin(); + auto it = m_phyList.begin(); for (; it != m_phyList.end(); it++) { if (src != (*it)) @@ -245,7 +245,7 @@ void UanTransducerHd::RemoveArrival(UanPacketArrival arrival) { // Remove entry from arrival list - ArrivalList::iterator it = m_arrivalList.begin(); + auto it = m_arrivalList.begin(); for (; it != m_arrivalList.end(); it++) { if (it->GetPacket() == arrival.GetPacket()) @@ -254,7 +254,7 @@ UanTransducerHd::RemoveArrival(UanPacketArrival arrival) break; } } - UanPhyList::const_iterator ait = m_phyList.begin(); + auto ait = m_phyList.begin(); for (; ait != m_phyList.end(); ait++) { (*ait)->NotifyIntChange(); diff --git a/src/uan/model/uan-tx-mode.cc b/src/uan/model/uan-tx-mode.cc index 06b438d00..0268527d9 100644 --- a/src/uan/model/uan-tx-mode.cc +++ b/src/uan/model/uan-tx-mode.cc @@ -116,7 +116,7 @@ UanTxModeFactory::~UanTxModeFactory() bool UanTxModeFactory::NameUsed(std::string name) { - std::map::iterator it = m_modes.begin(); + auto it = m_modes.begin(); for (; it != m_modes.end(); it++) { @@ -176,7 +176,7 @@ UanTxModeFactory::GetModeItem(uint32_t uid) UanTxModeFactory::UanTxModeItem& UanTxModeFactory::GetModeItem(std::string name) { - std::map::iterator it = m_modes.begin(); + auto it = m_modes.begin(); for (; it != m_modes.end(); it++) { if ((*it).second.m_name == name) @@ -237,7 +237,7 @@ UanModesList::DeleteMode(uint32_t modeNum) { NS_ASSERT(modeNum < m_modes.size()); - std::vector::iterator it = m_modes.begin(); + auto it = m_modes.begin(); for (uint32_t i = 0; i < modeNum; i++) { it++; diff --git a/src/visualizer/model/pyviz.cc b/src/visualizer/model/pyviz.cc index c45ff806c..5605fbeaf 100644 --- a/src/visualizer/model/pyviz.cc +++ b/src/visualizer/model/pyviz.cc @@ -298,8 +298,7 @@ PyViz::SimulatorRunUntil(Time time) Time expirationTime = Simulator::Now() - Seconds(10); // Clear very old transmission records - for (std::map::iterator iter = m_txRecords.begin(); - iter != m_txRecords.end();) + for (auto iter = m_txRecords.begin(); iter != m_txRecords.end();) { if (iter->second.time < expirationTime) { @@ -312,8 +311,7 @@ PyViz::SimulatorRunUntil(Time time) } // Clear very old packets of interest - for (std::map::iterator iter = m_packetsOfInterest.begin(); - iter != m_packetsOfInterest.end();) + for (auto iter = m_packetsOfInterest.begin(); iter != m_packetsOfInterest.end();) { if (iter->second < expirationTime) { @@ -385,8 +383,7 @@ PyViz::TransmissionSampleKey::operator==(const PyViz::TransmissionSampleKey& oth PyViz::NetDeviceStatistics& PyViz::FindNetDeviceStatistics(int node, int interface) { - std::map>::iterator nodeStatsIter = - m_nodesStatistics.find(node); + auto nodeStatsIter = m_nodesStatistics.find(node); std::vector* stats; if (nodeStatsIter == m_nodesStatistics.end()) { @@ -404,8 +401,7 @@ PyViz::FindNetDeviceStatistics(int node, int interface) bool PyViz::GetPacketCaptureOptions(uint32_t nodeId, const PacketCaptureOptions** outOptions) const { - std::map::const_iterator iter = - m_packetCaptureOptions.find(nodeId); + auto iter = m_packetCaptureOptions.find(nodeId); if (iter == m_packetCaptureOptions.end()) { return false; @@ -444,7 +440,7 @@ PyViz::FilterPacket(Ptr packet, const PacketCaptureOptions& option while (metadataIterator.HasNext()) { PacketMetadata::Item item = metadataIterator.Next(); - std::set::iterator missingIter = missingHeaders.find(item.tid); + auto missingIter = missingHeaders.find(item.tid); if (missingIter != missingHeaders.end()) { missingHeaders.erase(missingIter); @@ -495,7 +491,7 @@ PyViz::TraceDevQueueDrop(std::string context, Ptr packet) } } - std::map, uint32_t>::iterator iter = m_packetDrops.find(node); + auto iter = m_packetDrops.find(node); if (iter == m_packetDrops.end()) { m_packetDrops[node] = packet->GetSize(); @@ -698,8 +694,7 @@ PyViz::TraceNetDevRxCommon(const std::string& context, Ptr channel = device->GetChannel(); - std::map::iterator recordIter = - m_txRecords.find(TxRecordKey(channel, uid)); + auto recordIter = m_txRecords.find(TxRecordKey(channel, uid)); if (recordIter == m_txRecords.end()) { @@ -722,10 +717,7 @@ PyViz::TraceNetDevRxCommon(const std::string& context, NS_LOG_DEBUG("m_transmissionSamples begin:"); if (g_log.IsEnabled(ns3::LOG_DEBUG)) { - for (std::map::const_iterator iter = - m_transmissionSamples.begin(); - iter != m_transmissionSamples.end(); - iter++) + for (auto iter = m_transmissionSamples.begin(); iter != m_transmissionSamples.end(); iter++) { NS_LOG_DEBUG(iter->first.transmitter << "/" << iter->first.transmitter->GetId() << ", " << iter->first.receiver @@ -736,8 +728,7 @@ PyViz::TraceNetDevRxCommon(const std::string& context, NS_LOG_DEBUG("m_transmissionSamples end."); #endif - std::map::iterator iter = - m_transmissionSamples.find(key); + auto iter = m_transmissionSamples.find(key); if (iter == m_transmissionSamples.end()) { @@ -867,10 +858,7 @@ PyViz::GetTransmissionSamples() const { NS_LOG_DEBUG("GetTransmissionSamples BEGIN"); TransmissionSampleList list; - for (std::map::const_iterator iter = - m_transmissionSamples.begin(); - iter != m_transmissionSamples.end(); - iter++) + for (auto iter = m_transmissionSamples.begin(); iter != m_transmissionSamples.end(); iter++) { TransmissionSample sample; sample.transmitter = iter->first.transmitter; @@ -890,9 +878,7 @@ PyViz::GetPacketDropSamples() const { NS_LOG_DEBUG("GetPacketDropSamples BEGIN"); PacketDropSampleList list; - for (std::map, uint32_t>::const_iterator iter = m_packetDrops.begin(); - iter != m_packetDrops.end(); - iter++) + for (auto iter = m_packetDrops.begin(); iter != m_packetDrops.end(); iter++) { PacketDropSample sample; sample.transmitter = iter->first; @@ -915,10 +901,7 @@ std::vector PyViz::GetNodesStatistics() const { std::vector retval; - for (std::map>::const_iterator iter = - m_nodesStatistics.begin(); - iter != m_nodesStatistics.end(); - iter++) + for (auto iter = m_nodesStatistics.begin(); iter != m_nodesStatistics.end(); iter++) { NodeStatistics stats = {iter->first, iter->second}; retval.push_back(stats); @@ -931,7 +914,7 @@ PyViz::GetLastPackets(uint32_t nodeId) const { NS_LOG_DEBUG("GetLastPackets: " << nodeId); - std::map::const_iterator iter = m_lastPackets.find(nodeId); + auto iter = m_lastPackets.find(nodeId); if (iter != m_lastPackets.end()) { return iter->second; diff --git a/src/wifi/examples/wifi-manager-example.cc b/src/wifi/examples/wifi-manager-example.cc index 04d880087..6fdc96fb3 100644 --- a/src/wifi/examples/wifi-manager-example.cc +++ b/src/wifi/examples/wifi-manager-example.cc @@ -714,8 +714,8 @@ main(int argc, char* argv[]) Ptr wndServer = ndServer->GetObject(); Ptr wifiPhyPtrClient = wndClient->GetPhy(); Ptr wifiPhyPtrServer = wndServer->GetPhy(); - uint8_t t_clientNss = static_cast(clientNss); - uint8_t t_serverNss = static_cast(serverNss); + auto t_clientNss = static_cast(clientNss); + auto t_serverNss = static_cast(serverNss); wifiPhyPtrClient->SetNumberOfAntennas(t_clientNss); wifiPhyPtrClient->SetMaxSupportedTxSpatialStreams(t_clientNss); wifiPhyPtrClient->SetMaxSupportedRxSpatialStreams(t_clientNss); diff --git a/src/wifi/helper/athstats-helper.cc b/src/wifi/helper/athstats-helper.cc index b7dda8e60..3b977a015 100644 --- a/src/wifi/helper/athstats-helper.cc +++ b/src/wifi/helper/athstats-helper.cc @@ -88,7 +88,7 @@ AthstatsHelper::EnableAthstats(std::string filename, Ptr nd) void AthstatsHelper::EnableAthstats(std::string filename, NetDeviceContainer d) { - for (NetDeviceContainer::Iterator i = d.Begin(); i != d.End(); ++i) + for (auto i = d.Begin(); i != d.End(); ++i) { Ptr dev = *i; EnableAthstats(filename, dev->GetNode()->GetId(), dev->GetIfIndex()); @@ -99,7 +99,7 @@ void AthstatsHelper::EnableAthstats(std::string filename, NodeContainer n) { NetDeviceContainer devs; - for (NodeContainer::Iterator i = n.Begin(); i != n.End(); ++i) + for (auto i = n.Begin(); i != n.End(); ++i) { Ptr node = *i; for (std::size_t j = 0; j < node->GetNDevices(); ++j) diff --git a/src/wifi/helper/wifi-helper.cc b/src/wifi/helper/wifi-helper.cc index 71d8e5324..32e3a0648 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -759,7 +759,7 @@ WifiHelper::Install(const WifiPhyHelper& phyHelper, NodeContainer::Iterator last) const { NetDeviceContainer devices; - for (NodeContainer::Iterator i = first; i != last; ++i) + for (auto i = first; i != last; ++i) { Ptr node = *i; Ptr device = CreateObject(); @@ -984,7 +984,7 @@ WifiHelper::AssignStreams(NetDeviceContainer c, int64_t stream) { int64_t currentStream = stream; Ptr netDevice; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { netDevice = (*i); Ptr wifi = DynamicCast(netDevice); diff --git a/src/wifi/helper/yans-wifi-helper.cc b/src/wifi/helper/yans-wifi-helper.cc index 1ee1b43f1..5429fd02f 100644 --- a/src/wifi/helper/yans-wifi-helper.cc +++ b/src/wifi/helper/yans-wifi-helper.cc @@ -54,9 +54,7 @@ YansWifiChannelHelper::Create() const { Ptr channel = CreateObject(); Ptr prev = nullptr; - for (std::vector::const_iterator i = m_propagationLoss.begin(); - i != m_propagationLoss.end(); - ++i) + for (auto i = m_propagationLoss.begin(); i != m_propagationLoss.end(); ++i) { Ptr cur = (*i).Create(); if (prev) diff --git a/src/wifi/model/channel-access-manager.cc b/src/wifi/model/channel-access-manager.cc index c90408ffc..da41e3938 100644 --- a/src/wifi/model/channel-access-manager.cc +++ b/src/wifi/model/channel-access-manager.cc @@ -495,7 +495,7 @@ ChannelAccessManager::DoGrantDcfAccess() NS_LOG_FUNCTION(this); uint32_t k = 0; Time now = Simulator::Now(); - for (Txops::iterator i = m_txops.begin(); i != m_txops.end(); k++) + for (auto i = m_txops.begin(); i != m_txops.end(); k++) { Ptr txop = *i; if (txop->GetAccessStatus(m_linkId) == Txop::REQUESTED && @@ -511,7 +511,7 @@ ChannelAccessManager::DoGrantDcfAccess() i++; // go to the next item in the list. k++; std::vector> internalCollisionTxops; - for (Txops::iterator j = i; j != m_txops.end(); j++, k++) + for (auto j = i; j != m_txops.end(); j++, k++) { Ptr otherTxop = *j; if (otherTxop->GetAccessStatus(m_linkId) == Txop::REQUESTED && @@ -891,13 +891,13 @@ ChannelAccessManager::NotifySwitchingStartNow(PhyListener* phyListener, Time dur if (phyListener) // to make tests happy { // check if the PHY switched channel to operate on another EMLSR link - decltype(m_switchingEmlsrLinks)::const_iterator emlsrInfoIt; for (const auto& [phyRef, listener] : m_phyListeners) { Ptr phy = phyRef; - if (listener.get() == phyListener && - (emlsrInfoIt = m_switchingEmlsrLinks.find(phy)) != m_switchingEmlsrLinks.cend() && + auto emlsrInfoIt = m_switchingEmlsrLinks.find(phy); + + if (listener.get() == phyListener && emlsrInfoIt != m_switchingEmlsrLinks.cend() && phy->GetOperatingChannel() == emlsrInfoIt->second.channel) { // the PHY associated with the given PHY listener switched channel to diff --git a/src/wifi/model/ctrl-headers.cc b/src/wifi/model/ctrl-headers.cc index 2503231b2..b243e6280 100644 --- a/src/wifi/model/ctrl-headers.cc +++ b/src/wifi/model/ctrl-headers.cc @@ -232,7 +232,7 @@ CtrlBAckRequestHeader::MustSendHtImmediateAck() const uint8_t CtrlBAckRequestHeader::GetTidInfo() const { - uint8_t tid = static_cast(m_tidInfo); + auto tid = static_cast(m_tidInfo); return tid; } diff --git a/src/wifi/model/edca-parameter-set.cc b/src/wifi/model/edca-parameter-set.cc index b599e86b4..4655e95f4 100644 --- a/src/wifi/model/edca-parameter-set.cc +++ b/src/wifi/model/edca-parameter-set.cc @@ -61,14 +61,14 @@ EdcaParameterSet::SetBeAci(uint8_t aci) void EdcaParameterSet::SetBeCWmin(uint32_t cwMin) { - uint8_t ECWmin = static_cast(log2(cwMin + 1)); + auto ECWmin = static_cast(log2(cwMin + 1)); m_acBE |= (ECWmin & 0x0f) << 8; } void EdcaParameterSet::SetBeCWmax(uint32_t cwMax) { - uint8_t ECWmax = static_cast(log2(cwMax + 1)); + auto ECWmax = static_cast(log2(cwMax + 1)); m_acBE |= (ECWmax & 0x0f) << 12; } @@ -93,14 +93,14 @@ EdcaParameterSet::SetBkAci(uint8_t aci) void EdcaParameterSet::SetBkCWmin(uint32_t cwMin) { - uint8_t ECWmin = static_cast(log2(cwMin + 1)); + auto ECWmin = static_cast(log2(cwMin + 1)); m_acBK |= (ECWmin & 0x0f) << 8; } void EdcaParameterSet::SetBkCWmax(uint32_t cwMax) { - uint8_t ECWmax = static_cast(log2(cwMax + 1)); + auto ECWmax = static_cast(log2(cwMax + 1)); m_acBK |= (ECWmax & 0x0f) << 12; } @@ -125,14 +125,14 @@ EdcaParameterSet::SetViAci(uint8_t aci) void EdcaParameterSet::SetViCWmin(uint32_t cwMin) { - uint8_t ECWmin = static_cast(log2(cwMin + 1)); + auto ECWmin = static_cast(log2(cwMin + 1)); m_acVI |= (ECWmin & 0x0f) << 8; } void EdcaParameterSet::SetViCWmax(uint32_t cwMax) { - uint8_t ECWmax = static_cast(log2(cwMax + 1)); + auto ECWmax = static_cast(log2(cwMax + 1)); m_acVI |= (ECWmax & 0x0f) << 12; } @@ -157,14 +157,14 @@ EdcaParameterSet::SetVoAci(uint8_t aci) void EdcaParameterSet::SetVoCWmin(uint32_t cwMin) { - uint8_t ECWmin = static_cast(log2(cwMin + 1)); + auto ECWmin = static_cast(log2(cwMin + 1)); m_acVO |= (ECWmin & 0x0f) << 8; } void EdcaParameterSet::SetVoCWmax(uint32_t cwMax) { - uint8_t ECWmax = static_cast(log2(cwMax + 1)); + auto ECWmax = static_cast(log2(cwMax + 1)); m_acVO |= (ECWmax & 0x0f) << 12; } diff --git a/src/wifi/model/eht/eht-frame-exchange-manager.cc b/src/wifi/model/eht/eht-frame-exchange-manager.cc index d7d53ddaa..2f95d590a 100644 --- a/src/wifi/model/eht/eht-frame-exchange-manager.cc +++ b/src/wifi/model/eht/eht-frame-exchange-manager.cc @@ -398,8 +398,7 @@ EhtFrameExchangeManager::SendMuRts(const WifiTxParameters& txParams) { NS_ASSERT(txParams.m_protection && txParams.m_protection->method == WifiProtection::MU_RTS_CTS); - WifiMuRtsCtsProtection* protection = - static_cast(txParams.m_protection.get()); + auto protection = static_cast(txParams.m_protection.get()); NS_ASSERT(protection->muRts.IsMuRts()); // see formula (35-1) in Sec. 35.5.2.2.3 of 802.11be D3.0 diff --git a/src/wifi/model/eht/tid-to-link-mapping-element.cc b/src/wifi/model/eht/tid-to-link-mapping-element.cc index f1d1e885d..ce87990d0 100644 --- a/src/wifi/model/eht/tid-to-link-mapping-element.cc +++ b/src/wifi/model/eht/tid-to-link-mapping-element.cc @@ -45,9 +45,9 @@ TidToLinkMapping::Control::GetSubfieldSize() const void TidToLinkMapping::Control::Serialize(Buffer::Iterator& start) const { - uint8_t val = static_cast(direction) | ((defaultMapping ? 1 : 0) << 2) | - ((mappingSwitchTimePresent ? 1 : 0) << 3) | - ((expectedDurationPresent ? 1 : 0) << 4) | ((linkMappingSize == 1 ? 1 : 0) << 5); + auto val = static_cast(direction) | ((defaultMapping ? 1 : 0) << 2) | + ((mappingSwitchTimePresent ? 1 : 0) << 3) | + ((expectedDurationPresent ? 1 : 0) << 4) | ((linkMappingSize == 1 ? 1 : 0) << 5); start.WriteU8(val); NS_ASSERT_MSG(!defaultMapping || !presenceBitmap.has_value(), diff --git a/src/wifi/model/frame-exchange-manager.cc b/src/wifi/model/frame-exchange-manager.cc index e59151e81..d35d2d454 100644 --- a/src/wifi/model/frame-exchange-manager.cc +++ b/src/wifi/model/frame-exchange-manager.cc @@ -493,8 +493,7 @@ FrameExchangeManager::SendMpdu() // the timeout duration is "aSIFSTime + aSlotTime + aRxPHYStartDelay, starting // at the PHY-TXEND.confirm primitive" (section 10.3.2.9 or 10.22.2.2 of 802.11-2016). // aRxPHYStartDelay equals the time to transmit the PHY header. - WifiNormalAck* normalAcknowledgment = - static_cast(m_txParams.m_acknowledgment.get()); + auto normalAcknowledgment = static_cast(m_txParams.m_acknowledgment.get()); Time timeout = txDuration + m_phy->GetSifs() + m_phy->GetSlot() + @@ -589,7 +588,7 @@ FrameExchangeManager::CalculateProtectionTime(WifiProtection* protection) const } else if (protection->method == WifiProtection::RTS_CTS) { - WifiRtsCtsProtection* rtsCtsProtection = static_cast(protection); + auto rtsCtsProtection = static_cast(protection); rtsCtsProtection->protectionTime = m_phy->CalculateTxDuration(GetRtsSize(), rtsCtsProtection->rtsTxVector, m_phy->GetPhyBand()) + @@ -600,8 +599,7 @@ FrameExchangeManager::CalculateProtectionTime(WifiProtection* protection) const } else if (protection->method == WifiProtection::CTS_TO_SELF) { - WifiCtsToSelfProtection* ctsToSelfProtection = - static_cast(protection); + auto ctsToSelfProtection = static_cast(protection); ctsToSelfProtection->protectionTime = m_phy->CalculateTxDuration(GetCtsSize(), ctsToSelfProtection->ctsTxVector, @@ -622,7 +620,7 @@ FrameExchangeManager::CalculateAcknowledgmentTime(WifiAcknowledgment* acknowledg } else if (acknowledgment->method == WifiAcknowledgment::NORMAL_ACK) { - WifiNormalAck* normalAcknowledgment = static_cast(acknowledgment); + auto normalAcknowledgment = static_cast(acknowledgment); normalAcknowledgment->acknowledgmentTime = m_phy->GetSifs() + m_phy->CalculateTxDuration(GetAckSize(), normalAcknowledgment->ackTxVector, @@ -708,8 +706,7 @@ FrameExchangeManager::SendRts(const WifiTxParameters& txParams) rts.SetAddr2(m_self); NS_ASSERT(txParams.m_protection && txParams.m_protection->method == WifiProtection::RTS_CTS); - WifiRtsCtsProtection* rtsCtsProtection = - static_cast(txParams.m_protection.get()); + auto rtsCtsProtection = static_cast(txParams.m_protection.get()); NS_ASSERT(txParams.m_txDuration != Time::Min()); rts.SetDuration(GetRtsDurationId(rtsCtsProtection->rtsTxVector, @@ -810,8 +807,7 @@ FrameExchangeManager::SendCtsToSelf(const WifiTxParameters& txParams) NS_ASSERT(txParams.m_protection && txParams.m_protection->method == WifiProtection::CTS_TO_SELF); - WifiCtsToSelfProtection* ctsToSelfProtection = - static_cast(txParams.m_protection.get()); + auto ctsToSelfProtection = static_cast(txParams.m_protection.get()); NS_ASSERT(txParams.m_txDuration != Time::Min()); cts.SetDuration(GetCtsToSelfDurationId(ctsToSelfProtection->ctsTxVector, diff --git a/src/wifi/model/he/he-frame-exchange-manager.cc b/src/wifi/model/he/he-frame-exchange-manager.cc index 8ff0e1bd2..81c3c7481 100644 --- a/src/wifi/model/he/he-frame-exchange-manager.cc +++ b/src/wifi/model/he/he-frame-exchange-manager.cc @@ -295,8 +295,7 @@ HeFrameExchangeManager::RecordSentMuRtsTo(const WifiTxParameters& txParams) NS_LOG_FUNCTION(this << &txParams); NS_ASSERT(txParams.m_protection && txParams.m_protection->method == WifiProtection::MU_RTS_CTS); - WifiMuRtsCtsProtection* protection = - static_cast(txParams.m_protection.get()); + auto protection = static_cast(txParams.m_protection.get()); NS_ASSERT(protection->muRts.IsMuRts()); NS_ASSERT_MSG(m_apMac, "APs only can send MU-RTS TF"); @@ -363,8 +362,7 @@ HeFrameExchangeManager::SendMuRts(const WifiTxParameters& txParams) hdr.SetNoMoreFragments(); NS_ASSERT(txParams.m_protection && txParams.m_protection->method == WifiProtection::MU_RTS_CTS); - WifiMuRtsCtsProtection* protection = - static_cast(txParams.m_protection.get()); + auto protection = static_cast(txParams.m_protection.get()); NS_ASSERT(protection->muRts.IsMuRts()); protection->muRts.SetCsRequired(true); @@ -543,7 +541,7 @@ HeFrameExchangeManager::SendPsduMap() */ if (m_txParams.m_acknowledgment->method == WifiAcknowledgment::DL_MU_BAR_BA_SEQUENCE) { - WifiDlMuBarBaSequence* acknowledgment = + auto acknowledgment = static_cast(m_txParams.m_acknowledgment.get()); // schedule the transmission of required BlockAckReq frames @@ -594,8 +592,7 @@ HeFrameExchangeManager::SendPsduMap() */ else if (m_txParams.m_acknowledgment->method == WifiAcknowledgment::DL_MU_TF_MU_BAR) { - WifiDlMuTfMuBar* acknowledgment = - static_cast(m_txParams.m_acknowledgment.get()); + auto acknowledgment = static_cast(m_txParams.m_acknowledgment.get()); if (!m_triggerFrame) { @@ -671,8 +668,7 @@ HeFrameExchangeManager::SendPsduMap() */ else if (m_txParams.m_acknowledgment->method == WifiAcknowledgment::DL_MU_AGGREGATE_TF) { - WifiDlMuAggregateTf* acknowledgment = - static_cast(m_txParams.m_acknowledgment.get()); + auto acknowledgment = static_cast(m_txParams.m_acknowledgment.get()); m_trigVector = acknowledgment->stationsReplyingWithBlockAck.begin()->second.blockAckTxVector; @@ -719,8 +715,7 @@ HeFrameExchangeManager::SendPsduMap() NS_ASSERT(IsTrigger(m_psduMap)); mpdu = *m_psduMap.begin()->second->begin(); - WifiUlMuMultiStaBa* acknowledgment = - static_cast(m_txParams.m_acknowledgment.get()); + auto acknowledgment = static_cast(m_txParams.m_acknowledgment.get()); // record the set of stations solicited by this Trigger Frame for (const auto& station : acknowledgment->stationsReceivingMultiStaBa) @@ -1004,8 +999,7 @@ HeFrameExchangeManager::CalculateProtectionTime(WifiProtection* protection) cons if (protection->method == WifiProtection::MU_RTS_CTS) { - WifiMuRtsCtsProtection* muRtsCtsProtection = - static_cast(protection); + auto muRtsCtsProtection = static_cast(protection); // Get the TXVECTOR used by one station to send the CTS response. This is used // to compute the TX duration, so it does not matter which station we choose @@ -1039,8 +1033,7 @@ HeFrameExchangeManager::CalculateAcknowledgmentTime(WifiAcknowledgment* acknowle */ if (acknowledgment->method == WifiAcknowledgment::DL_MU_BAR_BA_SEQUENCE) { - WifiDlMuBarBaSequence* dlMuBarBaAcknowledgment = - static_cast(acknowledgment); + auto dlMuBarBaAcknowledgment = static_cast(acknowledgment); Time duration = Seconds(0); @@ -1087,7 +1080,7 @@ HeFrameExchangeManager::CalculateAcknowledgmentTime(WifiAcknowledgment* acknowle */ else if (acknowledgment->method == WifiAcknowledgment::DL_MU_TF_MU_BAR) { - WifiDlMuTfMuBar* dlMuTfMuBarAcknowledgment = static_cast(acknowledgment); + auto dlMuTfMuBarAcknowledgment = static_cast(acknowledgment); Time duration = Seconds(0); @@ -1133,8 +1126,7 @@ HeFrameExchangeManager::CalculateAcknowledgmentTime(WifiAcknowledgment* acknowle */ else if (acknowledgment->method == WifiAcknowledgment::DL_MU_AGGREGATE_TF) { - WifiDlMuAggregateTf* dlMuAggrTfAcknowledgment = - static_cast(acknowledgment); + auto dlMuAggrTfAcknowledgment = static_cast(acknowledgment); Time duration = Seconds(0); @@ -1168,7 +1160,7 @@ HeFrameExchangeManager::CalculateAcknowledgmentTime(WifiAcknowledgment* acknowle */ else if (acknowledgment->method == WifiAcknowledgment::UL_MU_MULTI_STA_BA) { - WifiUlMuMultiStaBa* ulMuMultiStaBa = static_cast(acknowledgment); + auto ulMuMultiStaBa = static_cast(acknowledgment); Time duration = m_phy->CalculateTxDuration(GetBlockAckSize(ulMuMultiStaBa->baType), ulMuMultiStaBa->multiStaBaTxVector, @@ -1252,8 +1244,7 @@ HeFrameExchangeManager::GetTxDuration(uint32_t ppduPayloadSize, txParams.m_acknowledgment->method == WifiAcknowledgment::DL_MU_AGGREGATE_TF) { // we need to account for the size of the aggregated MU-BAR Trigger Frame - WifiDlMuAggregateTf* acknowledgment = - static_cast(txParams.m_acknowledgment.get()); + auto acknowledgment = static_cast(txParams.m_acknowledgment.get()); const auto& info = acknowledgment->stationsReplyingWithBlockAck.find(receiver); NS_ASSERT(info != acknowledgment->stationsReplyingWithBlockAck.end()); @@ -1507,7 +1498,7 @@ HeFrameExchangeManager::GetHeTbTxVector(CtrlTriggerHeader trigger, Mac48Address trigger.GetApTxPower() - static_cast( *optRssi); // cast RSSI to be on equal footing with AP Tx power information - double reqTxPowerDbm = static_cast(userInfoIt->GetUlTargetRssi() + pathLossDb); + auto reqTxPowerDbm = static_cast(userInfoIt->GetUlTargetRssi() + pathLossDb); // Convert the transmit power to a power level uint8_t numPowerLevels = m_phy->GetNTxPower(); @@ -1560,7 +1551,7 @@ HeFrameExchangeManager::SetTargetRssi(CtrlTriggerHeader& trigger) const NS_ASSERT(itAidAddr != staList.end()); auto optRssi = GetMostRecentRssi(itAidAddr->second); NS_ASSERT(optRssi); - int8_t rssi = static_cast(*optRssi); + auto rssi = static_cast(*optRssi); rssi = (rssi >= -20) ? -20 : ((rssi <= -110) ? -110 : rssi); // cap so as to keep within [-110; -20] dBm @@ -1641,8 +1632,7 @@ HeFrameExchangeManager::SendMultiStaBlockAck(const WifiTxParameters& txParams, T NS_ASSERT(m_apMac); NS_ASSERT(txParams.m_acknowledgment && txParams.m_acknowledgment->method == WifiAcknowledgment::UL_MU_MULTI_STA_BA); - WifiUlMuMultiStaBa* acknowledgment = - static_cast(txParams.m_acknowledgment.get()); + auto acknowledgment = static_cast(txParams.m_acknowledgment.get()); NS_ASSERT(!acknowledgment->stationsReceivingMultiStaBa.empty()); @@ -2202,8 +2192,7 @@ HeFrameExchangeManager::ReceiveMpdu(Ptr mpdu, Mac48Address sender = hdr.GetAddr2(); NS_ASSERT(m_txParams.m_acknowledgment && m_txParams.m_acknowledgment->method == WifiAcknowledgment::UL_MU_MULTI_STA_BA); - WifiUlMuMultiStaBa* acknowledgment = - static_cast(m_txParams.m_acknowledgment.get()); + auto acknowledgment = static_cast(m_txParams.m_acknowledgment.get()); std::size_t index = acknowledgment->baType.m_bitmapLen.size(); if (m_txTimer.GetStasExpectedToRespond().count(sender) == 0) @@ -2374,7 +2363,7 @@ HeFrameExchangeManager::ReceiveMpdu(Ptr mpdu, NS_ASSERT(m_txParams.m_acknowledgment->method == WifiAcknowledgment::DL_MU_BAR_BA_SEQUENCE); - WifiDlMuBarBaSequence* acknowledgment = + auto acknowledgment = static_cast(m_txParams.m_acknowledgment.get()); NS_ASSERT(acknowledgment->stationsReplyingWithNormalAck.size() == 1); NS_ASSERT(m_apMac); @@ -2676,8 +2665,7 @@ HeFrameExchangeManager::EndReceiveAmpdu(Ptr psdu, Mac48Address sender = psdu->GetAddr2(); NS_ASSERT(m_txParams.m_acknowledgment && m_txParams.m_acknowledgment->method == WifiAcknowledgment::UL_MU_MULTI_STA_BA); - WifiUlMuMultiStaBa* acknowledgment = - static_cast(m_txParams.m_acknowledgment.get()); + auto acknowledgment = static_cast(m_txParams.m_acknowledgment.get()); std::size_t index = acknowledgment->baType.m_bitmapLen.size(); if (m_txTimer.GetStasExpectedToRespond().count(sender) == 0) diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index 688996297..4f26883a6 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -1826,7 +1826,7 @@ HePhy::ConvertHeRuSubcarriers(uint16_t bandWidth, uint8_t bandIndex) { WifiSpectrumBandIndices convertedSubcarriers; - uint32_t nGuardBands = + auto nGuardBands = static_cast(((2 * guardBandwidth * 1e6) / subcarrierSpacing) + 0.5); uint32_t centerFrequencyIndex = 0; switch (bandWidth) @@ -1848,7 +1848,7 @@ HePhy::ConvertHeRuSubcarriers(uint16_t bandWidth, break; } - size_t numBandsInBand = static_cast(bandWidth * 1e6 / subcarrierSpacing); + auto numBandsInBand = static_cast(bandWidth * 1e6 / subcarrierSpacing); centerFrequencyIndex += numBandsInBand * bandIndex; convertedSubcarriers.first = centerFrequencyIndex + subcarrierRange.first; @@ -1866,7 +1866,7 @@ HePhy::GetRuBands(Ptr phy, uint16_t channelWidth, uint16_t guardB { for (uint32_t type = 0; type < 7; type++) { - HeRu::RuType ruType = static_cast(type); + auto ruType = static_cast(type); std::size_t nRus = HeRu::GetNRus(bw, ruType); for (std::size_t phyIndex = 1; phyIndex <= nRus; phyIndex++) { diff --git a/src/wifi/model/ht/ht-frame-exchange-manager.cc b/src/wifi/model/ht/ht-frame-exchange-manager.cc index ad2f63b13..bdac25e70 100644 --- a/src/wifi/model/ht/ht-frame-exchange-manager.cc +++ b/src/wifi/model/ht/ht-frame-exchange-manager.cc @@ -643,7 +643,7 @@ HtFrameExchangeManager::CalculateAcknowledgmentTime(WifiAcknowledgment* acknowle if (acknowledgment->method == WifiAcknowledgment::BLOCK_ACK) { - WifiBlockAck* blockAcknowledgment = static_cast(acknowledgment); + auto blockAcknowledgment = static_cast(acknowledgment); Time baTxDuration = m_phy->CalculateTxDuration(GetBlockAckSize(blockAcknowledgment->baType), blockAcknowledgment->blockAckTxVector, m_phy->GetPhyBand()); @@ -651,7 +651,7 @@ HtFrameExchangeManager::CalculateAcknowledgmentTime(WifiAcknowledgment* acknowle } else if (acknowledgment->method == WifiAcknowledgment::BAR_BLOCK_ACK) { - WifiBarBlockAck* barBlockAcknowledgment = static_cast(acknowledgment); + auto barBlockAcknowledgment = static_cast(acknowledgment); Time barTxDuration = m_phy->CalculateTxDuration(GetBlockAckRequestSize(barBlockAcknowledgment->barType), barBlockAcknowledgment->blockAckReqTxVector, @@ -1007,8 +1007,7 @@ HtFrameExchangeManager::SendPsdu() // the timeout duration is "aSIFSTime + aSlotTime + aRxPHYStartDelay, starting // at the PHY-TXEND.confirm primitive" (section 10.3.2.9 or 10.22.2.2 of 802.11-2016). // aRxPHYStartDelay equals the time to transmit the PHY header. - WifiBlockAck* blockAcknowledgment = - static_cast(m_txParams.m_acknowledgment.get()); + auto blockAcknowledgment = static_cast(m_txParams.m_acknowledgment.get()); Time timeout = txDuration + m_phy->GetSifs() + m_phy->GetSlot() + diff --git a/src/wifi/model/interference-helper.cc b/src/wifi/model/interference-helper.cc index 953980fc0..bd29a2b2b 100644 --- a/src/wifi/model/interference-helper.cc +++ b/src/wifi/model/interference-helper.cc @@ -535,7 +535,7 @@ InterferenceHelper::CalculateChunkSuccessRate(double snir, return 1.0; } uint64_t rate = mode.GetDataRate(txVector.GetChannelWidth()); - uint64_t nbits = static_cast(rate * duration.GetSeconds()); + auto nbits = static_cast(rate * duration.GetSeconds()); double csr = m_errorRateModel->GetChunkSuccessRate(mode, txVector, snir, nbits, m_numRxAntennas, field); return csr; @@ -553,7 +553,7 @@ InterferenceHelper::CalculatePayloadChunkSuccessRate(double snir, } WifiMode mode = txVector.GetMode(staId); uint64_t rate = mode.GetDataRate(txVector, staId); - uint64_t nbits = static_cast(rate * duration.GetSeconds()); + auto nbits = static_cast(rate * duration.GetSeconds()); nbits /= txVector.GetNss(staId); // divide effective number of bits by NSS to achieve same chunk // error rate as SISO for AWGN double csr = m_errorRateModel->GetChunkSuccessRate(mode, diff --git a/src/wifi/model/mac-rx-middle.cc b/src/wifi/model/mac-rx-middle.cc index 454f83e4f..2a5f20129 100644 --- a/src/wifi/model/mac-rx-middle.cc +++ b/src/wifi/model/mac-rx-middle.cc @@ -103,7 +103,7 @@ class OriginatorRxStatus m_fragments.push_back(packet); m_defragmenting = false; Ptr full = Create(); - for (FragmentsCI i = m_fragments.begin(); i != m_fragments.end(); i++) + for (auto i = m_fragments.begin(); i != m_fragments.end(); i++) { full->AddAtEnd(*i); } @@ -167,12 +167,12 @@ MacRxMiddle::MacRxMiddle() MacRxMiddle::~MacRxMiddle() { NS_LOG_FUNCTION_NOARGS(); - for (OriginatorsI i = m_originatorStatus.begin(); i != m_originatorStatus.end(); i++) + for (auto i = m_originatorStatus.begin(); i != m_originatorStatus.end(); i++) { delete (*i).second; } m_originatorStatus.erase(m_originatorStatus.begin(), m_originatorStatus.end()); - for (QosOriginatorsI i = m_qosOriginatorStatus.begin(); i != m_qosOriginatorStatus.end(); i++) + for (auto i = m_qosOriginatorStatus.begin(); i != m_qosOriginatorStatus.end(); i++) { delete (*i).second; } diff --git a/src/wifi/model/mac-tx-middle.cc b/src/wifi/model/mac-tx-middle.cc index f141e7e2b..60adb924e 100644 --- a/src/wifi/model/mac-tx-middle.cc +++ b/src/wifi/model/mac-tx-middle.cc @@ -40,9 +40,7 @@ MacTxMiddle::MacTxMiddle() MacTxMiddle::~MacTxMiddle() { NS_LOG_FUNCTION(this); - for (std::map::const_iterator i = m_qosSequences.begin(); - i != m_qosSequences.end(); - i++) + for (auto i = m_qosSequences.begin(); i != m_qosSequences.end(); i++) { delete[] i->second; } @@ -57,7 +55,7 @@ MacTxMiddle::GetNextSequenceNumberFor(const WifiMacHeader* hdr) { uint8_t tid = hdr->GetQosTid(); NS_ASSERT(tid < 16); - std::map::const_iterator it = m_qosSequences.find(hdr->GetAddr1()); + auto it = m_qosSequences.find(hdr->GetAddr1()); if (it != m_qosSequences.end()) { retval = it->second[tid]; @@ -68,8 +66,7 @@ MacTxMiddle::GetNextSequenceNumberFor(const WifiMacHeader* hdr) { retval = 0; std::pair newSeq(hdr->GetAddr1(), new uint16_t[16]); - std::pair::const_iterator, bool> newIns = - m_qosSequences.insert(newSeq); + auto newIns = m_qosSequences.insert(newSeq); NS_ASSERT(newIns.second == true); for (uint8_t i = 0; i < 16; i++) { @@ -96,7 +93,7 @@ MacTxMiddle::PeekNextSequenceNumberFor(const WifiMacHeader* hdr) { uint8_t tid = hdr->GetQosTid(); NS_ASSERT(tid < 16); - std::map::const_iterator it = m_qosSequences.find(hdr->GetAddr1()); + auto it = m_qosSequences.find(hdr->GetAddr1()); if (it != m_qosSequences.end()) { retval = it->second[tid]; @@ -119,7 +116,7 @@ MacTxMiddle::GetNextSeqNumberByTidAndAddress(uint8_t tid, Mac48Address addr) con NS_LOG_FUNCTION(this); NS_ASSERT(tid < 16); uint16_t seq = 0; - std::map::const_iterator it = m_qosSequences.find(addr); + auto it = m_qosSequences.find(addr); if (it != m_qosSequences.end()) { return it->second[tid]; diff --git a/src/wifi/model/mgt-headers.cc b/src/wifi/model/mgt-headers.cc index 96dca5d1e..27add657c 100644 --- a/src/wifi/model/mgt-headers.cc +++ b/src/wifi/model/mgt-headers.cc @@ -1688,7 +1688,7 @@ uint8_t MgtDelBaHeader::GetTid() const { NS_ASSERT(m_tid < 16); - uint8_t tid = static_cast(m_tid); + auto tid = static_cast(m_tid); return tid; } diff --git a/src/wifi/model/non-ht/dsss-phy.cc b/src/wifi/model/non-ht/dsss-phy.cc index 61ee66a52..3dda8c609 100644 --- a/src/wifi/model/non-ht/dsss-phy.cc +++ b/src/wifi/model/non-ht/dsss-phy.cc @@ -380,7 +380,7 @@ DsssPhy::GetDataRate(const std::string& name, WifiModulationClass modClass) NS_FATAL_ERROR("Incorrect modulation class, must specify either WIFI_MOD_CLASS_DSSS or " "WIFI_MOD_CLASS_HR_DSSS!"); } - uint16_t numberOfBitsPerSubcarrier = static_cast(log2(constellationSize)); + auto numberOfBitsPerSubcarrier = static_cast(log2(constellationSize)); uint64_t dataRate = ((11000000 / divisor) * numberOfBitsPerSubcarrier); return dataRate; } diff --git a/src/wifi/model/rate-control/aarf-wifi-manager.cc b/src/wifi/model/rate-control/aarf-wifi-manager.cc index 0b78ee80d..f3ddffb5a 100644 --- a/src/wifi/model/rate-control/aarf-wifi-manager.cc +++ b/src/wifi/model/rate-control/aarf-wifi-manager.cc @@ -123,7 +123,7 @@ WifiRemoteStation* AarfWifiManager::DoCreateStation() const { NS_LOG_FUNCTION(this); - AarfWifiRemoteStation* station = new AarfWifiRemoteStation(); + auto station = new AarfWifiRemoteStation(); station->m_successThreshold = m_minSuccessThreshold; station->m_timerTimeout = m_minTimerThreshold; @@ -157,7 +157,7 @@ void AarfWifiManager::DoReportDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - AarfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_timer++; station->m_failed++; station->m_success = 0; @@ -224,7 +224,7 @@ AarfWifiManager::DoReportDataOk(WifiRemoteStation* st, uint8_t dataNss) { NS_LOG_FUNCTION(this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss); - AarfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_timer++; station->m_success++; station->m_failed = 0; @@ -259,7 +259,7 @@ WifiTxVector AarfWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth) { NS_LOG_FUNCTION(this << st << allowedWidth); - AarfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { @@ -290,7 +290,7 @@ AarfWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) NS_LOG_FUNCTION(this << st); /// \todo we could/should implement the AARF algorithm for /// RTS only by picking a single rate within the BasicRateSet. - AarfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { diff --git a/src/wifi/model/rate-control/aarfcd-wifi-manager.cc b/src/wifi/model/rate-control/aarfcd-wifi-manager.cc index e910165b0..00adff31d 100644 --- a/src/wifi/model/rate-control/aarfcd-wifi-manager.cc +++ b/src/wifi/model/rate-control/aarfcd-wifi-manager.cc @@ -151,7 +151,7 @@ WifiRemoteStation* AarfcdWifiManager::DoCreateStation() const { NS_LOG_FUNCTION(this); - AarfcdWifiRemoteStation* station = new AarfcdWifiRemoteStation(); + auto station = new AarfcdWifiRemoteStation(); // AARF fields below station->m_successThreshold = m_minSuccessThreshold; @@ -182,7 +182,7 @@ void AarfcdWifiManager::DoReportDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - AarfcdWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_timer++; station->m_failed++; station->m_success = 0; @@ -269,7 +269,7 @@ AarfcdWifiManager::DoReportRtsOk(WifiRemoteStation* st, double rtsSnr) { NS_LOG_FUNCTION(this << st << ctsSnr << ctsMode << rtsSnr); - AarfcdWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); NS_LOG_DEBUG("station=" << station << " rts ok"); station->m_rtsCounter--; } @@ -283,7 +283,7 @@ AarfcdWifiManager::DoReportDataOk(WifiRemoteStation* st, uint8_t dataNss) { NS_LOG_FUNCTION(this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss); - AarfcdWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_timer++; station->m_success++; station->m_failed = 0; @@ -328,7 +328,7 @@ WifiTxVector AarfcdWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth) { NS_LOG_FUNCTION(this << st << allowedWidth); - AarfcdWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { @@ -359,7 +359,7 @@ AarfcdWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) NS_LOG_FUNCTION(this << st); /// \todo we could/should implement the AARF algorithm for /// RTS only by picking a single rate within the BasicRateSet. - AarfcdWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { @@ -390,7 +390,7 @@ bool AarfcdWifiManager::DoNeedRts(WifiRemoteStation* st, uint32_t size, bool normally) { NS_LOG_FUNCTION(this << st << size << normally); - AarfcdWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); NS_LOG_INFO("" << station << " rate=" << station->m_rate << " rts=" << (station->m_rtsOn ? "RTS" : "BASIC") << " rtsCounter=" << station->m_rtsCounter); diff --git a/src/wifi/model/rate-control/amrr-wifi-manager.cc b/src/wifi/model/rate-control/amrr-wifi-manager.cc index b3055515f..bb92ddf61 100644 --- a/src/wifi/model/rate-control/amrr-wifi-manager.cc +++ b/src/wifi/model/rate-control/amrr-wifi-manager.cc @@ -129,7 +129,7 @@ WifiRemoteStation* AmrrWifiManager::DoCreateStation() const { NS_LOG_FUNCTION(this); - AmrrWifiRemoteStation* station = new AmrrWifiRemoteStation(); + auto station = new AmrrWifiRemoteStation(); station->m_nextModeUpdate = Simulator::Now() + m_updatePeriod; station->m_tx_ok = 0; station->m_tx_err = 0; @@ -158,7 +158,7 @@ void AmrrWifiManager::DoReportDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - AmrrWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_retry++; station->m_tx_retr++; } @@ -181,7 +181,7 @@ AmrrWifiManager::DoReportDataOk(WifiRemoteStation* st, uint8_t dataNss) { NS_LOG_FUNCTION(this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss); - AmrrWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_retry = 0; station->m_tx_ok++; } @@ -196,7 +196,7 @@ void AmrrWifiManager::DoReportFinalDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - AmrrWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_retry = 0; station->m_tx_err++; } @@ -334,7 +334,7 @@ WifiTxVector AmrrWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth) { NS_LOG_FUNCTION(this << st << allowedWidth); - AmrrWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); UpdateMode(station); NS_ASSERT(station->m_txrate < GetNSupported(station)); uint8_t rateIndex; @@ -403,7 +403,7 @@ WifiTxVector AmrrWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - AmrrWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { diff --git a/src/wifi/model/rate-control/aparf-wifi-manager.cc b/src/wifi/model/rate-control/aparf-wifi-manager.cc index 63e7b1829..7fb579581 100644 --- a/src/wifi/model/rate-control/aparf-wifi-manager.cc +++ b/src/wifi/model/rate-control/aparf-wifi-manager.cc @@ -160,7 +160,7 @@ WifiRemoteStation* AparfWifiManager::DoCreateStation() const { NS_LOG_FUNCTION(this); - AparfWifiRemoteStation* station = new AparfWifiRemoteStation(); + auto station = new AparfWifiRemoteStation(); station->m_successThreshold = m_successMax1; station->m_failThreshold = m_failMax; @@ -189,7 +189,7 @@ AparfWifiManager::CheckInit(AparfWifiRemoteStation* station) station->m_critRateIndex = 0; WifiMode mode = GetSupported(station, station->m_rateIndex); uint16_t channelWidth = GetChannelWidth(station); - DataRate rate = DataRate(mode.GetDataRate(channelWidth)); + DataRate rate(mode.GetDataRate(channelWidth)); double power = GetPhy()->GetPowerDbm(m_maxPower); m_powerChange(power, power, station->m_state->m_address); m_rateChange(rate, rate, station->m_state->m_address); @@ -207,7 +207,7 @@ void AparfWifiManager::DoReportDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - AparfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); station->m_nFailed++; station->m_nSuccess = 0; @@ -271,7 +271,7 @@ AparfWifiManager::DoReportDataOk(WifiRemoteStation* st, uint8_t dataNss) { NS_LOG_FUNCTION(this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss); - AparfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); station->m_nSuccess++; station->m_nFailed = 0; @@ -354,7 +354,7 @@ WifiTxVector AparfWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth) { NS_LOG_FUNCTION(this << st << allowedWidth); - AparfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { @@ -362,9 +362,8 @@ AparfWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth } CheckInit(station); WifiMode mode = GetSupported(station, station->m_rateIndex); - DataRate rate = DataRate(mode.GetDataRate(channelWidth)); - DataRate prevRate = - DataRate(GetSupported(station, station->m_prevRateIndex).GetDataRate(channelWidth)); + DataRate rate(mode.GetDataRate(channelWidth)); + DataRate prevRate(GetSupported(station, station->m_prevRateIndex).GetDataRate(channelWidth)); double power = GetPhy()->GetPowerDbm(station->m_powerLevel); double prevPower = GetPhy()->GetPowerDbm(station->m_prevPowerLevel); if (station->m_prevPowerLevel != station->m_powerLevel) @@ -395,7 +394,7 @@ AparfWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) NS_LOG_FUNCTION(this << st); /// \todo we could/should implement the ARF algorithm for /// RTS only by picking a single rate within the BasicRateSet. - AparfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { diff --git a/src/wifi/model/rate-control/arf-wifi-manager.cc b/src/wifi/model/rate-control/arf-wifi-manager.cc index 3931d2477..31897729e 100644 --- a/src/wifi/model/rate-control/arf-wifi-manager.cc +++ b/src/wifi/model/rate-control/arf-wifi-manager.cc @@ -107,7 +107,7 @@ WifiRemoteStation* ArfWifiManager::DoCreateStation() const { NS_LOG_FUNCTION(this); - ArfWifiRemoteStation* station = new ArfWifiRemoteStation(); + auto station = new ArfWifiRemoteStation(); station->m_successThreshold = m_successThreshold; station->m_timerTimeout = m_timerThreshold; @@ -141,7 +141,7 @@ void ArfWifiManager::DoReportDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - ArfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_timer++; station->m_failed++; station->m_success = 0; @@ -202,7 +202,7 @@ ArfWifiManager::DoReportDataOk(WifiRemoteStation* st, uint8_t dataNss) { NS_LOG_FUNCTION(this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss); - ArfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_timer++; station->m_success++; station->m_failed = 0; @@ -236,7 +236,7 @@ WifiTxVector ArfWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth) { NS_LOG_FUNCTION(this << st << allowedWidth); - ArfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { @@ -267,7 +267,7 @@ ArfWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) NS_LOG_FUNCTION(this << st); /// \todo we could/should implement the ARF algorithm for /// RTS only by picking a single rate within the BasicRateSet. - ArfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { diff --git a/src/wifi/model/rate-control/cara-wifi-manager.cc b/src/wifi/model/rate-control/cara-wifi-manager.cc index d8366b9d6..ba9ee45d8 100644 --- a/src/wifi/model/rate-control/cara-wifi-manager.cc +++ b/src/wifi/model/rate-control/cara-wifi-manager.cc @@ -115,7 +115,7 @@ WifiRemoteStation* CaraWifiManager::DoCreateStation() const { NS_LOG_FUNCTION(this); - CaraWifiRemoteStation* station = new CaraWifiRemoteStation(); + auto station = new CaraWifiRemoteStation(); station->m_rate = 0; station->m_success = 0; station->m_failed = 0; @@ -133,7 +133,7 @@ void CaraWifiManager::DoReportDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - CaraWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_timer++; station->m_failed++; station->m_success = 0; @@ -173,7 +173,7 @@ CaraWifiManager::DoReportDataOk(WifiRemoteStation* st, uint8_t dataNss) { NS_LOG_FUNCTION(this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss); - CaraWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_timer++; station->m_success++; station->m_failed = 0; @@ -207,7 +207,7 @@ WifiTxVector CaraWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth) { NS_LOG_FUNCTION(this << st << allowedWidth); - CaraWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { @@ -236,7 +236,7 @@ WifiTxVector CaraWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - CaraWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); /// \todo we could/should implement the Arf algorithm for /// RTS only by picking a single rate within the BasicRateSet. uint16_t channelWidth = GetChannelWidth(station); @@ -269,7 +269,7 @@ bool CaraWifiManager::DoNeedRts(WifiRemoteStation* st, uint32_t size, bool normally) { NS_LOG_FUNCTION(this << st << size << normally); - CaraWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); return normally || station->m_failed >= m_probeThreshold; } diff --git a/src/wifi/model/rate-control/constant-rate-wifi-manager.cc b/src/wifi/model/rate-control/constant-rate-wifi-manager.cc index b80d3b33d..c60317245 100644 --- a/src/wifi/model/rate-control/constant-rate-wifi-manager.cc +++ b/src/wifi/model/rate-control/constant-rate-wifi-manager.cc @@ -69,7 +69,7 @@ WifiRemoteStation* ConstantRateWifiManager::DoCreateStation() const { NS_LOG_FUNCTION(this); - WifiRemoteStation* station = new WifiRemoteStation(); + auto station = new WifiRemoteStation(); return station; } diff --git a/src/wifi/model/rate-control/ideal-wifi-manager.cc b/src/wifi/model/rate-control/ideal-wifi-manager.cc index 17ecfd23c..5302f7f71 100644 --- a/src/wifi/model/rate-control/ideal-wifi-manager.cc +++ b/src/wifi/model/rate-control/ideal-wifi-manager.cc @@ -224,7 +224,7 @@ WifiRemoteStation* IdealWifiManager::DoCreateStation() const { NS_LOG_FUNCTION(this); - IdealWifiRemoteStation* station = new IdealWifiRemoteStation(); + auto station = new IdealWifiRemoteStation(); Reset(station); return station; } @@ -233,7 +233,7 @@ void IdealWifiManager::Reset(WifiRemoteStation* station) const { NS_LOG_FUNCTION(this << station); - IdealWifiRemoteStation* st = static_cast(station); + auto st = static_cast(station); st->m_lastSnrObserved = 0.0; st->m_lastChannelWidthObserved = 0; st->m_lastNssObserved = 1; @@ -268,7 +268,7 @@ IdealWifiManager::DoReportRtsOk(WifiRemoteStation* st, double rtsSnr) { NS_LOG_FUNCTION(this << st << ctsSnr << ctsMode.GetUniqueName() << rtsSnr); - IdealWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_lastSnrObserved = rtsSnr; station->m_lastChannelWidthObserved = GetPhy()->GetChannelWidth() >= 40 ? 20 : GetPhy()->GetChannelWidth(); @@ -285,7 +285,7 @@ IdealWifiManager::DoReportDataOk(WifiRemoteStation* st, { NS_LOG_FUNCTION(this << st << ackSnr << ackMode.GetUniqueName() << dataSnr << dataChannelWidth << +dataNss); - IdealWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); if (dataSnr == 0) { NS_LOG_WARN("DataSnr reported to be zero; not saving this report."); @@ -307,7 +307,7 @@ IdealWifiManager::DoReportAmpduTxStatus(WifiRemoteStation* st, { NS_LOG_FUNCTION(this << st << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr << dataChannelWidth << +dataNss); - IdealWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); if (dataSnr == 0) { NS_LOG_WARN("DataSnr reported to be zero; not saving this report."); @@ -336,7 +336,7 @@ WifiTxVector IdealWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth) { NS_LOG_FUNCTION(this << st << allowedWidth); - IdealWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); // We search within the Supported rate set the mode with the // highest data rate for which the SNR threshold is smaller than m_lastSnr // to ensure correct packet delivery. @@ -586,7 +586,7 @@ WifiTxVector IdealWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - IdealWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); // We search within the Basic rate set the mode with the highest // SNR threshold possible which is smaller than m_lastSnr to // ensure correct packet delivery. diff --git a/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc b/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc index 851765124..bdfac643b 100644 --- a/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc +++ b/src/wifi/model/rate-control/minstrel-ht-wifi-manager.cc @@ -480,7 +480,7 @@ WifiRemoteStation* MinstrelHtWifiManager::DoCreateStation() const { NS_LOG_FUNCTION(this); - MinstrelHtWifiRemoteStation* station = new MinstrelHtWifiRemoteStation(); + auto station = new MinstrelHtWifiRemoteStation(); // Initialize variables common to both stations. station->m_nextStatsUpdate = Simulator::Now() + m_updateStats; @@ -572,7 +572,7 @@ void MinstrelHtWifiManager::DoReportRtsFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - MinstrelHtWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); if (!station->m_initialized) { @@ -595,7 +595,7 @@ void MinstrelHtWifiManager::DoReportFinalRtsFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - MinstrelHtWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); NS_LOG_DEBUG("Final RTS failed"); CheckInit(station); if (!station->m_initialized) @@ -609,7 +609,7 @@ void MinstrelHtWifiManager::DoReportDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - MinstrelHtWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); if (!station->m_initialized) @@ -644,7 +644,7 @@ MinstrelHtWifiManager::DoReportDataOk(WifiRemoteStation* st, uint8_t dataNss) { NS_LOG_FUNCTION(this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss); - MinstrelHtWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); if (!station->m_initialized) @@ -716,7 +716,7 @@ void MinstrelHtWifiManager::DoReportFinalDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - MinstrelHtWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); if (!station->m_initialized) @@ -770,7 +770,7 @@ MinstrelHtWifiManager::DoReportAmpduTxStatus(WifiRemoteStation* st, { NS_LOG_FUNCTION(this << st << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr << dataChannelWidth << +dataNss); - MinstrelHtWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); if (!station->m_initialized) @@ -1023,7 +1023,7 @@ WifiTxVector MinstrelHtWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth) { NS_LOG_FUNCTION(this << st << allowedWidth); - MinstrelHtWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); if (!station->m_initialized) { @@ -1096,7 +1096,7 @@ WifiTxVector MinstrelHtWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - MinstrelHtWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); if (!station->m_initialized) { @@ -1182,7 +1182,7 @@ MinstrelHtWifiManager::DoNeedRetransmission(WifiRemoteStation* st, { NS_LOG_FUNCTION(this << st << packet << normally); - MinstrelHtWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); if (!station->m_initialized) diff --git a/src/wifi/model/rate-control/minstrel-wifi-manager.cc b/src/wifi/model/rate-control/minstrel-wifi-manager.cc index 768f0f6d2..180dd14fb 100644 --- a/src/wifi/model/rate-control/minstrel-wifi-manager.cc +++ b/src/wifi/model/rate-control/minstrel-wifi-manager.cc @@ -178,7 +178,7 @@ WifiRemoteStation* MinstrelWifiManager::DoCreateStation() const { NS_LOG_FUNCTION(this); - MinstrelWifiRemoteStation* station = new MinstrelWifiRemoteStation(); + auto station = new MinstrelWifiRemoteStation(); station->m_nextStatsUpdate = Simulator::Now() + m_updateStats; station->m_col = 0; @@ -779,7 +779,7 @@ void MinstrelWifiManager::DoReportRtsFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - MinstrelWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); NS_LOG_DEBUG("DoReportRtsFailed m_txrate=" << station->m_txrate); station->m_shortRetry++; } @@ -797,7 +797,7 @@ void MinstrelWifiManager::DoReportFinalRtsFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - MinstrelWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); UpdateRetry(station); } @@ -805,7 +805,7 @@ void MinstrelWifiManager::DoReportDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - MinstrelWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); NS_LOG_DEBUG("DoReportDataFailed " << station << "\t rate " << station->m_txrate << "\tlongRetry \t" << station->m_longRetry); CheckInit(station); @@ -826,7 +826,7 @@ MinstrelWifiManager::DoReportDataOk(WifiRemoteStation* st, uint8_t dataNss) { NS_LOG_FUNCTION(this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss); - MinstrelWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); if (!station->m_initialized) @@ -865,7 +865,7 @@ void MinstrelWifiManager::DoReportFinalDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - MinstrelWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); if (!station->m_initialized) @@ -939,7 +939,7 @@ WifiTxVector MinstrelWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth) { NS_LOG_FUNCTION(this << st << allowedWidth); - MinstrelWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); return GetDataTxVector(station); } @@ -947,7 +947,7 @@ WifiTxVector MinstrelWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - MinstrelWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); return GetRtsTxVector(station); } @@ -957,7 +957,7 @@ MinstrelWifiManager::DoNeedRetransmission(WifiRemoteStation* st, bool normally) { NS_LOG_FUNCTION(this << st << packet << normally); - MinstrelWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); if (!station->m_initialized) diff --git a/src/wifi/model/rate-control/onoe-wifi-manager.cc b/src/wifi/model/rate-control/onoe-wifi-manager.cc index 11bfbff5e..705d1a542 100644 --- a/src/wifi/model/rate-control/onoe-wifi-manager.cc +++ b/src/wifi/model/rate-control/onoe-wifi-manager.cc @@ -115,7 +115,7 @@ WifiRemoteStation* OnoeWifiManager::DoCreateStation() const { NS_LOG_FUNCTION(this); - OnoeWifiRemoteStation* station = new OnoeWifiRemoteStation(); + auto station = new OnoeWifiRemoteStation(); station->m_nextModeUpdate = Simulator::Now() + m_updatePeriod; station->m_rateBlocked = false; station->m_shortRetry = 0; @@ -138,7 +138,7 @@ void OnoeWifiManager::DoReportRtsFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - OnoeWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_shortRetry++; station->m_rateBlocked = true; // do not change rate for retransmission } @@ -147,7 +147,7 @@ void OnoeWifiManager::DoReportDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - OnoeWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_longRetry++; station->m_rateBlocked = true; // do not change rate for retransmission } @@ -159,7 +159,7 @@ OnoeWifiManager::DoReportRtsOk(WifiRemoteStation* st, double rtsSnr) { NS_LOG_FUNCTION(this << st << ctsSnr << ctsMode << rtsSnr); - OnoeWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_rateBlocked = true; // do not change rate } @@ -172,7 +172,7 @@ OnoeWifiManager::DoReportDataOk(WifiRemoteStation* st, uint8_t dataNss) { NS_LOG_FUNCTION(this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss); - OnoeWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); UpdateRetry(station); station->m_tx_ok++; station->m_rateBlocked = false; // we can change the rate for next packet @@ -182,7 +182,7 @@ void OnoeWifiManager::DoReportFinalRtsFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - OnoeWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); UpdateRetry(station); station->m_tx_err++; station->m_rateBlocked = false; // we can change the rate for next packet @@ -192,7 +192,7 @@ void OnoeWifiManager::DoReportFinalDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - OnoeWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); UpdateRetry(station); station->m_tx_err++; station->m_rateBlocked = false; // we can change the rate for next packet @@ -293,7 +293,7 @@ WifiTxVector OnoeWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth) { NS_LOG_FUNCTION(this << st << allowedWidth); - OnoeWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); UpdateMode(station); NS_ASSERT(station->m_txrate < GetNSupported(station)); uint8_t rateIndex; @@ -362,7 +362,7 @@ WifiTxVector OnoeWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - OnoeWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { diff --git a/src/wifi/model/rate-control/parf-wifi-manager.cc b/src/wifi/model/rate-control/parf-wifi-manager.cc index 9222cd81d..e9e76f4b3 100644 --- a/src/wifi/model/rate-control/parf-wifi-manager.cc +++ b/src/wifi/model/rate-control/parf-wifi-manager.cc @@ -126,7 +126,7 @@ WifiRemoteStation* ParfWifiManager::DoCreateStation() const { NS_LOG_FUNCTION(this); - ParfWifiRemoteStation* station = new ParfWifiRemoteStation(); + auto station = new ParfWifiRemoteStation(); station->m_nSuccess = 0; station->m_nFail = 0; @@ -155,7 +155,7 @@ ParfWifiManager::CheckInit(ParfWifiRemoteStation* station) station->m_prevPowerLevel = m_maxPower; WifiMode mode = GetSupported(station, station->m_rateIndex); uint16_t channelWidth = GetChannelWidth(station); - DataRate rate = DataRate(mode.GetDataRate(channelWidth)); + DataRate rate(mode.GetDataRate(channelWidth)); double power = GetPhy()->GetPowerDbm(m_maxPower); m_powerChange(power, power, station->m_state->m_address); m_rateChange(rate, rate, station->m_state->m_address); @@ -182,7 +182,7 @@ void ParfWifiManager::DoReportDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - ParfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); station->m_nAttempt++; station->m_nFail++; @@ -273,7 +273,7 @@ ParfWifiManager::DoReportDataOk(WifiRemoteStation* st, uint8_t dataNss) { NS_LOG_FUNCTION(this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss); - ParfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); station->m_nAttempt++; station->m_nSuccess++; @@ -323,7 +323,7 @@ WifiTxVector ParfWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth) { NS_LOG_FUNCTION(this << st << allowedWidth); - ParfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { @@ -331,9 +331,8 @@ ParfWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth) } CheckInit(station); WifiMode mode = GetSupported(station, station->m_rateIndex); - DataRate rate = DataRate(mode.GetDataRate(channelWidth)); - DataRate prevRate = - DataRate(GetSupported(station, station->m_prevRateIndex).GetDataRate(channelWidth)); + DataRate rate(mode.GetDataRate(channelWidth)); + DataRate prevRate(GetSupported(station, station->m_prevRateIndex).GetDataRate(channelWidth)); double power = GetPhy()->GetPowerDbm(station->m_powerLevel); double prevPower = GetPhy()->GetPowerDbm(station->m_prevPowerLevel); if (station->m_prevPowerLevel != station->m_powerLevel) @@ -364,7 +363,7 @@ ParfWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) NS_LOG_FUNCTION(this << st); /// \todo we could/should implement the ARF algorithm for /// RTS only by picking a single rate within the BasicRateSet. - ParfWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { diff --git a/src/wifi/model/rate-control/rraa-wifi-manager.cc b/src/wifi/model/rate-control/rraa-wifi-manager.cc index 1cd4943fb..278e64f9b 100644 --- a/src/wifi/model/rate-control/rraa-wifi-manager.cc +++ b/src/wifi/model/rate-control/rraa-wifi-manager.cc @@ -169,7 +169,7 @@ Time RraaWifiManager::GetCalcTxTime(WifiMode mode) const { NS_LOG_FUNCTION(this << mode); - for (TxTime::const_iterator i = m_calcTxTime.begin(); i != m_calcTxTime.end(); i++) + for (auto i = m_calcTxTime.begin(); i != m_calcTxTime.end(); i++) { if (mode == i->second) { @@ -192,9 +192,7 @@ RraaWifiManager::GetThresholds(RraaWifiRemoteStation* station, WifiMode mode) co { NS_LOG_FUNCTION(this << station << mode); WifiRraaThresholds threshold; - for (RraaThresholdsTable::const_iterator i = station->m_thresholds.begin(); - i != station->m_thresholds.end(); - i++) + for (auto i = station->m_thresholds.begin(); i != station->m_thresholds.end(); i++) { if (mode == i->second) { @@ -208,7 +206,7 @@ RraaWifiManager::GetThresholds(RraaWifiRemoteStation* station, WifiMode mode) co WifiRemoteStation* RraaWifiManager::DoCreateStation() const { - RraaWifiRemoteStation* station = new RraaWifiRemoteStation(); + auto station = new RraaWifiRemoteStation(); station->m_initialized = false; station->m_adaptiveRtsWnd = 0; station->m_rtsCounter = 0; @@ -303,7 +301,7 @@ void RraaWifiManager::DoReportDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - RraaWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_lastFrameFail = true; CheckTimeout(station); station->m_counter--; @@ -335,7 +333,7 @@ RraaWifiManager::DoReportDataOk(WifiRemoteStation* st, uint8_t dataNss) { NS_LOG_FUNCTION(this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss); - RraaWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); station->m_lastFrameFail = false; CheckTimeout(station); station->m_counter--; @@ -358,7 +356,7 @@ WifiTxVector RraaWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth) { NS_LOG_FUNCTION(this << st << allowedWidth); - RraaWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { @@ -388,7 +386,7 @@ WifiTxVector RraaWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - RraaWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { @@ -419,7 +417,7 @@ bool RraaWifiManager::DoNeedRts(WifiRemoteStation* st, uint32_t size, bool normally) { NS_LOG_FUNCTION(this << st << size << normally); - RraaWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); if (m_basic) { diff --git a/src/wifi/model/rate-control/rrpaa-wifi-manager.cc b/src/wifi/model/rate-control/rrpaa-wifi-manager.cc index 09f85e251..ac95ff08d 100644 --- a/src/wifi/model/rate-control/rrpaa-wifi-manager.cc +++ b/src/wifi/model/rate-control/rrpaa-wifi-manager.cc @@ -198,7 +198,7 @@ Time RrpaaWifiManager::GetCalcTxTime(WifiMode mode) const { NS_LOG_FUNCTION(this << mode); - for (TxTime::const_iterator i = m_calcTxTime.begin(); i != m_calcTxTime.end(); i++) + for (auto i = m_calcTxTime.begin(); i != m_calcTxTime.end(); i++) { if (mode == i->second) { @@ -221,9 +221,7 @@ RrpaaWifiManager::GetThresholds(RrpaaWifiRemoteStation* station, WifiMode mode) { NS_LOG_FUNCTION(this << station << mode); WifiRrpaaThresholds threshold; - for (RrpaaThresholdsTable::const_iterator i = station->m_thresholds.begin(); - i != station->m_thresholds.end(); - i++) + for (auto i = station->m_thresholds.begin(); i != station->m_thresholds.end(); i++) { if (mode == i->second) { @@ -238,7 +236,7 @@ WifiRemoteStation* RrpaaWifiManager::DoCreateStation() const { NS_LOG_FUNCTION(this); - RrpaaWifiRemoteStation* station = new RrpaaWifiRemoteStation(); + auto station = new RrpaaWifiRemoteStation(); station->m_adaptiveRtsWnd = 0; station->m_rtsCounter = 0; station->m_adaptiveRtsOn = false; @@ -264,7 +262,7 @@ RrpaaWifiManager::CheckInit(RrpaaWifiRemoteStation* station) station->m_powerLevel = m_maxPowerLevel; WifiMode mode = GetSupported(station, 0); uint16_t channelWidth = GetChannelWidth(station); - DataRate rate = DataRate(mode.GetDataRate(channelWidth)); + DataRate rate(mode.GetDataRate(channelWidth)); double power = GetPhy()->GetPowerDbm(station->m_powerLevel); m_rateChange(rate, rate, station->m_state->m_address); m_powerChange(power, power, station->m_state->m_address); @@ -345,7 +343,7 @@ void RrpaaWifiManager::DoReportDataFailed(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - RrpaaWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); station->m_lastFrameFail = true; CheckTimeout(station); @@ -378,7 +376,7 @@ RrpaaWifiManager::DoReportDataOk(WifiRemoteStation* st, uint8_t dataNss) { NS_LOG_FUNCTION(this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss); - RrpaaWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); station->m_lastFrameFail = false; CheckTimeout(station); @@ -402,7 +400,7 @@ WifiTxVector RrpaaWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth) { NS_LOG_FUNCTION(this << st << allowedWidth); - RrpaaWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { @@ -410,9 +408,8 @@ RrpaaWifiManager::DoGetDataTxVector(WifiRemoteStation* st, uint16_t allowedWidth } CheckInit(station); WifiMode mode = GetSupported(station, station->m_rateIndex); - DataRate rate = DataRate(mode.GetDataRate(channelWidth)); - DataRate prevRate = - DataRate(GetSupported(station, station->m_prevRateIndex).GetDataRate(channelWidth)); + DataRate rate(mode.GetDataRate(channelWidth)); + DataRate prevRate(GetSupported(station, station->m_prevRateIndex).GetDataRate(channelWidth)); double power = GetPhy()->GetPowerDbm(station->m_powerLevel); double prevPower = GetPhy()->GetPowerDbm(station->m_prevPowerLevel); if (station->m_prevRateIndex != station->m_rateIndex) @@ -441,7 +438,7 @@ WifiTxVector RrpaaWifiManager::DoGetRtsTxVector(WifiRemoteStation* st) { NS_LOG_FUNCTION(this << st); - RrpaaWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); uint16_t channelWidth = GetChannelWidth(station); if (channelWidth > 20 && channelWidth != 22) { @@ -472,7 +469,7 @@ bool RrpaaWifiManager::DoNeedRts(WifiRemoteStation* st, uint32_t size, bool normally) { NS_LOG_FUNCTION(this << st << size << normally); - RrpaaWifiRemoteStation* station = static_cast(st); + auto station = static_cast(st); CheckInit(station); if (m_basic) { diff --git a/src/wifi/model/rate-control/thompson-sampling-wifi-manager.cc b/src/wifi/model/rate-control/thompson-sampling-wifi-manager.cc index 7da0ee9e8..4954dfadf 100644 --- a/src/wifi/model/rate-control/thompson-sampling-wifi-manager.cc +++ b/src/wifi/model/rate-control/thompson-sampling-wifi-manager.cc @@ -105,7 +105,7 @@ WifiRemoteStation* ThompsonSamplingWifiManager::DoCreateStation() const { NS_LOG_FUNCTION(this); - ThompsonSamplingWifiRemoteStation* station = new ThompsonSamplingWifiRemoteStation(); + auto station = new ThompsonSamplingWifiRemoteStation(); station->m_nextMode = 0; station->m_lastMode = 0; return station; diff --git a/src/wifi/model/supported-rates.cc b/src/wifi/model/supported-rates.cc index 7981b9e0b..b550942e5 100644 --- a/src/wifi/model/supported-rates.cc +++ b/src/wifi/model/supported-rates.cc @@ -95,7 +95,7 @@ AllSupportedRates::SetBasicRate(uint64_t bs) { NS_LOG_FUNCTION(this << bs); NS_ASSERT_MSG(IsBssMembershipSelectorRate(bs) == false, "Invalid rate"); - uint8_t rate = static_cast(bs / 500000); + auto rate = static_cast(bs / 500000); for (uint8_t i = 0; i < GetNRates(); i++) { auto& currRate = i < 8 ? rates.m_rates[i] : extendedRates->m_rates[i - 8]; @@ -121,7 +121,7 @@ AllSupportedRates::AddBssMembershipSelectorRate(uint64_t bs) NS_ASSERT_MSG(bs == BSS_MEMBERSHIP_SELECTOR_HT_PHY || bs == BSS_MEMBERSHIP_SELECTOR_VHT_PHY || bs == BSS_MEMBERSHIP_SELECTOR_HE_PHY || bs == BSS_MEMBERSHIP_SELECTOR_EHT_PHY, "Value " << bs << " not a BSS Membership Selector"); - uint8_t rate = static_cast(bs / 500000); + auto rate = static_cast(bs / 500000); for (std::size_t i = 0; i < rates.m_rates.size(); i++) { if (rate == rates.m_rates[i]) @@ -158,7 +158,7 @@ bool AllSupportedRates::IsSupportedRate(uint64_t bs) const { NS_LOG_FUNCTION(this << bs); - uint8_t rate = static_cast(bs / 500000); + auto rate = static_cast(bs / 500000); for (std::size_t i = 0; i < rates.m_rates.size(); i++) { if (rate == rates.m_rates[i] || (rate | 0x80) == rates.m_rates[i]) diff --git a/src/wifi/model/wifi-default-protection-manager.cc b/src/wifi/model/wifi-default-protection-manager.cc index 5586eefac..c435b7410 100644 --- a/src/wifi/model/wifi-default-protection-manager.cc +++ b/src/wifi/model/wifi-default-protection-manager.cc @@ -359,7 +359,6 @@ WifiDefaultProtectionManager::TryUlMuTransmission(Ptr mpdu, NS_ABORT_MSG_IF(m_mac->GetTypeOfStation() != AP, "HE APs only can send DL MU PPDUs"); const auto& staList = StaticCast(m_mac)->GetStaList(m_linkId); - std::remove_reference_t::const_iterator staIt; bool allProtected = true; bool isUnprotectedEmlsrDst = false; @@ -369,7 +368,7 @@ WifiDefaultProtectionManager::TryUlMuTransmission(Ptr mpdu, // Add a User Info field to the MU-RTS for this solicited station // The UL HE-MCS, UL FEC Coding Type, UL DCM, SS Allocation and UL Target RSSI fields // in the User Info field are reserved (Sec. 9.3.1.22.5 of 802.11ax) - staIt = staList.find(userInfo.GetAid12()); + auto staIt = staList.find(userInfo.GetAid12()); NS_ASSERT(staIt != staList.cend()); AddUserInfoToMuRts(protection->muRts, txWidth, staIt->second); bool isProtected = diff --git a/src/wifi/model/wifi-mac-header.cc b/src/wifi/model/wifi-mac-header.cc index d5c65dbfe..7c561d538 100644 --- a/src/wifi/model/wifi-mac-header.cc +++ b/src/wifi/model/wifi-mac-header.cc @@ -308,7 +308,7 @@ WifiMacHeader::SetRawDuration(uint16_t duration) void WifiMacHeader::SetDuration(Time duration) { - int64_t duration_us = + auto duration_us = static_cast(ceil(static_cast(duration.GetNanoSeconds()) / 1000)); NS_ASSERT(duration_us >= 0 && duration_us <= 0x7fff); m_duration = static_cast(duration_us); diff --git a/src/wifi/model/wifi-mac-queue-container.cc b/src/wifi/model/wifi-mac-queue-container.cc index a50b8e654..f1a549186 100644 --- a/src/wifi/model/wifi-mac-queue-container.cc +++ b/src/wifi/model/wifi-mac-queue-container.cc @@ -123,8 +123,8 @@ std::pair WifiMacQueueContainer::DoExtractExpiredMpdus(ContainerQueue& queue) const { std::optional> ret; - iterator firstExpiredIt = queue.begin(); - iterator lastExpiredIt = firstExpiredIt; + auto firstExpiredIt = queue.begin(); + auto lastExpiredIt = firstExpiredIt; Time now = Simulator::Now(); do diff --git a/src/wifi/model/wifi-mac-queue.cc b/src/wifi/model/wifi-mac-queue.cc index ee2e743f2..7d98094ec 100644 --- a/src/wifi/model/wifi-mac-queue.cc +++ b/src/wifi/model/wifi-mac-queue.cc @@ -342,7 +342,7 @@ WifiMacQueue::PeekByQueueId(const WifiContainerQueueId& queueId, PtruniqueUid == name) { @@ -364,7 +363,7 @@ WifiModeFactory::Search(std::string name) const // is a fatal problem, but we try to be helpful by displaying the // list of WifiModes that are supported. NS_LOG_UNCOND("Could not find match for WifiMode named \"" << name << "\". Valid options are:"); - for (i = m_itemList.begin(); i != m_itemList.end(); i++) + for (auto i = m_itemList.begin(); i != m_itemList.end(); i++) { NS_LOG_UNCOND(" " << i->uniqueUid); } @@ -384,7 +383,7 @@ uint32_t WifiModeFactory::AllocateUid(std::string uniqueUid) { uint32_t j = 0; - for (WifiModeItemList::const_iterator i = m_itemList.begin(); i != m_itemList.end(); i++) + for (auto i = m_itemList.begin(); i != m_itemList.end(); i++) { if (i->uniqueUid == uniqueUid) { @@ -392,7 +391,7 @@ WifiModeFactory::AllocateUid(std::string uniqueUid) } j++; } - uint32_t uid = static_cast(m_itemList.size()); + auto uid = static_cast(m_itemList.size()); m_itemList.emplace_back(); return uid; } diff --git a/src/wifi/model/wifi-remote-station-manager.cc b/src/wifi/model/wifi-remote-station-manager.cc index 5e1eef9d5..2ec797f2c 100644 --- a/src/wifi/model/wifi-remote-station-manager.cc +++ b/src/wifi/model/wifi-remote-station-manager.cc @@ -1162,7 +1162,7 @@ WifiRemoteStationManager::NeedCtsToSelf(WifiTxVector txVector) { // search for the BSS Basic Rate set, if the used mode is in the basic set then there is no // need for CTS To Self - for (WifiModeListIterator i = m_bssBasicRateSet.begin(); i != m_bssBasicRateSet.end(); i++) + for (auto i = m_bssBasicRateSet.begin(); i != m_bssBasicRateSet.end(); i++) { if (mode == *i) { @@ -1174,8 +1174,7 @@ WifiRemoteStationManager::NeedCtsToSelf(WifiTxVector txVector) { // search for the BSS Basic MCS set, if the used mode is in the basic set then there is // no need for CTS To Self - for (WifiModeListIterator i = m_bssBasicMcsSet.begin(); i != m_bssBasicMcsSet.end(); - i++) + for (auto i = m_bssBasicMcsSet.begin(); i != m_bssBasicMcsSet.end(); i++) { if (mode == *i) { @@ -1761,7 +1760,7 @@ uint32_t WifiRemoteStationManager::GetNNonErpBasicModes() const { uint32_t size = 0; - for (WifiModeListIterator i = m_bssBasicRateSet.begin(); i != m_bssBasicRateSet.end(); i++) + for (auto i = m_bssBasicRateSet.begin(); i != m_bssBasicRateSet.end(); i++) { if (i->GetModulationClass() == WIFI_MOD_CLASS_ERP_OFDM) { @@ -1778,7 +1777,7 @@ WifiRemoteStationManager::GetNonErpBasicMode(uint8_t i) const NS_ASSERT(i < GetNNonErpBasicModes()); uint32_t index = 0; bool found = false; - for (WifiModeListIterator j = m_bssBasicRateSet.begin(); j != m_bssBasicRateSet.end();) + for (auto j = m_bssBasicRateSet.begin(); j != m_bssBasicRateSet.end();) { if (i == index) { @@ -1902,7 +1901,7 @@ WifiRemoteStationManager::GetNonErpSupported(const WifiRemoteStation* station, u // moved in case it breaks standard rules. uint32_t index = 0; bool found = false; - for (WifiModeListIterator j = station->m_state->m_operationalRateSet.begin(); + for (auto j = station->m_state->m_operationalRateSet.begin(); j != station->m_state->m_operationalRateSet.end();) { if (i == index) @@ -2048,7 +2047,7 @@ uint32_t WifiRemoteStationManager::GetNNonErpSupported(const WifiRemoteStation* station) const { uint32_t size = 0; - for (WifiModeListIterator i = station->m_state->m_operationalRateSet.begin(); + for (auto i = station->m_state->m_operationalRateSet.begin(); i != station->m_state->m_operationalRateSet.end(); i++) { diff --git a/src/wifi/model/yans-wifi-channel.cc b/src/wifi/model/yans-wifi-channel.cc index 7c341fb2b..c4bbd9503 100644 --- a/src/wifi/model/yans-wifi-channel.cc +++ b/src/wifi/model/yans-wifi-channel.cc @@ -92,7 +92,7 @@ YansWifiChannel::Send(Ptr sender, Ptr ppdu, double NS_LOG_FUNCTION(this << sender << ppdu << txPowerDbm); Ptr senderMobility = sender->GetMobility(); NS_ASSERT(senderMobility); - for (PhyList::const_iterator i = m_phyList.begin(); i != m_phyList.end(); i++) + for (auto i = m_phyList.begin(); i != m_phyList.end(); i++) { if (sender != (*i)) { diff --git a/src/wifi/test/block-ack-test-suite.cc b/src/wifi/test/block-ack-test-suite.cc index 96de051cd..e4bca2fa2 100644 --- a/src/wifi/test/block-ack-test-suite.cc +++ b/src/wifi/test/block-ack-test-suite.cc @@ -1284,7 +1284,7 @@ MultiStaCtrlBAckResponseHeaderTest::DoRun() uint16_t aid6 = 2045; bool ackType6 = true; uint8_t tid6 = 6; - Mac48Address address6 = Mac48Address("00:00:00:00:00:01"); + Mac48Address address6("00:00:00:00:00:01"); blockAck.SetAid11(aid6, 5); blockAck.SetAckType(ackType6, 5); diff --git a/src/wifi/test/channel-access-manager-test.cc b/src/wifi/test/channel-access-manager-test.cc index cab604fc4..cd2d0d3c3 100644 --- a/src/wifi/test/channel-access-manager-test.cc +++ b/src/wifi/test/channel-access-manager-test.cc @@ -650,7 +650,7 @@ ChannelAccessManagerTest::EndTest() { Simulator::Run(); - for (typename TxopTests::const_iterator i = m_txop.begin(); i != m_txop.end(); i++) + for (auto i = m_txop.begin(); i != m_txop.end(); i++) { Ptr> state = *i; NS_TEST_EXPECT_MSG_EQ(state->m_expectedGrants.empty(), true, "Have no expected grants"); diff --git a/src/wifi/test/spectrum-wifi-phy-test.cc b/src/wifi/test/spectrum-wifi-phy-test.cc index b2e974be2..8fd2762f0 100644 --- a/src/wifi/test/spectrum-wifi-phy-test.cc +++ b/src/wifi/test/spectrum-wifi-phy-test.cc @@ -716,7 +716,7 @@ SpectrumWifiPhyFilterTest::RunOne() { for (unsigned int type = 0; type < 7; type++) { - HeRu::RuType ruType = static_cast(type); + auto ruType = static_cast(type); for (std::size_t index = 1; index <= HeRu::GetNRus(bw, ruType); index++) { HeRu::SubcarrierGroup subcarrierGroup = diff --git a/src/wifi/test/wifi-primary-channels-test.cc b/src/wifi/test/wifi-primary-channels-test.cc index 4916ba1c9..28ff9a088 100644 --- a/src/wifi/test/wifi-primary-channels-test.cc +++ b/src/wifi/test/wifi-primary-channels-test.cc @@ -665,7 +665,7 @@ WifiPrimaryChannelsTest::DoRun() { for (unsigned int type = 0; type < 7; type++) { - HeRu::RuType ruType = static_cast(type); + auto ruType = static_cast(type); std::size_t nRus = HeRu::GetNRus(txChannelWidth, ruType); std::set txBss; if (nRus > 0) @@ -713,7 +713,7 @@ WifiPrimaryChannelsTest::DoRun() { for (unsigned int type = 0; type < 7; type++) { - HeRu::RuType ruType = static_cast(type); + auto ruType = static_cast(type); std::size_t nRus = HeRu::GetNRus(txChannelWidth, ruType); std::set txBss; if (nRus > 0) diff --git a/src/wifi/test/wifi-test.cc b/src/wifi/test/wifi-test.cc index 4c83e9c37..f57135af6 100644 --- a/src/wifi/test/wifi-test.cc +++ b/src/wifi/test/wifi-test.cc @@ -1578,9 +1578,7 @@ Bug2843TestCase::StoreDistinctTuple(std::string context, Ptr::const_iterator it = m_distinctTuples.begin(); - it != m_distinctTuples.end(); - it++) + for (auto it = m_distinctTuples.begin(); it != m_distinctTuples.end(); it++) { if (*it == tupleForCurrentTx) { diff --git a/src/wimax/examples/wimax-ipv4.cc b/src/wimax/examples/wimax-ipv4.cc index 0afa3eac2..c074595ce 100644 --- a/src/wimax/examples/wimax-ipv4.cc +++ b/src/wimax/examples/wimax-ipv4.cc @@ -117,7 +117,7 @@ main(int argc, char* argv[]) WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler); - Ptr* ss = new Ptr[nbSS]; + auto ss = new Ptr[nbSS]; for (int i = 0; i < nbSS; i++) { @@ -146,10 +146,10 @@ main(int argc, char* argv[]) WimaxHelper::EnableLogComponents(); // Turn on all wimax logging } /*------------------------------*/ - UdpServerHelper* udpServer = new UdpServerHelper[nbSS / 2]; - ApplicationContainer* serverApps = new ApplicationContainer[nbSS / 2]; - UdpClientHelper* udpClient = new UdpClientHelper[nbSS / 2]; - ApplicationContainer* clientApps = new ApplicationContainer[nbSS / 2]; + auto udpServer = new UdpServerHelper[nbSS / 2]; + auto serverApps = new ApplicationContainer[nbSS / 2]; + auto udpClient = new UdpClientHelper[nbSS / 2]; + auto clientApps = new ApplicationContainer[nbSS / 2]; for (int i = 0; i < nbSS / 2; i++) { diff --git a/src/wimax/helper/wimax-helper.cc b/src/wimax/helper/wimax-helper.cc index 0f5408b1c..62deae249 100644 --- a/src/wimax/helper/wimax-helper.cc +++ b/src/wimax/helper/wimax-helper.cc @@ -224,7 +224,7 @@ WimaxHelper::Install(NodeContainer c, double frameDuration) { NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { Ptr node = *i; Ptr phy = CreatePhy(phyType); @@ -268,7 +268,7 @@ WimaxHelper::Install(NodeContainer c, SchedulerType schedulerType) { NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { Ptr node = *i; Ptr phy = CreatePhy(phyType); @@ -309,7 +309,7 @@ WimaxHelper::Install(NodeContainer c, SchedulerType schedulerType) { NetDeviceContainer devices; - for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++) + for (auto i = c.Begin(); i != c.End(); i++) { Ptr node = *i; @@ -637,7 +637,7 @@ static void PcapSniffTxRxEvent(Ptr file, Ptr burst) { std::list> packets = burst->GetPackets(); - for (std::list>::iterator iter = packets.begin(); iter != packets.end(); ++iter) + for (auto iter = packets.begin(); iter != packets.end(); ++iter) { Ptr p = (*iter)->Copy(); WimaxMacToMacHeader m2m(p->GetSize()); @@ -696,7 +696,7 @@ WimaxHelper::AssignStreams(NetDeviceContainer c, int64_t stream) { int64_t currentStream = stream; Ptr netDevice; - for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i) + for (auto i = c.Begin(); i != c.End(); ++i) { netDevice = (*i); Ptr wimax = DynamicCast(netDevice); diff --git a/src/wimax/model/bandwidth-manager.cc b/src/wimax/model/bandwidth-manager.cc index 1294ded83..a44e48da4 100644 --- a/src/wimax/model/bandwidth-manager.cc +++ b/src/wimax/model/bandwidth-manager.cc @@ -129,9 +129,7 @@ BandwidthManager::SelectFlowForRequest(uint32_t& bytesToRequest) std::vector serviceFlows = ss->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_ALL); - for (std::vector::iterator iter = serviceFlows.begin(); - iter != serviceFlows.end(); - ++iter) + for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) { serviceFlow = *iter; if (serviceFlow->GetSchedulingType() == ServiceFlow::SF_TYPE_RTPS || @@ -229,15 +227,11 @@ BandwidthManager::GetSymbolsPerFrameAllocated() uint32_t allocationPerFrame = 0; std::vector* ssRecords = bs->GetSSManager()->GetSSRecords(); - for (std::vector::const_iterator iter1 = ssRecords->begin(); - iter1 != ssRecords->end(); - ++iter1) + for (auto iter1 = ssRecords->begin(); iter1 != ssRecords->end(); ++iter1) { std::vector ssServiceFlows = (*iter1)->GetServiceFlows(ServiceFlow::SF_TYPE_ALL); - for (std::vector::const_iterator iter2 = ssServiceFlows.begin(); - iter2 != ssServiceFlows.end(); - ++iter2) + for (auto iter2 = ssServiceFlows.begin(); iter2 != ssServiceFlows.end(); ++iter2) { allocationPerFrame += (*iter2)->GetRecord()->GetGrantSize(); } diff --git a/src/wimax/model/bs-link-manager.cc b/src/wimax/model/bs-link-manager.cc index ff865e4c2..910920a61 100644 --- a/src/wimax/model/bs-link-manager.cc +++ b/src/wimax/model/bs-link-manager.cc @@ -257,7 +257,7 @@ BSLinkManager::VerifyInvitedRanging(Cid cid, uint8_t uiuc) if (ssRecord->GetInvitedRangRetries() == m_bs->GetMaxInvitedRangRetries()) { - RngRsp* rngrsp = new RngRsp(); + auto rngrsp = new RngRsp(); AbortRanging(ssRecord->GetBasicCid(), rngrsp, ssRecord, true); } // else keep polling } diff --git a/src/wimax/model/bs-net-device.cc b/src/wimax/model/bs-net-device.cc index cee21dfa5..1d954f09b 100644 --- a/src/wimax/model/bs-net-device.cc +++ b/src/wimax/model/bs-net-device.cc @@ -851,9 +851,7 @@ BaseStationNetDevice::DoReceive(Ptr packet) // DEFRAGMENTATION NS_LOG_INFO("\t BS PACKET DEFRAGMENTATION" << std::endl); - for (std::list>::const_iterator iter = fragmentsQueue.begin(); - iter != fragmentsQueue.end(); - ++iter) + for (auto iter = fragmentsQueue.begin(); iter != fragmentsQueue.end(); ++iter) { // Create the whole Packet fullPacket->AddAtEnd(*iter); @@ -1029,10 +1027,7 @@ BaseStationNetDevice::CreateDlMap() std::list>>* downlinkBursts = m_scheduler->GetDownlinkBursts(); - for (std::list>>::iterator iter = - downlinkBursts->begin(); - iter != downlinkBursts->end(); - ++iter) + for (auto iter = downlinkBursts->begin(); iter != downlinkBursts->end(); ++iter) { iter->first->SetPreamblePresent(0); iter->first->SetStartTime(0); @@ -1096,9 +1091,7 @@ BaseStationNetDevice::CreateUlMap() std::list uplinkAllocations = m_uplinkScheduler->GetUplinkAllocations(); - for (std::list::iterator iter = uplinkAllocations.begin(); - iter != uplinkAllocations.end(); - ++iter) + for (auto iter = uplinkAllocations.begin(); iter != uplinkAllocations.end(); ++iter) { ulmap.AddUlMapElement(*iter); } @@ -1197,9 +1190,7 @@ BaseStationNetDevice::MarkUplinkAllocations() { uint16_t symbolsToAllocation = 0; std::list uplinkAllocations = m_uplinkScheduler->GetUplinkAllocations(); - for (std::list::iterator iter = uplinkAllocations.begin(); - iter != uplinkAllocations.end(); - ++iter) + for (auto iter = uplinkAllocations.begin(); iter != uplinkAllocations.end(); ++iter) { OfdmUlMapIe uplinkAllocation = *iter; diff --git a/src/wimax/model/bs-scheduler-rtps.cc b/src/wimax/model/bs-scheduler-rtps.cc index 06b0ce945..bda677d3b 100644 --- a/src/wimax/model/bs-scheduler-rtps.cc +++ b/src/wimax/model/bs-scheduler-rtps.cc @@ -96,7 +96,7 @@ BSSchedulerRtps::AddDownlinkBurst(Ptr connection, WimaxPhy::ModulationType modulationType, Ptr burst) { - OfdmDlMapIe* dlMapIe = new OfdmDlMapIe(); + auto dlMapIe = new OfdmDlMapIe(); dlMapIe->SetCid(connection->GetCid()); dlMapIe->SetDiuc(diuc); @@ -319,11 +319,10 @@ BSSchedulerRtps::BSSchedulerBasicConnection(uint32_t& availableSymbols) Ptr packet; Ptr burst = Create(); - std::vector>::const_iterator iter; std::vector> connections; connections = GetBs()->GetConnectionManager()->GetConnections(Cid::BASIC); - for (iter = connections.begin(); iter != connections.end(); ++iter) + for (auto iter = connections.begin(); iter != connections.end(); ++iter) { while ((*iter)->HasPackets() && availableSymbols > 0) { @@ -381,11 +380,10 @@ BSSchedulerRtps::BSSchedulerPrimaryConnection(uint32_t& availableSymbols) Ptr packet; Ptr burst = Create(); - std::vector>::const_iterator iter; std::vector> connections; connections = GetBs()->GetConnectionManager()->GetConnections(Cid::PRIMARY); - for (iter = connections.begin(); iter != connections.end(); ++iter) + for (auto iter = connections.begin(); iter != connections.end(); ++iter) { while ((*iter)->HasPackets() && availableSymbols > 0) { @@ -444,12 +442,11 @@ BSSchedulerRtps::BSSchedulerUGSConnection(uint32_t& availableSymbols) Time currentTime = Simulator::Now(); - std::vector::iterator iter; ServiceFlowRecord* serviceFlowRecord; std::vector serviceFlows; serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_UGS); - for (iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) + for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) { serviceFlowRecord = (*iter)->GetRecord(); // if latency would exceed in case grant is allocated in next frame then allocate in current @@ -503,7 +500,6 @@ BSSchedulerRtps::BSSchedulerRTPSConnection(uint32_t& availableSymbols) Time currentTime = Simulator::Now(); std::vector> connections; - std::vector::iterator iter2; ServiceFlowRecord* serviceFlowRecord; std::vector serviceFlows; @@ -520,7 +516,7 @@ BSSchedulerRtps::BSSchedulerRTPSConnection(uint32_t& availableSymbols) serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_RTPS); nbConnection = 0; - for (iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) + for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) { // DL RTPS Scheduler works for all rtPS connection that have packets to transmitt!!! serviceFlowRecord = (*iter2)->GetRecord(); @@ -644,11 +640,10 @@ BSSchedulerRtps::BSSchedulerNRTPSConnection(uint32_t& availableSymbols) Ptr packet; Ptr burst = Create(); - std::vector::iterator iter; std::vector serviceFlows; serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_NRTPS); - for (iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) + for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) { connection = (*iter)->GetConnection(); @@ -702,11 +697,10 @@ BSSchedulerRtps::BSSchedulerBEConnection(uint32_t& availableSymbols) Ptr packet; Ptr burst = Create(); - std::vector::iterator iter; std::vector serviceFlows; serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_BE); - for (iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) + for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) { connection = (*iter)->GetConnection(); diff --git a/src/wimax/model/bs-scheduler-simple.cc b/src/wimax/model/bs-scheduler-simple.cc index 60dfff52f..8ad393dbf 100644 --- a/src/wimax/model/bs-scheduler-simple.cc +++ b/src/wimax/model/bs-scheduler-simple.cc @@ -94,7 +94,7 @@ BSSchedulerSimple::AddDownlinkBurst(Ptr connection, WimaxPhy::ModulationType modulationType, Ptr burst) { - OfdmDlMapIe* dlMapIe = new OfdmDlMapIe(); + auto dlMapIe = new OfdmDlMapIe(); dlMapIe->SetCid(connection->GetCid()); dlMapIe->SetDiuc(diuc); @@ -243,8 +243,6 @@ BSSchedulerSimple::SelectConnection(Ptr& connection) { connection = nullptr; Time currentTime = Simulator::Now(); - std::vector>::const_iterator iter1; - std::vector::iterator iter2; ServiceFlowRecord* serviceFlowRecord; NS_LOG_INFO("BS Scheduler: Selecting connection..."); if (GetBs()->GetBroadcastConnection()->HasPackets()) @@ -265,7 +263,7 @@ BSSchedulerSimple::SelectConnection(Ptr& connection) std::vector serviceFlows; connections = GetBs()->GetConnectionManager()->GetConnections(Cid::BASIC); - for (iter1 = connections.begin(); iter1 != connections.end(); ++iter1) + for (auto iter1 = connections.begin(); iter1 != connections.end(); ++iter1) { if ((*iter1)->HasPackets()) { @@ -276,7 +274,7 @@ BSSchedulerSimple::SelectConnection(Ptr& connection) } connections = GetBs()->GetConnectionManager()->GetConnections(Cid::PRIMARY); - for (iter1 = connections.begin(); iter1 != connections.end(); ++iter1) + for (auto iter1 = connections.begin(); iter1 != connections.end(); ++iter1) { if ((*iter1)->HasPackets()) { @@ -287,7 +285,7 @@ BSSchedulerSimple::SelectConnection(Ptr& connection) } serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_UGS); - for (iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) + for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) { serviceFlowRecord = (*iter2)->GetRecord(); NS_LOG_INFO("processing UGS: HAS PACKET=" @@ -310,7 +308,7 @@ BSSchedulerSimple::SelectConnection(Ptr& connection) } serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_RTPS); - for (iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) + for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) { serviceFlowRecord = (*iter2)->GetRecord(); // if latency would exceed in case poll is allocated in next frame then allocate in @@ -329,7 +327,7 @@ BSSchedulerSimple::SelectConnection(Ptr& connection) serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_NRTPS); - for (iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) + for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) { // unused: serviceFlowRecord = (*iter2)->GetRecord (); if ((*iter2)->HasPackets()) @@ -342,7 +340,7 @@ BSSchedulerSimple::SelectConnection(Ptr& connection) } serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_BE); - for (iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) + for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) { // unused: serviceFlowRecord = (*iter2)->GetRecord (); if ((*iter2)->HasPackets()) diff --git a/src/wimax/model/bs-service-flow-manager.cc b/src/wimax/model/bs-service-flow-manager.cc index ff77a495b..229b6e7dc 100644 --- a/src/wimax/model/bs-service-flow-manager.cc +++ b/src/wimax/model/bs-service-flow-manager.cc @@ -223,7 +223,7 @@ BsServiceFlowManager::ProcessDsaReq(const DsaReq& dsaReq, Cid cid) void BsServiceFlowManager::AddMulticastServiceFlow(ServiceFlow sf, WimaxPhy::ModulationType modulation) { - ServiceFlow* serviceFlow = new ServiceFlow(); + auto serviceFlow = new ServiceFlow(); serviceFlow->CopyParametersFrom(sf); Ptr bs = m_device->GetObject(); Ptr multicastConnection = diff --git a/src/wimax/model/bs-uplink-scheduler-mbqos.cc b/src/wimax/model/bs-uplink-scheduler-mbqos.cc index 57ba89695..59c40b109 100644 --- a/src/wimax/model/bs-uplink-scheduler-mbqos.cc +++ b/src/wimax/model/bs-uplink-scheduler-mbqos.cc @@ -175,17 +175,14 @@ UplinkSchedulerMBQoS::UplinkSchedWindowTimer() std::vector* ssRecords = GetBs()->GetSSManager()->GetSSRecords(); // For each SS - for (std::vector::iterator iter = ssRecords->begin(); iter != ssRecords->end(); - ++iter) + for (auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter) { SSRecord* ssRecord = *iter; std::vector serviceFlows = ssRecord->GetServiceFlows(ServiceFlow::SF_TYPE_ALL); // For each flow - for (std::vector::iterator iter2 = serviceFlows.begin(); - iter2 != serviceFlows.end(); - ++iter2) + for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) { ServiceFlow* serviceFlow = *iter2; if ((serviceFlow->GetSchedulingType() == ServiceFlow::SF_TYPE_RTPS) || @@ -235,8 +232,7 @@ UplinkSchedulerMBQoS::Schedule() AllocateInitialRangingInterval(symbolsToAllocation, availableSymbols); std::vector* ssRecords = GetBs()->GetSSManager()->GetSSRecords(); - for (std::vector::iterator iter = ssRecords->begin(); iter != ssRecords->end(); - ++iter) + for (auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter) { SSRecord* ssRecord = *iter; @@ -575,7 +571,7 @@ uint32_t UplinkSchedulerMBQoS::CountSymbolsQueue(std::list> jobs) { uint32_t symbols = 0; - for (std::list>::iterator iter = jobs.begin(); iter != jobs.end(); ++iter) + for (auto iter = jobs.begin(); iter != jobs.end(); ++iter) { Ptr job = *iter; @@ -683,7 +679,7 @@ UplinkSchedulerMBQoS::CheckDeadline(uint32_t& availableSymbols) // for each request in the intermediate queue if (!m_uplinkJobs_inter.empty()) { - std::list>::iterator iter = m_uplinkJobs_inter.begin(); + auto iter = m_uplinkJobs_inter.begin(); while (iter != m_uplinkJobs_inter.end() && availableSymbols) { @@ -776,15 +772,12 @@ UplinkSchedulerMBQoS::CheckMinimumBandwidth(uint32_t& availableSymbols) // For each connection of type rtPS or nrtPS std::vector* ssRecords = GetBs()->GetSSManager()->GetSSRecords(); - for (std::vector::iterator iter = ssRecords->begin(); iter != ssRecords->end(); - ++iter) + for (auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter) { SSRecord* ssRecord = *iter; std::vector serviceFlows = ssRecord->GetServiceFlows(ServiceFlow::SF_TYPE_ALL); - for (std::vector::iterator iter2 = serviceFlows.begin(); - iter2 != serviceFlows.end(); - ++iter2) + for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) { ServiceFlow* serviceFlow = *iter2; if (serviceFlow->GetSchedulingType() == ServiceFlow::SF_TYPE_RTPS || @@ -799,9 +792,7 @@ UplinkSchedulerMBQoS::CheckMinimumBandwidth(uint32_t& availableSymbols) } // for each request in the imermediate queue - for (std::list>::const_iterator iter = m_uplinkJobs_inter.begin(); - iter != m_uplinkJobs_inter.end(); - ++iter) + for (auto iter = m_uplinkJobs_inter.begin(); iter != m_uplinkJobs_inter.end(); ++iter) { Ptr job = *iter; // SSRecord ssRecord = job->GetSsRecord(); @@ -850,9 +841,7 @@ UplinkSchedulerMBQoS::CheckMinimumBandwidth(uint32_t& availableSymbols) priorityUlJobs.sort(SortProcessPtr()); - for (std::list>::const_iterator iter = priorityUlJobs.begin(); - iter != priorityUlJobs.end(); - ++iter) + for (auto iter = priorityUlJobs.begin(); iter != priorityUlJobs.end(); ++iter) { Ptr priorityUlJob = *iter; Ptr job_priority = priorityUlJob->GetUlJob(); @@ -879,9 +868,7 @@ UplinkSchedulerMBQoS::ServiceUnsolicitedGrants(const SSRecord* ssRecord, uint8_t uiuc = ulMapIe.GetUiuc(); // SS's burst profile std::vector serviceFlows = ssRecord->GetServiceFlows(schedulingType); - for (std::vector::iterator iter = serviceFlows.begin(); - iter != serviceFlows.end(); - ++iter) + for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) { ServiceFlow* serviceFlow = *iter; @@ -945,9 +932,7 @@ UplinkSchedulerMBQoS::ServiceBandwidthRequests(const SSRecord* ssRecord, { std::vector serviceFlows = ssRecord->GetServiceFlows(schedulingType); - for (std::vector::iterator iter = serviceFlows.begin(); - iter != serviceFlows.end(); - ++iter) + for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) { if (!ServiceBandwidthRequests(*iter, schedulingType, @@ -1127,9 +1112,7 @@ UplinkSchedulerMBQoS::GetPendingSize(ServiceFlow* serviceFlow) std::list> priorityUlJobs; // for each request in the imermediate queue - for (std::list>::const_iterator iter = m_uplinkJobs_inter.begin(); - iter != m_uplinkJobs_inter.end(); - ++iter) + for (auto iter = m_uplinkJobs_inter.begin(); iter != m_uplinkJobs_inter.end(); ++iter) { Ptr job = *iter; diff --git a/src/wimax/model/bs-uplink-scheduler-rtps.cc b/src/wimax/model/bs-uplink-scheduler-rtps.cc index bbbcb2283..d27221db4 100644 --- a/src/wimax/model/bs-uplink-scheduler-rtps.cc +++ b/src/wimax/model/bs-uplink-scheduler-rtps.cc @@ -183,8 +183,7 @@ UplinkSchedulerRtps::Schedule() std::vector* ssRecords = GetBs()->GetSSManager()->GetSSRecords(); NS_LOG_INFO("UL Scheduler start, availableSymbols = " << availableSymbols); - for (std::vector::iterator iter = ssRecords->begin(); iter != ssRecords->end(); - ++iter) + for (auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter) { SSRecord* ssRecord = *iter; if (ssRecord->GetIsBroadcastSS()) @@ -305,8 +304,7 @@ UplinkSchedulerRtps::Schedule() // UL Scheduler for nrtPS and BE flows if (availableSymbols) { - for (std::vector::iterator iter = ssRecords->begin(); iter != ssRecords->end(); - ++iter) + for (auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter) { SSRecord* ssRecord = *iter; if (ssRecord->GetIsBroadcastSS()) @@ -371,9 +369,7 @@ UplinkSchedulerRtps::ServiceUnsolicitedGrants(const SSRecord* ssRecord, uint8_t uiuc = ulMapIe.GetUiuc(); // SS's burst profile std::vector serviceFlows = ssRecord->GetServiceFlows(schedulingType); - for (std::vector::iterator iter = serviceFlows.begin(); - iter != serviceFlows.end(); - ++iter) + for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) { ServiceFlow* serviceFlow = *iter; @@ -458,9 +454,7 @@ UplinkSchedulerRtps::ServiceBandwidthRequests(const SSRecord* ssRecord, { std::vector serviceFlows = ssRecord->GetServiceFlows(schedulingType); - for (std::vector::iterator iter = serviceFlows.begin(); - iter != serviceFlows.end(); - ++iter) + for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) { if (!ServiceBandwidthRequests(*iter, schedulingType, @@ -550,8 +544,7 @@ UplinkSchedulerRtps::ULSchedulerRTPSConnection(uint32_t& symbolsToAllocation, Cid cid; std::vector* ssRecords = GetBs()->GetSSManager()->GetSSRecords(); - for (std::vector::iterator iter = ssRecords->begin(); iter != ssRecords->end(); - ++iter) + for (auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter) { SSRecord* ssRecord = *iter; if (ssRecord->GetIsBroadcastSS()) @@ -571,9 +564,7 @@ UplinkSchedulerRtps::ULSchedulerRTPSConnection(uint32_t& symbolsToAllocation, std::vector serviceFlows = ssRecord->GetServiceFlows(ServiceFlow::SF_TYPE_RTPS); - for (std::vector::iterator iter2 = serviceFlows.begin(); - iter2 != serviceFlows.end(); - ++iter2) + for (auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2) { record_[nbAllocation] = (*iter2)->GetRecord(); uint32_t requiredBandwidth = record_[nbAllocation]->GetRequestedBandwidth() - diff --git a/src/wimax/model/bs-uplink-scheduler-simple.cc b/src/wimax/model/bs-uplink-scheduler-simple.cc index d553f3740..f1f0e6983 100644 --- a/src/wimax/model/bs-uplink-scheduler-simple.cc +++ b/src/wimax/model/bs-uplink-scheduler-simple.cc @@ -182,8 +182,7 @@ UplinkSchedulerSimple::Schedule() AllocateInitialRangingInterval(symbolsToAllocation, availableSymbols); std::vector* ssRecords = GetBs()->GetSSManager()->GetSSRecords(); - for (std::vector::iterator iter = ssRecords->begin(); iter != ssRecords->end(); - ++iter) + for (auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter) { SSRecord* ssRecord = *iter; @@ -350,9 +349,7 @@ UplinkSchedulerSimple::ServiceUnsolicitedGrants(const SSRecord* ssRecord, uint8_t uiuc = ulMapIe.GetUiuc(); // SS's burst profile std::vector serviceFlows = ssRecord->GetServiceFlows(schedulingType); - for (std::vector::iterator iter = serviceFlows.begin(); - iter != serviceFlows.end(); - ++iter) + for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) { ServiceFlow* serviceFlow = *iter; @@ -423,9 +420,7 @@ UplinkSchedulerSimple::ServiceBandwidthRequests(const SSRecord* ssRecord, { std::vector serviceFlows = ssRecord->GetServiceFlows(schedulingType); - for (std::vector::iterator iter = serviceFlows.begin(); - iter != serviceFlows.end(); - ++iter) + for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) { if (!ServiceBandwidthRequests(*iter, schedulingType, diff --git a/src/wimax/model/burst-profile-manager.cc b/src/wimax/model/burst-profile-manager.cc index b9e0d6fc8..32c3db3d2 100644 --- a/src/wimax/model/burst-profile-manager.cc +++ b/src/wimax/model/burst-profile-manager.cc @@ -76,9 +76,7 @@ BurstProfileManager::GetModulationType(uint8_t iuc, WimaxNetDevice::Direction di { std::vector dlBurstProfiles = m_device->GetCurrentDcd().GetDlBurstProfiles(); - for (std::vector::iterator iter = dlBurstProfiles.begin(); - iter != dlBurstProfiles.end(); - ++iter) + for (auto iter = dlBurstProfiles.begin(); iter != dlBurstProfiles.end(); ++iter) { if (iter->GetDiuc() == iuc) { @@ -90,9 +88,7 @@ BurstProfileManager::GetModulationType(uint8_t iuc, WimaxNetDevice::Direction di { std::vector ulBurstProfiles = m_device->GetCurrentUcd().GetUlBurstProfiles(); - for (std::vector::iterator iter = ulBurstProfiles.begin(); - iter != ulBurstProfiles.end(); - ++iter) + for (auto iter = ulBurstProfiles.begin(); iter != ulBurstProfiles.end(); ++iter) { if (iter->GetUiuc() == iuc) { @@ -115,9 +111,7 @@ BurstProfileManager::GetBurstProfile(WimaxPhy::ModulationType modulationType, { std::vector dlBurstProfiles = m_device->GetCurrentDcd().GetDlBurstProfiles(); - for (std::vector::iterator iter = dlBurstProfiles.begin(); - iter != dlBurstProfiles.end(); - ++iter) + for (auto iter = dlBurstProfiles.begin(); iter != dlBurstProfiles.end(); ++iter) { if (iter->GetFecCodeType() == modulationType) { @@ -129,9 +123,7 @@ BurstProfileManager::GetBurstProfile(WimaxPhy::ModulationType modulationType, { std::vector ulBurstProfiles = m_device->GetCurrentUcd().GetUlBurstProfiles(); - for (std::vector::iterator iter = ulBurstProfiles.begin(); - iter != ulBurstProfiles.end(); - ++iter) + for (auto iter = ulBurstProfiles.begin(); iter != ulBurstProfiles.end(); ++iter) { if (iter->GetFecCodeType() == modulationType) { diff --git a/src/wimax/model/connection-manager.cc b/src/wimax/model/connection-manager.cc index b0933ade6..b36e721d9 100644 --- a/src/wimax/model/connection-manager.cc +++ b/src/wimax/model/connection-manager.cc @@ -128,9 +128,7 @@ ConnectionManager::AddConnection(Ptr connection, Cid::Type type Ptr ConnectionManager::GetConnection(Cid cid) { - std::vector>::const_iterator iter; - - for (iter = m_basicConnections.begin(); iter != m_basicConnections.end(); ++iter) + for (auto iter = m_basicConnections.begin(); iter != m_basicConnections.end(); ++iter) { if ((*iter)->GetCid() == cid) { @@ -138,7 +136,7 @@ ConnectionManager::GetConnection(Cid cid) } } - for (iter = m_primaryConnections.begin(); iter != m_primaryConnections.end(); ++iter) + for (auto iter = m_primaryConnections.begin(); iter != m_primaryConnections.end(); ++iter) { if ((*iter)->GetCid() == cid) { @@ -146,7 +144,7 @@ ConnectionManager::GetConnection(Cid cid) } } - for (iter = m_transportConnections.begin(); iter != m_transportConnections.end(); ++iter) + for (auto iter = m_transportConnections.begin(); iter != m_transportConnections.end(); ++iter) { if ((*iter)->GetCid() == cid) { @@ -189,27 +187,21 @@ ConnectionManager::GetNPackets(Cid::Type type, ServiceFlow::SchedulingType sched switch (type) { case Cid::BASIC: { - for (std::vector>::const_iterator iter = m_basicConnections.begin(); - iter != m_basicConnections.end(); - ++iter) + for (auto iter = m_basicConnections.begin(); iter != m_basicConnections.end(); ++iter) { nrPackets += (*iter)->GetQueue()->GetSize(); } break; } case Cid::PRIMARY: { - for (std::vector>::const_iterator iter = m_primaryConnections.begin(); - iter != m_primaryConnections.end(); - ++iter) + for (auto iter = m_primaryConnections.begin(); iter != m_primaryConnections.end(); ++iter) { nrPackets += (*iter)->GetQueue()->GetSize(); } break; } case Cid::TRANSPORT: { - for (std::vector>::const_iterator iter = - m_transportConnections.begin(); - iter != m_transportConnections.end(); + for (auto iter = m_transportConnections.begin(); iter != m_transportConnections.end(); ++iter) { if (schedulingType == ServiceFlow::SF_TYPE_ALL || @@ -231,8 +223,7 @@ ConnectionManager::GetNPackets(Cid::Type type, ServiceFlow::SchedulingType sched bool ConnectionManager::HasPackets() const { - std::vector>::const_iterator iter; - for (iter = m_basicConnections.begin(); iter != m_basicConnections.end(); ++iter) + for (auto iter = m_basicConnections.begin(); iter != m_basicConnections.end(); ++iter) { if ((*iter)->HasPackets()) { @@ -240,7 +231,7 @@ ConnectionManager::HasPackets() const } } - for (iter = m_primaryConnections.begin(); iter != m_primaryConnections.end(); ++iter) + for (auto iter = m_primaryConnections.begin(); iter != m_primaryConnections.end(); ++iter) { if ((*iter)->HasPackets()) { @@ -248,7 +239,7 @@ ConnectionManager::HasPackets() const } } - for (iter = m_transportConnections.begin(); iter != m_transportConnections.end(); ++iter) + for (auto iter = m_transportConnections.begin(); iter != m_transportConnections.end(); ++iter) { if ((*iter)->HasPackets()) { diff --git a/src/wimax/model/cs-parameters.cc b/src/wimax/model/cs-parameters.cc index 626300172..b1d6080a3 100644 --- a/src/wimax/model/cs-parameters.cc +++ b/src/wimax/model/cs-parameters.cc @@ -37,7 +37,7 @@ CsParameters::CsParameters(Tlv tlv) NS_ASSERT_MSG(tlv.GetType() == SfVectorTlvValue::IPV4_CS_Parameters, "Invalid TLV"); CsParamVectorTlvValue* param = ((CsParamVectorTlvValue*)(tlv.PeekValue())); - for (std::vector::const_iterator iter = param->Begin(); iter != param->End(); ++iter) + for (auto iter = param->Begin(); iter != param->End(); ++iter) { switch ((*iter)->GetType()) { diff --git a/src/wimax/model/ipcs-classifier-record.cc b/src/wimax/model/ipcs-classifier-record.cc index c57883f9b..b20bd842b 100644 --- a/src/wimax/model/ipcs-classifier-record.cc +++ b/src/wimax/model/ipcs-classifier-record.cc @@ -62,7 +62,7 @@ IpcsClassifierRecord::IpcsClassifierRecord(Tlv tlv) m_tosHigh = 0; m_tosMask = 0; m_cid = 0; - for (std::vector::const_iterator iter = rules->Begin(); iter != rules->End(); ++iter) + for (auto iter = rules->Begin(); iter != rules->End(); ++iter) { switch ((*iter)->GetType()) { @@ -75,49 +75,40 @@ IpcsClassifierRecord::IpcsClassifierRecord(Tlv tlv) break; } case ClassificationRuleVectorTlvValue::Protocol: { - ProtocolTlvValue* list = (ProtocolTlvValue*)(*iter)->PeekValue(); - for (std::vector::const_iterator iter2 = list->Begin(); iter2 != list->End(); - ++iter2) + auto list = (ProtocolTlvValue*)(*iter)->PeekValue(); + for (auto iter2 = list->Begin(); iter2 != list->End(); ++iter2) { AddProtocol(*iter2); } break; } case ClassificationRuleVectorTlvValue::IP_src: { - Ipv4AddressTlvValue* list = (Ipv4AddressTlvValue*)(*iter)->PeekValue(); - for (std::vector::const_iterator iter2 = list->Begin(); - iter2 != list->End(); - ++iter2) + auto list = (Ipv4AddressTlvValue*)(*iter)->PeekValue(); + for (auto iter2 = list->Begin(); iter2 != list->End(); ++iter2) { AddSrcAddr((*iter2).Address, (*iter2).Mask); } break; } case ClassificationRuleVectorTlvValue::IP_dst: { - Ipv4AddressTlvValue* list = (Ipv4AddressTlvValue*)(*iter)->PeekValue(); - for (std::vector::const_iterator iter2 = list->Begin(); - iter2 != list->End(); - ++iter2) + auto list = (Ipv4AddressTlvValue*)(*iter)->PeekValue(); + for (auto iter2 = list->Begin(); iter2 != list->End(); ++iter2) { AddDstAddr((*iter2).Address, (*iter2).Mask); } break; } case ClassificationRuleVectorTlvValue::Port_src: { - PortRangeTlvValue* list = (PortRangeTlvValue*)(*iter)->PeekValue(); - for (std::vector::const_iterator iter2 = list->Begin(); - iter2 != list->End(); - ++iter2) + auto list = (PortRangeTlvValue*)(*iter)->PeekValue(); + for (auto iter2 = list->Begin(); iter2 != list->End(); ++iter2) { AddSrcPortRange((*iter2).PortLow, (*iter2).PortHigh); } break; } case ClassificationRuleVectorTlvValue::Port_dst: { - PortRangeTlvValue* list = (PortRangeTlvValue*)(*iter)->PeekValue(); - for (std::vector::const_iterator iter2 = list->Begin(); - iter2 != list->End(); - ++iter2) + auto list = (PortRangeTlvValue*)(*iter)->PeekValue(); + for (auto iter2 = list->Begin(); iter2 != list->End(); ++iter2) { AddDstPortRange((*iter2).PortLow, (*iter2).PortHigh); } @@ -236,8 +227,7 @@ IpcsClassifierRecord::GetPriority() const bool IpcsClassifierRecord::CheckMatchSrcAddr(Ipv4Address srcAddress) const { - for (std::vector::const_iterator iter = m_srcAddr.begin(); iter != m_srcAddr.end(); - ++iter) + for (auto iter = m_srcAddr.begin(); iter != m_srcAddr.end(); ++iter) { NS_LOG_INFO("src addr check match: pkt=" << srcAddress << " cls=" << (*iter).Address << "/" << (*iter).Mask); @@ -253,8 +243,7 @@ IpcsClassifierRecord::CheckMatchSrcAddr(Ipv4Address srcAddress) const bool IpcsClassifierRecord::CheckMatchDstAddr(Ipv4Address dstAddress) const { - for (std::vector::const_iterator iter = m_dstAddr.begin(); iter != m_dstAddr.end(); - ++iter) + for (auto iter = m_dstAddr.begin(); iter != m_dstAddr.end(); ++iter) { NS_LOG_INFO("dst addr check match: pkt=" << dstAddress << " cls=" << (*iter).Address << "/" << (*iter).Mask); @@ -270,9 +259,7 @@ IpcsClassifierRecord::CheckMatchDstAddr(Ipv4Address dstAddress) const bool IpcsClassifierRecord::CheckMatchSrcPort(uint16_t port) const { - for (std::vector::const_iterator iter = m_srcPortRange.begin(); - iter != m_srcPortRange.end(); - ++iter) + for (auto iter = m_srcPortRange.begin(); iter != m_srcPortRange.end(); ++iter) { NS_LOG_INFO("src port check match: pkt=" << port << " cls= [" << (*iter).PortLow << " TO " << (*iter).PortHigh << "]"); @@ -288,9 +275,7 @@ IpcsClassifierRecord::CheckMatchSrcPort(uint16_t port) const bool IpcsClassifierRecord::CheckMatchDstPort(uint16_t port) const { - for (std::vector::const_iterator iter = m_dstPortRange.begin(); - iter != m_dstPortRange.end(); - ++iter) + for (auto iter = m_dstPortRange.begin(); iter != m_dstPortRange.end(); ++iter) { NS_LOG_INFO("dst port check match: pkt=" << port << " cls= [" << (*iter).PortLow << " TO " << (*iter).PortHigh << "]"); @@ -306,8 +291,7 @@ IpcsClassifierRecord::CheckMatchDstPort(uint16_t port) const bool IpcsClassifierRecord::CheckMatchProtocol(uint8_t proto) const { - for (std::vector::const_iterator iter = m_protocol.begin(); iter != m_protocol.end(); - ++iter) + for (auto iter = m_protocol.begin(); iter != m_protocol.end(); ++iter) { NS_LOG_INFO("proto check match: pkt=" << (uint16_t)proto << " cls=" << (uint16_t)proto); if (proto == (*iter)) @@ -334,38 +318,31 @@ Tlv IpcsClassifierRecord::ToTlv() const { Ipv4AddressTlvValue ipv4AddrValSrc; - for (std::vector::const_iterator iter = m_srcAddr.begin(); iter != m_srcAddr.end(); - ++iter) + for (auto iter = m_srcAddr.begin(); iter != m_srcAddr.end(); ++iter) { ipv4AddrValSrc.Add((*iter).Address, (*iter).Mask); } Ipv4AddressTlvValue ipv4AddrValDst; - for (std::vector::const_iterator iter = m_dstAddr.begin(); iter != m_dstAddr.end(); - ++iter) + for (auto iter = m_dstAddr.begin(); iter != m_dstAddr.end(); ++iter) { ipv4AddrValDst.Add((*iter).Address, (*iter).Mask); } ProtocolTlvValue protoVal; - for (std::vector::const_iterator iter = m_protocol.begin(); iter != m_protocol.end(); - ++iter) + for (auto iter = m_protocol.begin(); iter != m_protocol.end(); ++iter) { protoVal.Add((*iter)); } PortRangeTlvValue portValueSrc; - for (std::vector::const_iterator iter = m_srcPortRange.begin(); - iter != m_srcPortRange.end(); - ++iter) + for (auto iter = m_srcPortRange.begin(); iter != m_srcPortRange.end(); ++iter) { portValueSrc.Add((*iter).PortLow, (*iter).PortHigh); } PortRangeTlvValue portValueDst; - for (std::vector::const_iterator iter = m_dstPortRange.begin(); - iter != m_dstPortRange.end(); - ++iter) + for (auto iter = m_dstPortRange.begin(); iter != m_dstPortRange.end(); ++iter) { portValueDst.Add((*iter).PortLow, (*iter).PortHigh); } diff --git a/src/wimax/model/service-flow-manager.cc b/src/wimax/model/service-flow-manager.cc index d1ffd9129..552cfe017 100644 --- a/src/wimax/model/service-flow-manager.cc +++ b/src/wimax/model/service-flow-manager.cc @@ -68,9 +68,7 @@ ServiceFlowManager::~ServiceFlowManager() void ServiceFlowManager::DoDispose() { - for (std::vector::iterator iter = m_serviceFlows->begin(); - iter != m_serviceFlows->end(); - ++iter) + for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) { delete (*iter); } @@ -92,9 +90,7 @@ ServiceFlowManager::DoClassify(Ipv4Address srcAddress, uint8_t proto, ServiceFlow::Direction dir) const { - for (std::vector::iterator iter = m_serviceFlows->begin(); - iter != m_serviceFlows->end(); - ++iter) + for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) { if ((*iter)->GetDirection() == dir) { @@ -110,9 +106,7 @@ ServiceFlowManager::DoClassify(Ipv4Address srcAddress, ServiceFlow* ServiceFlowManager::GetServiceFlow(uint32_t sfid) const { - for (std::vector::iterator iter = m_serviceFlows->begin(); - iter != m_serviceFlows->end(); - ++iter) + for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) { if ((*iter)->GetSfid() == sfid) { @@ -127,9 +121,7 @@ ServiceFlowManager::GetServiceFlow(uint32_t sfid) const ServiceFlow* ServiceFlowManager::GetServiceFlow(Cid cid) const { - for (std::vector::iterator iter = m_serviceFlows->begin(); - iter != m_serviceFlows->end(); - ++iter) + for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) { if ((*iter)->GetCid() == cid.GetIdentifier()) { @@ -145,9 +137,7 @@ std::vector ServiceFlowManager::GetServiceFlows(ServiceFlow::SchedulingType schedulingType) const { std::vector tmpServiceFlows; - for (std::vector::iterator iter = m_serviceFlows->begin(); - iter != m_serviceFlows->end(); - ++iter) + for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) { if (((*iter)->GetSchedulingType() == schedulingType) || (schedulingType == ServiceFlow::SF_TYPE_ALL)) @@ -173,9 +163,7 @@ ServiceFlowManager::AreServiceFlowsAllocated(std::vector* serviceF bool ServiceFlowManager::AreServiceFlowsAllocated(std::vector serviceFlowVector) { - for (std::vector::const_iterator iter = serviceFlowVector.begin(); - iter != serviceFlowVector.end(); - ++iter) + for (auto iter = serviceFlowVector.begin(); iter != serviceFlowVector.end(); ++iter) { if (!(*iter)->GetIsEnabled()) { @@ -188,8 +176,7 @@ ServiceFlowManager::AreServiceFlowsAllocated(std::vector serviceFl ServiceFlow* ServiceFlowManager::GetNextServiceFlowToAllocate() { - std::vector::iterator iter; - for (iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) + for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) { if (!(*iter)->GetIsEnabled()) { diff --git a/src/wimax/model/service-flow.cc b/src/wimax/model/service-flow.cc index 3af5f980e..6d1da625e 100644 --- a/src/wimax/model/service-flow.cc +++ b/src/wimax/model/service-flow.cc @@ -91,7 +91,7 @@ ServiceFlow::ServiceFlow(Tlv tlv) m_direction = SF_DIRECTION_DOWN; } - for (std::vector::const_iterator iter = param->Begin(); iter != param->End(); ++iter) + for (auto iter = param->Begin(); iter != param->End(); ++iter) { switch ((*iter)->GetType()) { diff --git a/src/wimax/model/simple-ofdm-wimax-channel.cc b/src/wimax/model/simple-ofdm-wimax-channel.cc index c5cc0405f..8650a0f42 100644 --- a/src/wimax/model/simple-ofdm-wimax-channel.cc +++ b/src/wimax/model/simple-ofdm-wimax-channel.cc @@ -128,9 +128,7 @@ Ptr SimpleOfdmWimaxChannel::DoGetDevice(std::size_t index) const { std::size_t j = 0; - for (std::list>::const_iterator iter = m_phyList.begin(); - iter != m_phyList.end(); - ++iter) + for (auto iter = m_phyList.begin(); iter != m_phyList.end(); ++iter) { if (j == index) { @@ -160,9 +158,7 @@ SimpleOfdmWimaxChannel::Send(Time BlockTime, Ptr receiverMobility = nullptr; senderMobility = phy->GetDevice()->GetNode()->GetObject(); SimpleOfdmSendParam* param; - for (std::list>::iterator iter = m_phyList.begin(); - iter != m_phyList.end(); - ++iter) + for (auto iter = m_phyList.begin(); iter != m_phyList.end(); ++iter) { Time delay = Seconds(0); if (phy != *iter) @@ -221,7 +217,7 @@ SimpleOfdmWimaxChannel::AssignStreams(int64_t stream) { int64_t currentStream = stream; typedef std::list> PhyList; - for (PhyList::const_iterator i = m_phyList.begin(); i != m_phyList.end(); i++) + for (auto i = m_phyList.begin(); i != m_phyList.end(); i++) { Ptr simpleOfdm = (*i); currentStream += simpleOfdm->AssignStreams(currentStream); diff --git a/src/wimax/model/simple-ofdm-wimax-phy.cc b/src/wimax/model/simple-ofdm-wimax-phy.cc index 903257200..5fe797e00 100644 --- a/src/wimax/model/simple-ofdm-wimax-phy.cc +++ b/src/wimax/model/simple-ofdm-wimax-phy.cc @@ -273,7 +273,7 @@ SimpleOfdmWimaxPhy::DoAttach(Ptr channel) void SimpleOfdmWimaxPhy::Send(SendParams* params) { - OfdmSendParams* o_params = dynamic_cast(params); + auto o_params = dynamic_cast(params); NS_ASSERT(o_params != nullptr); Send(o_params->GetBurst(), (WimaxPhy::ModulationType)o_params->GetModulationType(), @@ -501,10 +501,10 @@ SimpleOfdmWimaxPhy::ConvertBurstToBits(Ptr burst) std::list> packets = burst->GetPackets(); uint32_t j = 0; - for (std::list>::iterator iter = packets.begin(); iter != packets.end(); ++iter) + for (auto iter = packets.begin(); iter != packets.end(); ++iter) { Ptr packet = *iter; - uint8_t* pstart = (uint8_t*)std::malloc(packet->GetSize()); + auto pstart = (uint8_t*)std::malloc(packet->GetSize()); std::memset(pstart, 0, packet->GetSize()); packet->CopyData(pstart, packet->GetSize()); Bvec temp(8); @@ -677,7 +677,7 @@ SimpleOfdmWimaxPhy::CalculateDataRate(WimaxPhy::ModulationType modulationType) c double fecCode = 0; GetModulationFecParams(modulationType, bitsPerSymbol, fecCode); double symbolsPerSecond = 1 / GetSymbolDuration().GetSeconds(); - uint16_t bitsTransmittedPerSymbol = (uint16_t)(bitsPerSymbol * GetNrCarriers() * fecCode); + auto bitsTransmittedPerSymbol = (uint16_t)(bitsPerSymbol * GetNrCarriers() * fecCode); // 96, 192, 288, 384, 576, 767 and 864 bits per symbol for the seven modulations, respectively return (uint32_t)symbolsPerSecond * bitsTransmittedPerSymbol; diff --git a/src/wimax/model/snr-to-block-error-rate-manager.cc b/src/wimax/model/snr-to-block-error-rate-manager.cc index faa07477c..325b8bade 100644 --- a/src/wimax/model/snr-to-block-error-rate-manager.cc +++ b/src/wimax/model/snr-to-block-error-rate-manager.cc @@ -59,9 +59,7 @@ SNRToBlockErrorRateManager::ClearRecords() { for (int i = 0; i < 7; i++) { - for (std::vector::iterator iter = - m_recordModulation[i]->begin(); - iter != m_recordModulation[i]->end(); + for (auto iter = m_recordModulation[i]->begin(); iter != m_recordModulation[i]->end(); ++iter) { if (*iter) @@ -107,12 +105,12 @@ SNRToBlockErrorRateManager::LoadTraces() while (traceFile.good()) { traceFile >> snrValue >> bitErrorRate >> burstErrorRate >> sigma2 >> I1 >> I2; - SNRToBlockErrorRateRecord* record = new SNRToBlockErrorRateRecord(snrValue, - bitErrorRate, - burstErrorRate, - sigma2, - I1, - I2); + auto record = new SNRToBlockErrorRateRecord(snrValue, + bitErrorRate, + burstErrorRate, + sigma2, + I1, + I2); m_recordModulation[i]->push_back(record); } traceFile.close(); @@ -138,7 +136,7 @@ SNRToBlockErrorRateManager::LoadDefaultTraces() sigma2 = modulation0[3][j]; I1 = modulation0[4][j]; I2 = modulation0[5][j]; - SNRToBlockErrorRateRecord* record = + auto record = new SNRToBlockErrorRateRecord(snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2); m_recordModulation[0]->push_back(record); } @@ -150,7 +148,7 @@ SNRToBlockErrorRateManager::LoadDefaultTraces() sigma2 = modulation1[3][j]; I1 = modulation1[4][j]; I2 = modulation1[5][j]; - SNRToBlockErrorRateRecord* record = + auto record = new SNRToBlockErrorRateRecord(snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2); m_recordModulation[1]->push_back(record); } @@ -162,7 +160,7 @@ SNRToBlockErrorRateManager::LoadDefaultTraces() sigma2 = modulation2[3][j]; I1 = modulation2[4][j]; I2 = modulation2[5][j]; - SNRToBlockErrorRateRecord* record = + auto record = new SNRToBlockErrorRateRecord(snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2); m_recordModulation[2]->push_back(record); } @@ -174,7 +172,7 @@ SNRToBlockErrorRateManager::LoadDefaultTraces() sigma2 = modulation3[3][j]; I1 = modulation3[4][j]; I2 = modulation3[5][j]; - SNRToBlockErrorRateRecord* record = + auto record = new SNRToBlockErrorRateRecord(snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2); m_recordModulation[3]->push_back(record); } @@ -186,7 +184,7 @@ SNRToBlockErrorRateManager::LoadDefaultTraces() sigma2 = modulation4[3][j]; I1 = modulation4[4][j]; I2 = modulation4[5][j]; - SNRToBlockErrorRateRecord* record = + auto record = new SNRToBlockErrorRateRecord(snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2); m_recordModulation[4]->push_back(record); } @@ -198,7 +196,7 @@ SNRToBlockErrorRateManager::LoadDefaultTraces() sigma2 = modulation5[3][j]; I1 = modulation5[4][j]; I2 = modulation5[5][j]; - SNRToBlockErrorRateRecord* record = + auto record = new SNRToBlockErrorRateRecord(snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2); m_recordModulation[5]->push_back(record); } @@ -210,7 +208,7 @@ SNRToBlockErrorRateManager::LoadDefaultTraces() sigma2 = modulation6[3][j]; I1 = modulation6[4][j]; I2 = modulation6[5][j]; - SNRToBlockErrorRateRecord* record = + auto record = new SNRToBlockErrorRateRecord(snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2); m_recordModulation[6]->push_back(record); } @@ -246,12 +244,12 @@ SNRToBlockErrorRateManager::ReLoadTraces() while (traceFile.good()) { traceFile >> snrValue >> bitErrorRate >> burstErrorRate >> sigma2 >> I1 >> I2; - SNRToBlockErrorRateRecord* record = new SNRToBlockErrorRateRecord(snrValue, - bitErrorRate, - burstErrorRate, - sigma2, - I1, - I2); + auto record = new SNRToBlockErrorRateRecord(snrValue, + bitErrorRate, + burstErrorRate, + sigma2, + I1, + I2); m_recordModulation[i]->push_back(record); } @@ -349,8 +347,7 @@ SNRToBlockErrorRateManager::GetSNRToBlockErrorRateRecord(double SNR, uint8_t mod double I1 = coeff2 * (record->at(i - 1)->GetI1()) + coeff1 * (record->at(i)->GetI1()); double I2 = coeff2 * (record->at(i - 1)->GetI2()) + coeff1 * (record->at(i)->GetI2()); - SNRToBlockErrorRateRecord* SNRToBlockErrorRate = - new SNRToBlockErrorRateRecord(SNR, BER, BlcER, sigma2, I1, I2); + auto SNRToBlockErrorRate = new SNRToBlockErrorRateRecord(SNR, BER, BlcER, sigma2, I1, I2); return SNRToBlockErrorRate; } diff --git a/src/wimax/model/ss-manager.cc b/src/wimax/model/ss-manager.cc index d0df84c3b..456d79f13 100644 --- a/src/wimax/model/ss-manager.cc +++ b/src/wimax/model/ss-manager.cc @@ -48,8 +48,7 @@ SSManager::SSManager() SSManager::~SSManager() { - for (std::vector::iterator iter = m_ssRecords->begin(); iter != m_ssRecords->end(); - ++iter) + for (auto iter = m_ssRecords->begin(); iter != m_ssRecords->end(); ++iter) { delete *iter; } @@ -60,7 +59,7 @@ SSManager::~SSManager() SSRecord* SSManager::CreateSSRecord(const Mac48Address& macAddress) { - SSRecord* ssRecord = new SSRecord(macAddress); + auto ssRecord = new SSRecord(macAddress); m_ssRecords->push_back(ssRecord); return ssRecord; } @@ -68,8 +67,7 @@ SSManager::CreateSSRecord(const Mac48Address& macAddress) SSRecord* SSManager::GetSSRecord(const Mac48Address& macAddress) const { - for (std::vector::iterator iter = m_ssRecords->begin(); iter != m_ssRecords->end(); - ++iter) + for (auto iter = m_ssRecords->begin(); iter != m_ssRecords->end(); ++iter) { if ((*iter)->GetMacAddress() == macAddress) { @@ -84,8 +82,7 @@ SSManager::GetSSRecord(const Mac48Address& macAddress) const SSRecord* SSManager::GetSSRecord(Cid cid) const { - for (std::vector::iterator iter1 = m_ssRecords->begin(); iter1 != m_ssRecords->end(); - ++iter1) + for (auto iter1 = m_ssRecords->begin(); iter1 != m_ssRecords->end(); ++iter1) { SSRecord* ssRecord = *iter1; if (ssRecord->GetBasicCid() == cid || ssRecord->GetPrimaryCid() == cid) @@ -95,7 +92,7 @@ SSManager::GetSSRecord(Cid cid) const else { std::vector sf = ssRecord->GetServiceFlows(ServiceFlow::SF_TYPE_ALL); - for (std::vector::iterator iter2 = sf.begin(); iter2 != sf.end(); ++iter2) + for (auto iter2 = sf.begin(); iter2 != sf.end(); ++iter2) { if ((*iter2)->GetConnection()->GetCid() == cid) { @@ -118,8 +115,7 @@ SSManager::GetSSRecords() const bool SSManager::IsInRecord(const Mac48Address& macAddress) const { - for (std::vector::iterator iter = m_ssRecords->begin(); iter != m_ssRecords->end(); - ++iter) + for (auto iter = m_ssRecords->begin(); iter != m_ssRecords->end(); ++iter) { if ((*iter)->GetMacAddress() == macAddress) { @@ -140,8 +136,7 @@ SSManager::IsRegistered(const Mac48Address& macAddress) const void SSManager::DeleteSSRecord(Cid cid) { - for (std::vector::iterator iter1 = m_ssRecords->begin(); iter1 != m_ssRecords->end(); - ++iter1) + for (auto iter1 = m_ssRecords->begin(); iter1 != m_ssRecords->end(); ++iter1) { SSRecord* ssRecord = *iter1; if (ssRecord->GetBasicCid() == cid || ssRecord->GetPrimaryCid() == cid) @@ -152,8 +147,7 @@ SSManager::DeleteSSRecord(Cid cid) else { std::vector sf = ssRecord->GetServiceFlows(ServiceFlow::SF_TYPE_ALL); - for (std::vector::const_iterator iter2 = sf.begin(); iter2 != sf.end(); - ++iter2) + for (auto iter2 = sf.begin(); iter2 != sf.end(); ++iter2) { if ((*iter2)->GetConnection()->GetCid() == cid) { @@ -181,8 +175,7 @@ uint32_t SSManager::GetNRegisteredSSs() const { uint32_t nrSS = 0; - for (std::vector::iterator iter = m_ssRecords->begin(); iter != m_ssRecords->end(); - ++iter) + for (auto iter = m_ssRecords->begin(); iter != m_ssRecords->end(); ++iter) { if ((*iter)->GetRangingStatus() == WimaxNetDevice::RANGING_STATUS_SUCCESS) { diff --git a/src/wimax/model/ss-net-device.cc b/src/wimax/model/ss-net-device.cc index 8a5138776..9b0fd4106 100644 --- a/src/wimax/model/ss-net-device.cc +++ b/src/wimax/model/ss-net-device.cc @@ -1089,9 +1089,7 @@ SubscriberStationNetDevice::DoReceive(Ptr packet) // DEFRAGMENTATION NS_LOG_INFO("\t SS PACKET DEFRAGMENTATION" << std::endl); - for (std::list>::const_iterator iter = fragmentsQueue.begin(); - iter != fragmentsQueue.end(); - ++iter) + for (auto iter = fragmentsQueue.begin(); iter != fragmentsQueue.end(); ++iter) { // Create the whole Packet fullPacket->AddAtEnd(*iter); @@ -1146,8 +1144,7 @@ SubscriberStationNetDevice::ProcessDlMap(const DlMap& dlmap) m_baseStationId = dlmap.GetBaseStationId(); std::list dlMapElements = dlmap.GetDlMapElements(); - for (std::list::iterator iter = dlMapElements.begin(); iter != dlMapElements.end(); - ++iter) + for (auto iter = dlMapElements.begin(); iter != dlMapElements.end(); ++iter) { if (iter->GetDiuc() == OfdmDlBurstProfile::DIUC_END_OF_MAP) { @@ -1180,8 +1177,7 @@ SubscriberStationNetDevice::ProcessUlMap(const UlMap& ulmap) std::list ulMapElements = ulmap.GetUlMapElements(); m_linkManager->SetRangingIntervalFound(false); - for (std::list::iterator iter = ulMapElements.begin(); iter != ulMapElements.end(); - ++iter) + for (auto iter = ulMapElements.begin(); iter != ulMapElements.end(); ++iter) { OfdmUlMapIe ulMapIe = *iter; @@ -1282,9 +1278,7 @@ SubscriberStationNetDevice::ProcessDcd(const Dcd& dcd) std::vector dlBurstProfiles = dcd.GetDlBurstProfiles(); - for (std::vector::iterator iter = dlBurstProfiles.begin(); - iter != dlBurstProfiles.end(); - ++iter) + for (auto iter = dlBurstProfiles.begin(); iter != dlBurstProfiles.end(); ++iter) { OfdmDlBurstProfile brstProfile = *iter; @@ -1319,9 +1313,7 @@ SubscriberStationNetDevice::ProcessUcd(const Ucd& ucd) std::vector ulBurstProfiles = ucd.GetUlBurstProfiles(); - for (std::vector::iterator iter = ulBurstProfiles.begin(); - iter != ulBurstProfiles.end(); - ++iter) + for (auto iter = ulBurstProfiles.begin(); iter != ulBurstProfiles.end(); ++iter) { OfdmUlBurstProfile brstProfile = *iter; diff --git a/src/wimax/model/ss-record.cc b/src/wimax/model/ss-record.cc index 3577d22ec..82d18dc1e 100644 --- a/src/wimax/model/ss-record.cc +++ b/src/wimax/model/ss-record.cc @@ -233,9 +233,7 @@ std::vector SSRecord::GetServiceFlows(ServiceFlow::SchedulingType schedulingType) const { std::vector tmpServiceFlows; - for (std::vector::iterator iter = m_serviceFlows->begin(); - iter != m_serviceFlows->end(); - ++iter) + for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) { if (((*iter)->GetSchedulingType() == schedulingType) || (schedulingType == ServiceFlow::SF_TYPE_ALL)) @@ -261,9 +259,7 @@ SSRecord::GetIsBroadcastSS() const bool SSRecord::GetHasServiceFlowUgs() const { - for (std::vector::iterator iter = m_serviceFlows->begin(); - iter != m_serviceFlows->end(); - ++iter) + for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) { if ((*iter)->GetSchedulingType() == ServiceFlow::SF_TYPE_UGS) { @@ -276,9 +272,7 @@ SSRecord::GetHasServiceFlowUgs() const bool SSRecord::GetHasServiceFlowRtps() const { - for (std::vector::iterator iter = m_serviceFlows->begin(); - iter != m_serviceFlows->end(); - ++iter) + for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) { if ((*iter)->GetSchedulingType() == ServiceFlow::SF_TYPE_RTPS) { @@ -291,9 +285,7 @@ SSRecord::GetHasServiceFlowRtps() const bool SSRecord::GetHasServiceFlowNrtps() const { - for (std::vector::iterator iter = m_serviceFlows->begin(); - iter != m_serviceFlows->end(); - ++iter) + for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) { if ((*iter)->GetSchedulingType() == ServiceFlow::SF_TYPE_NRTPS) { @@ -306,9 +298,7 @@ SSRecord::GetHasServiceFlowNrtps() const bool SSRecord::GetHasServiceFlowBe() const { - for (std::vector::iterator iter = m_serviceFlows->begin(); - iter != m_serviceFlows->end(); - ++iter) + for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter) { if ((*iter)->GetSchedulingType() == ServiceFlow::SF_TYPE_BE) { diff --git a/src/wimax/model/ss-scheduler.cc b/src/wimax/model/ss-scheduler.cc index 5c007eb97..30c0077af 100644 --- a/src/wimax/model/ss-scheduler.cc +++ b/src/wimax/model/ss-scheduler.cc @@ -167,8 +167,6 @@ Ptr SSScheduler::SelectConnection() { Time currentTime = Simulator::Now(); - std::vector::const_iterator iter; - std::vector serviceFlows; NS_LOG_INFO("SS Scheduler: Selecting connection..."); if (m_ss->GetInitialRangingConnection()->HasPackets()) @@ -187,8 +185,8 @@ SSScheduler::SelectConnection() return m_ss->GetPrimaryConnection(); } - serviceFlows = m_ss->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_UGS); - for (iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) + auto serviceFlows = m_ss->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_UGS); + for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) { // making sure that this grant was actually intended for this UGS @@ -206,7 +204,7 @@ SSScheduler::SelectConnection() hence this function will never be called. */ serviceFlows = m_ss->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_RTPS); - for (iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) + for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) { if ((*iter)->HasPackets(MacHeaderType::HEADER_TYPE_GENERIC) && (currentTime + m_ss->GetPhy()->GetFrameDuration() > @@ -219,7 +217,7 @@ SSScheduler::SelectConnection() } serviceFlows = m_ss->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_NRTPS); - for (iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) + for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) { if ((*iter)->HasPackets(MacHeaderType::HEADER_TYPE_GENERIC)) { @@ -230,7 +228,7 @@ SSScheduler::SelectConnection() } serviceFlows = m_ss->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_BE); - for (iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) + for (auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter) { if ((*iter)->HasPackets(MacHeaderType::HEADER_TYPE_GENERIC)) { diff --git a/src/wimax/model/ss-service-flow-manager.cc b/src/wimax/model/ss-service-flow-manager.cc index 839ac6e39..629b679a7 100644 --- a/src/wimax/model/ss-service-flow-manager.cc +++ b/src/wimax/model/ss-service-flow-manager.cc @@ -105,7 +105,7 @@ SsServiceFlowManager::GetDsaAckTimeoutEvent() const void SsServiceFlowManager::AddServiceFlow(ServiceFlow serviceFlow) { - ServiceFlow* sf = new ServiceFlow(); + auto sf = new ServiceFlow(); sf->CopyParametersFrom(serviceFlow); ServiceFlowManager::AddServiceFlow(sf); } diff --git a/src/wimax/model/wimax-mac-queue.cc b/src/wimax/model/wimax-mac-queue.cc index 2ca9a6a17..b4c73ae13 100644 --- a/src/wimax/model/wimax-mac-queue.cc +++ b/src/wimax/model/wimax-mac-queue.cc @@ -438,8 +438,7 @@ WimaxMacQueue::Front(MacHeaderType::HeaderType packetType) const { QueueElement element; - for (std::deque::const_iterator iter = m_queue.begin(); iter != m_queue.end(); - ++iter) + for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) { element = *iter; if (element.m_hdrType.GetType() == packetType) @@ -456,7 +455,7 @@ WimaxMacQueue::Pop(MacHeaderType::HeaderType packetType) { QueueElement element; - for (std::deque::iterator iter = m_queue.begin(); iter != m_queue.end(); ++iter) + for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) { element = *iter; if (element.m_hdrType.GetType() == packetType) @@ -498,8 +497,7 @@ bool WimaxMacQueue::CheckForFragmentation(MacHeaderType::HeaderType packetType) { QueueElement element; - for (std::deque::const_iterator iter = m_queue.begin(); iter != m_queue.end(); - ++iter) + for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) { element = *iter; if (element.m_hdrType.GetType() == packetType) @@ -522,8 +520,7 @@ uint32_t WimaxMacQueue::GetFirstPacketHdrSize(MacHeaderType::HeaderType packetType) { QueueElement element; - for (std::deque::const_iterator iter = m_queue.begin(); iter != m_queue.end(); - ++iter) + for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) { element = *iter; if (element.m_hdrType.GetType() == packetType) @@ -559,8 +556,7 @@ uint32_t WimaxMacQueue::GetFirstPacketPayloadSize(MacHeaderType::HeaderType packetType) { QueueElement element; - for (std::deque::const_iterator iter = m_queue.begin(); iter != m_queue.end(); - ++iter) + for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) { element = *iter; if (element.m_hdrType.GetType() == packetType) @@ -601,7 +597,7 @@ WimaxMacQueue::GetFirstPacketRequiredByte(MacHeaderType::HeaderType packetType) void WimaxMacQueue::SetFragmentation(MacHeaderType::HeaderType packetType) { - for (std::deque::iterator iter = m_queue.begin(); iter != m_queue.end(); ++iter) + for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) { if (iter->m_hdrType.GetType() == packetType) { @@ -614,7 +610,7 @@ WimaxMacQueue::SetFragmentation(MacHeaderType::HeaderType packetType) void WimaxMacQueue::SetFragmentNumber(MacHeaderType::HeaderType packetType) { - for (std::deque::iterator iter = m_queue.begin(); iter != m_queue.end(); ++iter) + for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) { if (iter->m_hdrType.GetType() == packetType) { @@ -627,7 +623,7 @@ WimaxMacQueue::SetFragmentNumber(MacHeaderType::HeaderType packetType) void WimaxMacQueue::SetFragmentOffset(MacHeaderType::HeaderType packetType, uint32_t offset) { - for (std::deque::iterator iter = m_queue.begin(); iter != m_queue.end(); ++iter) + for (auto iter = m_queue.begin(); iter != m_queue.end(); ++iter) { if (iter->m_hdrType.GetType() == packetType) { diff --git a/src/wimax/model/wimax-net-device.cc b/src/wimax/model/wimax-net-device.cc index 2806c8b02..6972487ae 100644 --- a/src/wimax/model/wimax-net-device.cc +++ b/src/wimax/model/wimax-net-device.cc @@ -517,7 +517,7 @@ WimaxNetDevice::Receive(Ptr burst) NS_LOG_DEBUG("WimaxNetDevice::Receive, station = " << GetMacAddress()); Ptr b = burst->Copy(); - for (std::list>::const_iterator iter = b->Begin(); iter != b->End(); ++iter) + for (auto iter = b->Begin(); iter != b->End(); ++iter) { Ptr packet = *iter; DoReceive(packet); diff --git a/src/wimax/model/wimax-tlv.cc b/src/wimax/model/wimax-tlv.cc index 7e457677b..cf1944a31 100644 --- a/src/wimax/model/wimax-tlv.cc +++ b/src/wimax/model/wimax-tlv.cc @@ -239,8 +239,7 @@ VectorTlvValue::VectorTlvValue() VectorTlvValue::~VectorTlvValue() { - for (std::vector::const_iterator iter = m_tlvList->begin(); iter != m_tlvList->end(); - ++iter) + for (auto iter = m_tlvList->begin(); iter != m_tlvList->end(); ++iter) { delete (*iter); } @@ -252,8 +251,7 @@ uint32_t VectorTlvValue::GetSerializedSize() const { uint32_t size = 0; - for (std::vector::const_iterator iter = m_tlvList->begin(); iter != m_tlvList->end(); - ++iter) + for (auto iter = m_tlvList->begin(); iter != m_tlvList->end(); ++iter) { size += (*iter)->GetSerializedSize(); } @@ -263,8 +261,7 @@ VectorTlvValue::GetSerializedSize() const void VectorTlvValue::Serialize(Buffer::Iterator i) const { - for (std::vector::const_iterator iter = m_tlvList->begin(); iter != m_tlvList->end(); - ++iter) + for (auto iter = m_tlvList->begin(); iter != m_tlvList->end(); ++iter) { (*iter)->Serialize(i); i.Next((*iter)->GetSerializedSize()); @@ -297,8 +294,8 @@ SfVectorTlvValue::SfVectorTlvValue() SfVectorTlvValue* SfVectorTlvValue::Copy() const { - SfVectorTlvValue* tmp = new SfVectorTlvValue(); - for (std::vector::const_iterator iter = Begin(); iter != End(); ++iter) + auto tmp = new SfVectorTlvValue(); + for (auto iter = Begin(); iter != End(); ++iter) { tmp->Add(Tlv((*iter)->GetType(), (*iter)->GetLength(), *(*iter)->PeekValue())); } @@ -528,7 +525,7 @@ U8TlvValue::GetValue() const U8TlvValue* U8TlvValue::Copy() const { - U8TlvValue* tmp = new U8TlvValue(m_value); + auto tmp = new U8TlvValue(m_value); return tmp; } @@ -581,7 +578,7 @@ U16TlvValue::GetValue() const U16TlvValue* U16TlvValue::Copy() const { - U16TlvValue* tmp = new U16TlvValue(m_value); + auto tmp = new U16TlvValue(m_value); return tmp; } @@ -634,7 +631,7 @@ U32TlvValue::GetValue() const U32TlvValue* U32TlvValue::Copy() const { - U32TlvValue* tmp = new U32TlvValue(m_value); + auto tmp = new U32TlvValue(m_value); return tmp; } @@ -693,8 +690,8 @@ CsParamVectorTlvValue::CsParamVectorTlvValue() CsParamVectorTlvValue* CsParamVectorTlvValue::Copy() const { - CsParamVectorTlvValue* tmp = new CsParamVectorTlvValue(); - for (std::vector::const_iterator iter = Begin(); iter != End(); ++iter) + auto tmp = new CsParamVectorTlvValue(); + for (auto iter = Begin(); iter != End(); ++iter) { tmp->Add(Tlv((*iter)->GetType(), (*iter)->GetLength(), *(*iter)->PeekValue())); } @@ -710,8 +707,8 @@ ClassificationRuleVectorTlvValue::ClassificationRuleVectorTlvValue() ClassificationRuleVectorTlvValue* ClassificationRuleVectorTlvValue::Copy() const { - ClassificationRuleVectorTlvValue* tmp = new ClassificationRuleVectorTlvValue(); - for (std::vector::const_iterator iter = Begin(); iter != End(); ++iter) + auto tmp = new ClassificationRuleVectorTlvValue(); + for (auto iter = Begin(); iter != End(); ++iter) { tmp->Add(Tlv((*iter)->GetType(), (*iter)->GetLength(), *(*iter)->PeekValue())); } @@ -888,9 +885,7 @@ PortRangeTlvValue::GetSerializedSize() const void PortRangeTlvValue::Serialize(Buffer::Iterator i) const { - for (std::vector::const_iterator iter = m_portRange->begin(); - iter != m_portRange->end(); - ++iter) + for (auto iter = m_portRange->begin(); iter != m_portRange->end(); ++iter) { i.WriteHtonU16((*iter).PortLow); i.WriteHtonU16((*iter).PortHigh); @@ -935,10 +930,8 @@ PortRangeTlvValue::End() const PortRangeTlvValue* PortRangeTlvValue::Copy() const { - PortRangeTlvValue* tmp = new PortRangeTlvValue(); - for (std::vector::const_iterator iter = m_portRange->begin(); - iter != m_portRange->end(); - ++iter) + auto tmp = new PortRangeTlvValue(); + for (auto iter = m_portRange->begin(); iter != m_portRange->end(); ++iter) { tmp->Add((*iter).PortLow, (*iter).PortHigh); } @@ -971,8 +964,7 @@ ProtocolTlvValue::GetSerializedSize() const void ProtocolTlvValue::Serialize(Buffer::Iterator i) const { - for (std::vector::const_iterator iter = m_protocol->begin(); iter != m_protocol->end(); - ++iter) + for (auto iter = m_protocol->begin(); iter != m_protocol->end(); ++iter) { i.WriteU8((*iter)); } @@ -1011,9 +1003,8 @@ ProtocolTlvValue::End() const ProtocolTlvValue* ProtocolTlvValue::Copy() const { - ProtocolTlvValue* tmp = new ProtocolTlvValue(); - for (std::vector::const_iterator iter = m_protocol->begin(); iter != m_protocol->end(); - ++iter) + auto tmp = new ProtocolTlvValue(); + for (auto iter = m_protocol->begin(); iter != m_protocol->end(); ++iter) { tmp->Add((*iter)); } @@ -1046,9 +1037,7 @@ Ipv4AddressTlvValue::GetSerializedSize() const void Ipv4AddressTlvValue::Serialize(Buffer::Iterator i) const { - for (std::vector::const_iterator iter = m_ipv4Addr->begin(); - iter != m_ipv4Addr->end(); - ++iter) + for (auto iter = m_ipv4Addr->begin(); iter != m_ipv4Addr->end(); ++iter) { i.WriteHtonU32((*iter).Address.Get()); i.WriteHtonU32((*iter).Mask.Get()); @@ -1090,10 +1079,8 @@ Ipv4AddressTlvValue::End() const Ipv4AddressTlvValue* Ipv4AddressTlvValue::Copy() const { - Ipv4AddressTlvValue* tmp = new Ipv4AddressTlvValue(); - for (std::vector::const_iterator iter = m_ipv4Addr->begin(); - iter != m_ipv4Addr->end(); - ++iter) + auto tmp = new Ipv4AddressTlvValue(); + for (auto iter = m_ipv4Addr->begin(); iter != m_ipv4Addr->end(); ++iter) { tmp->Add((*iter).Address, (*iter).Mask); } diff --git a/src/wimax/test/wimax-fragmentation-test.cc b/src/wimax/test/wimax-fragmentation-test.cc index 1da01298f..e4bdd0c9f 100644 --- a/src/wimax/test/wimax-fragmentation-test.cc +++ b/src/wimax/test/wimax-fragmentation-test.cc @@ -63,8 +63,8 @@ Ns3WimaxFragmentationTestCase::DoRun() GenericMacHeader hdr; Cid cid; - WimaxConnection* connectionTx = new WimaxConnection(cid, Cid::TRANSPORT); - WimaxConnection* connectionRx = new WimaxConnection(cid, Cid::TRANSPORT); + auto connectionTx = new WimaxConnection(cid, Cid::TRANSPORT); + auto connectionRx = new WimaxConnection(cid, Cid::TRANSPORT); // A Packet of 1000 bytes has been created. // It will be fragmentated into 4 fragments and then defragmentated into fullPacket. @@ -127,9 +127,7 @@ Ns3WimaxFragmentationTestCase::DoRun() WimaxConnection::FragmentsQueue fragmentsQueue = connectionRx->GetFragmentsQueue(); // DEFRAGMENTATION - for (std::list>::const_iterator iter = fragmentsQueue.begin(); - iter != fragmentsQueue.end(); - ++iter) + for (auto iter = fragmentsQueue.begin(); iter != fragmentsQueue.end(); ++iter) { // Create the whole Packet fullPacket->AddAtEnd(*iter); diff --git a/src/wimax/test/wimax-service-flow-test.cc b/src/wimax/test/wimax-service-flow-test.cc index 8d9382646..b7f8ce888 100644 --- a/src/wimax/test/wimax-service-flow-test.cc +++ b/src/wimax/test/wimax-service-flow-test.cc @@ -98,7 +98,7 @@ Ns3WimaxSfCreationTestCase::DoRun() Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs); // Create one UGS Downlink service flow between the ss and the bs - ServiceFlow* DlServiceFlowUgs = new ServiceFlow(ServiceFlow::SF_DIRECTION_DOWN); + auto DlServiceFlowUgs = new ServiceFlow(ServiceFlow::SF_DIRECTION_DOWN); IpcsClassifierRecord DlClassifierUgs(Ipv4Address("0.0.0.0"), Ipv4Mask("0.0.0.0"), Ipv4Address("0.0.0.0"), @@ -121,7 +121,7 @@ Ns3WimaxSfCreationTestCase::DoRun() DlServiceFlowUgs->SetTrafficPriority(1); // Create one UGS Uplink service flow between the ss and the bs - ServiceFlow* UlServiceFlowUgs = new ServiceFlow(ServiceFlow::SF_DIRECTION_UP); + auto UlServiceFlowUgs = new ServiceFlow(ServiceFlow::SF_DIRECTION_UP); IpcsClassifierRecord UlClassifierUgs(Ipv4Address("0.0.0.0"), Ipv4Mask("0.0.0.0"), Ipv4Address("0.0.0.0"), diff --git a/src/wimax/test/wimax-tlv-test.cc b/src/wimax/test/wimax-tlv-test.cc index 963c489ac..429f54fd6 100644 --- a/src/wimax/test/wimax-tlv-test.cc +++ b/src/wimax/test/wimax-tlv-test.cc @@ -89,10 +89,8 @@ Ns3WimaxCsParamTlvTestCase::DoRun() packet->RemoveHeader(tlvReceived); if (tlvReceived.GetType() == Tlv::UPLINK_SERVICE_FLOW) { - SfVectorTlvValue* sfVecValue = (SfVectorTlvValue*)tlvReceived.PeekValue(); - for (std::vector::const_iterator iter = sfVecValue->Begin(); - iter != sfVecValue->End(); - ++iter) + auto sfVecValue = (SfVectorTlvValue*)tlvReceived.PeekValue(); + for (auto iter = sfVecValue->Begin(); iter != sfVecValue->End(); ++iter) { if ((*iter)->GetType() == SfVectorTlvValue::IPV4_CS_Parameters) { diff --git a/utils/bench-scheduler.cc b/utils/bench-scheduler.cc index d39f311a7..2cfbaf1fa 100644 --- a/utils/bench-scheduler.cc +++ b/utils/bench-scheduler.cc @@ -432,7 +432,7 @@ GetRandomStream(std::string filename) { if (*input >> value) { - uint64_t ns = (uint64_t)(value * 1000000000); + auto ns = (uint64_t)(value * 1000000000); nsValues.push_back(ns); } else diff --git a/utils/print-introspected-doxygen.cc b/utils/print-introspected-doxygen.cc index f71a02212..1ddcb2a0d 100644 --- a/utils/print-introspected-doxygen.cc +++ b/utils/print-introspected-doxygen.cc @@ -456,8 +456,7 @@ StaticInformation::DoGather(TypeId tid) for (uint32_t i = 0; i < tid.GetAttributeN(); ++i) { struct TypeId::AttributeInformation info = tid.GetAttribute(i); - const PointerChecker* ptrChecker = - dynamic_cast(PeekPointer(info.checker)); + const auto ptrChecker = dynamic_cast(PeekPointer(info.checker)); if (ptrChecker != nullptr) { TypeId pointee = ptrChecker->GetPointeeTypeId(); @@ -482,7 +481,7 @@ StaticInformation::DoGather(TypeId tid) continue; } // attempt to cast to an object vector. - const ObjectPtrContainerChecker* vectorChecker = + const auto vectorChecker = dynamic_cast(PeekPointer(info.checker)); if (vectorChecker != nullptr) { @@ -723,7 +722,7 @@ PrintAttributesTid(std::ostream& os, const TypeId tid) // Indirect cases to handle if (valType == "ns3::PointerValue") { - const PointerChecker* ptrChecker = + const auto ptrChecker = dynamic_cast(PeekPointer(info.checker)); if (ptrChecker != nullptr) { @@ -734,7 +733,7 @@ PrintAttributesTid(std::ostream& os, const TypeId tid) } else if (valType == "ns3::ObjectPtrContainerValue") { - const ObjectPtrContainerChecker* ptrChecker = + const auto ptrChecker = dynamic_cast(PeekPointer(info.checker)); if (ptrChecker != nullptr) { @@ -1071,7 +1070,7 @@ PrintAllGlobals(std::ostream& os) << "See ns3::GlobalValue for how to set these." << std::endl; os << listStart << std::endl; - for (GlobalValue::Iterator i = GlobalValue::Begin(); i != GlobalValue::End(); ++i) + for (auto i = GlobalValue::Begin(); i != GlobalValue::End(); ++i) { StringValue val; (*i)->GetValue(val); @@ -1127,7 +1126,6 @@ PrintAllLogComponents(std::ostream& os) os << tLeft << ":" << std::string(widthL - 1, '-') << tMid << ":" << std::string(widthR - 1, '-') << tRight << std::endl; - LogComponent::ComponentList::const_iterator it; for (const auto& it : (*logs)) { std::string file = it.second->File();