Use Boost.Range to simplify some code

Change-Id: I8ea55e324205c3f13096be6037e82aaab302bb55
diff --git a/ndn-cxx/mgmt/dispatcher.cpp b/ndn-cxx/mgmt/dispatcher.cpp
index 6cc80c5..326c511 100644
--- a/ndn-cxx/mgmt/dispatcher.cpp
+++ b/ndn-cxx/mgmt/dispatcher.cpp
@@ -52,16 +52,7 @@
 {
 }
 
-Dispatcher::~Dispatcher()
-{
-  std::vector<Name> topPrefixNames;
-  std::transform(m_topLevelPrefixes.begin(), m_topLevelPrefixes.end(), std::back_inserter(topPrefixNames),
-                 [] (const auto& entry) { return entry.first; });
-
-  for (const auto& name : topPrefixNames) {
-    removeTopPrefix(name);
-  }
-}
+Dispatcher::~Dispatcher() = default;
 
 void
 Dispatcher::addTopPrefix(const Name& prefix, bool wantRegister,
@@ -329,7 +320,7 @@
 void
 Dispatcher::postNotification(const Block& notification, const PartialName& relPrefix)
 {
-  if (m_topLevelPrefixes.empty() || m_topLevelPrefixes.size() > 1) {
+  if (m_topLevelPrefixes.size() != 1) {
     NDN_LOG_WARN("postNotification: no top-level prefix or too many top-level prefixes");
     return;
   }
diff --git a/ndn-cxx/net/impl/network-monitor-impl-netlink.cpp b/ndn-cxx/net/impl/network-monitor-impl-netlink.cpp
index ccd555a..f340964 100644
--- a/ndn-cxx/net/impl/network-monitor-impl-netlink.cpp
+++ b/ndn-cxx/net/impl/network-monitor-impl-netlink.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2019 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -32,6 +32,9 @@
 #include <linux/if_link.h>
 #include <net/if_arp.h>
 
+#include <boost/range/adaptor/map.hpp>
+#include <boost/range/algorithm_ext/push_back.hpp>
+
 NDN_LOG_INIT(ndn.NetworkMonitor);
 
 namespace ndn {
@@ -61,9 +64,9 @@
 shared_ptr<const NetworkInterface>
 NetworkMonitorImplNetlink::getNetworkInterface(const std::string& ifname) const
 {
-  for (const auto& e : m_interfaces) {
-    if (e.second->getName() == ifname)
-      return e.second;
+  for (const auto& interface : m_interfaces | boost::adaptors::map_values) {
+    if (interface->getName() == ifname)
+      return interface;
   }
   return nullptr;
 }
@@ -73,10 +76,7 @@
 {
   std::vector<shared_ptr<const NetworkInterface>> v;
   v.reserve(m_interfaces.size());
-
-  for (const auto& e : m_interfaces) {
-    v.push_back(e.second);
-  }
+  boost::push_back(v, m_interfaces | boost::adaptors::map_values);
   return v;
 }
 
diff --git a/ndn-cxx/net/impl/network-monitor-impl-osx.cpp b/ndn-cxx/net/impl/network-monitor-impl-osx.cpp
index 59ef9b0..838c630 100644
--- a/ndn-cxx/net/impl/network-monitor-impl-osx.cpp
+++ b/ndn-cxx/net/impl/network-monitor-impl-osx.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2019 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -65,6 +65,8 @@
 #include <boost/asio/io_service.hpp>
 #include <boost/asio/ip/address.hpp>
 #include <boost/asio/ip/udp.hpp>
+#include <boost/range/adaptor/map.hpp>
+#include <boost/range/algorithm_ext/push_back.hpp>
 
 NDN_LOG_INIT(ndn.NetworkMonitor);
 
@@ -165,10 +167,7 @@
 {
   std::vector<shared_ptr<const NetworkInterface>> v;
   v.reserve(m_interfaces.size());
-
-  for (const auto& e : m_interfaces) {
-    v.push_back(e.second);
-  }
+  boost::push_back(v, m_interfaces | boost::adaptors::map_values);
   return v;
 }
 
diff --git a/ndn-cxx/security/pib/pib-memory.cpp b/ndn-cxx/security/pib/pib-memory.cpp
index 7bf1952..94bd9f6 100644
--- a/ndn-cxx/security/pib/pib-memory.cpp
+++ b/ndn-cxx/security/pib/pib-memory.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2019 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -23,6 +23,8 @@
 #include "ndn-cxx/security/pib/pib.hpp"
 #include "ndn-cxx/security/security-common.hpp"
 
+#include <boost/range/adaptor/map.hpp>
+
 namespace ndn {
 namespace security {
 namespace pib {
@@ -168,9 +170,9 @@
 PibMemory::getKeysOfIdentity(const Name& identity) const
 {
   std::set<Name> ids;
-  for (const auto& key : m_keys) {
-    if (identity == v2::extractIdentityFromKeyName(key.first)) {
-      ids.insert(key.first);
+  for (const auto& keyName : m_keys | boost::adaptors::map_keys) {
+    if (identity == v2::extractIdentityFromKeyName(keyName)) {
+      ids.insert(keyName);
     }
   }
   return ids;
diff --git a/ndn-cxx/util/segment-fetcher.cpp b/ndn-cxx/util/segment-fetcher.cpp
index 71799dd..6596b74 100644
--- a/ndn-cxx/util/segment-fetcher.cpp
+++ b/ndn-cxx/util/segment-fetcher.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2018, Regents of the University of California,
+ * Copyright (c) 2013-2019, Regents of the University of California,
  *                          Colorado State University,
  *                          University Pierre & Marie Curie, Sorbonne University.
  *
@@ -33,6 +33,8 @@
 
 #include <boost/asio/io_service.hpp>
 #include <boost/lexical_cast.hpp>
+#include <boost/range/adaptor/map.hpp>
+
 #include <cmath>
 
 namespace ndn {
@@ -102,10 +104,10 @@
     return;
   }
 
-  for (const auto& pendingSegment : m_pendingSegments) {
-    m_face.removePendingInterest(pendingSegment.second.id);
-    if (pendingSegment.second.timeoutEvent) {
-      m_scheduler.cancelEvent(pendingSegment.second.timeoutEvent);
+  for (const auto& pendingSegment : m_pendingSegments | boost::adaptors::map_values) {
+    m_face.removePendingInterest(pendingSegment.id);
+    if (pendingSegment.timeoutEvent) {
+      m_scheduler.cancelEvent(pendingSegment.timeoutEvent);
     }
   }
   m_face.getIoService().post([self = std::move(m_this)] {});