<div dir="ltr">Dear All,<div><br></div><div>I am working inside lru-policy.hpp and really need some ideas for code optimization.</div><div><br></div><div>My goal is to get an iterator of a policy_container that points to a content which matches a given content name (ndn::Name).</div><div>I have achieved this goal through the following inline function.</div><div><br></div><div><div>      inline typename policy_container::iterator</div><div>      search_with_name(ndn::Name name_item)</div><div>      {</div><div><span class="" style="white-space:pre"> </span>typename policy_container::iterator it;</div><div><span class="" style="white-space:pre">    </span>for (it = policy_container::begin (); it != policy_container::end (); ++it)</div><div><span class="" style="white-space:pre">        </span>{</div><div><span class="" style="white-space:pre">  </span>  if (name_item == it->payload()->GetName()) break;</div><div><span class="" style="white-space:pre"> </span>}</div><div><span class="" style="white-space:pre">  </span>return it;</div><div>      }</div><div><br></div><div>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).</div><div><br></div><div>Is there any faster way to do this?</div><div>Your suggestion will be highly appreciated and I would like to thank you in advance for your time.</div><div><br></div><br><div class="gmail_signature"><div dir="ltr">Best regards,<div>Saran Tarnoi</div></div></div>
</div></div>