[ndnSIM] How to get an iterator to a content in policy_containter given a name

Saran Tarnoi sarantarnoi at gmail.com
Tue Nov 17 23:37:48 PST 2015


Dear All,

I am working inside lru-policy.hpp and really need some ideas for code
optimization.

My goal is to get an iterator of a policy_container that points to a
content which matches a given content name (ndn::Name).
I have achieved this goal through the following inline function.

      inline typename policy_container::iterator
      search_with_name(ndn::Name name_item)
      {
typename policy_container::iterator it;
for (it = policy_container::begin (); it != policy_container::end (); ++it)
{
 if (name_item == it->payload()->GetName()) break;
}
return it;
      }

However, the above code is so slow when policy_container is large (, which
makes sense as we will be iterating the check for all items in
policy_container in the worst case).

Is there any faster way to do this?
Your suggestion will be highly appreciated and I would like to thank you in
advance for your time.


Best regards,
Saran Tarnoi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20151118/34c1949e/attachment.html>


More information about the ndnSIM mailing list