table: drop ChildSelector processing in CS

refs #4805

Change-Id: I994d1955091421e6a4ab682f40898999875736fe
diff --git a/daemon/table/cs.cpp b/daemon/table/cs.cpp
index 3a06c7d..a086cac 100644
--- a/daemon/table/cs.cpp
+++ b/daemon/table/cs.cpp
@@ -86,111 +86,51 @@
   }
 }
 
-void
-Cs::erase(const Name& prefix, size_t limit, const AfterEraseCallback& cb)
+std::pair<iterator, iterator>
+Cs::findPrefixRange(const Name& prefix) const
 {
-  BOOST_ASSERT(static_cast<bool>(cb));
-
   iterator first = m_table.lower_bound(prefix);
   iterator last = m_table.end();
   if (prefix.size() > 0) {
     last = m_table.lower_bound(prefix.getSuccessor());
   }
+  return {first, last};
+}
+
+size_t
+Cs::eraseImpl(const Name& prefix, size_t limit)
+{
+  iterator i, last;
+  std::tie(i, last) = findPrefixRange(prefix);
 
   size_t nErased = 0;
-  while (first != last && nErased < limit) {
-    m_policy->beforeErase(first);
-    first = m_table.erase(first);
+  while (i != last && nErased < limit) {
+    m_policy->beforeErase(i);
+    i = m_table.erase(i);
     ++nErased;
   }
-
-  if (cb) {
-    cb(nErased);
-  }
+  return nErased;
 }
 
-void
-Cs::find(const Interest& interest,
-         const HitCallback& hitCallback,
-         const MissCallback& missCallback) const
+iterator
+Cs::findImpl(const Interest& interest) const
 {
-  BOOST_ASSERT(static_cast<bool>(hitCallback));
-  BOOST_ASSERT(static_cast<bool>(missCallback));
-
   if (!m_shouldServe || m_policy->getLimit() == 0) {
-    missCallback(interest);
-    return;
+    return m_table.end();
   }
+
   const Name& prefix = interest.getName();
-  bool isRightmost = interest.getChildSelector() == 1;
-  NFD_LOG_DEBUG("find " << prefix << (isRightmost ? " R" : " L"));
+  auto range = findPrefixRange(prefix);
+  auto match = std::find_if(range.first, range.second,
+                            [&interest] (const auto& entry) { return entry.canSatisfy(interest); });
 
-  iterator first = m_table.lower_bound(prefix);
-  iterator last = m_table.end();
-  if (prefix.size() > 0) {
-    last = m_table.lower_bound(prefix.getSuccessor());
+  if (match == range.second) {
+    NFD_LOG_DEBUG("find " << prefix << " no-match");
+    return m_table.end();
   }
-
-  iterator match = last;
-  if (isRightmost) {
-    match = this->findRightmost(interest, first, last);
-  }
-  else {
-    match = this->findLeftmost(interest, first, last);
-  }
-
-  if (match == last) {
-    NFD_LOG_DEBUG("  no-match");
-    missCallback(interest);
-    return;
-  }
-  NFD_LOG_DEBUG("  matching " << match->getName());
+  NFD_LOG_DEBUG("find " << prefix << " matching " << match->getName());
   m_policy->beforeUse(match);
-  hitCallback(interest, match->getData());
-}
-
-iterator
-Cs::findLeftmost(const Interest& interest, iterator first, iterator last) const
-{
-  return std::find_if(first, last, [&interest] (const auto& entry) { return entry.canSatisfy(interest); });
-}
-
-iterator
-Cs::findRightmost(const Interest& interest, iterator first, iterator last) const
-{
-  // Each loop visits a sub-namespace under a prefix one component longer than Interest Name.
-  // If there is a match in that sub-namespace, the leftmost match is returned;
-  // otherwise, loop continues.
-
-  size_t interestNameLength = interest.getName().size();
-  for (iterator right = last; right != first;) {
-    iterator prev = std::prev(right);
-
-    // special case: [first,prev] have exact Names
-    if (prev->getName().size() == interestNameLength) {
-      NFD_LOG_TRACE("  find-among-exact " << prev->getName());
-      iterator matchExact = this->findRightmostAmongExact(interest, first, right);
-      return matchExact == right ? last : matchExact;
-    }
-
-    Name prefix = prev->getName().getPrefix(interestNameLength + 1);
-    iterator left = m_table.lower_bound(prefix);
-
-    // normal case: [left,right) are under one-component-longer prefix
-    NFD_LOG_TRACE("  find-under-prefix " << prefix);
-    iterator match = this->findLeftmost(interest, left, right);
-    if (match != right) {
-      return match;
-    }
-    right = left;
-  }
-  return last;
-}
-
-iterator
-Cs::findRightmostAmongExact(const Interest& interest, iterator first, iterator last) const
-{
-  return find_last_if(first, last, [&interest] (const auto& entry) { return entry.canSatisfy(interest); });
+  return match;
 }
 
 void