<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I haven’t tried, but it should be something like</div><div class=""><br class=""></div><div class="">const_cast<<span style="font-family: Menlo-Regular;" class="">typename Container::iterator</span>>(&(*itm))</div><div class=""><br class=""></div><div class="">—</div><div class="">Alex</div><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 26, 2014, at 4:32 PM, Shahneela Naz <<a href="mailto:shahneela.cs@gmail.com" class="">shahneela.cs@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class="">Dear Sir<br class=""><br class=""></div>Thanks a lot. I am not using for indexing purpose. ...Kindly can you further explain how I can use const_cast.<br class=""><br class=""><br class=""></div>Regards<br class=""></div>shahneela<br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Nov 26, 2014 at 6:34 PM, Alex Afanasyev <span dir="ltr" class=""><<a href="mailto:alexander.afanasyev@ucla.edu" target="_blank" class="">alexander.afanasyev@ucla.edu</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Nov 26, 2014, at 2:16 PM, Shahneela Naz <<a href="mailto:shahneela.cs@gmail.com" target="_blank" class="">shahneela.cs@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class="">Dear sir,<br class=""><br class=""></div>I am doing changes in lifetime_stats_policy.h<br class=""><br class=""></div>I have defined following to associate lifetime value of a content entry<br class=""><br class="">static double& get_time (typename Container::iterator item)<br class="">    {<br class="">      return static_cast<typename policy_container::value_traits::hook_type*><br class="">        (policy_container::value_traits::to_node_ptr(*item))->LiveTime;<br class="">    }<br class="">      <br class="">    static const double& get_time (typename Container::const_iterator item)<br class="">       {<br class="">      return static_cast<const typename policy_container::value_traits::hook_type*><br class="">        (policy_container::value_traits::to_node_ptr(*item))->LiveTime;<br class="">    }<br class=""><br class=""></div><div class="">I associate an initial lifetime value to every item I insert...<br class=""><br class=""></div><div class="">next I want to update lifetime of all entries already present in cache.. I am doing this way..<br class=""><br class="">for (typename policy_container::const_iterator itm = policy_container::begin ();<br class="">                itm != policy_container::end (); itm++){ <br class=""></div><div class="">               double oldLifeTime = get_time(&(*itm));<br class=""></div><div class="">               double newLifeTime = oldLifetime * 0.6 ; // let us say so <br class=""></div><div class="">             //  next I want to associate this new value with the item but I am unable to do so;<br class=""><br class=""></div><div class="">  }  <br class=""></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Is this lifetime value is used in indexing purposes in the policy_container?  If so, you cannot replace the value and the only way is to remove the item from the cache, and then re-insert it with the new value.</div><div class=""><br class=""></div><div class="">If lifetime is not used for indexing purposes, then you can use const_cast.</div><div class=""><br class=""></div><div class="">—</div><span class="HOEnZb"><font color="#888888" class=""><div class="">Alex</div></font></span><div class=""><div class="h5"><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Oct 16, 2014 at 12:45 PM, Alex Afanasyev <span dir="ltr" class=""><<a href="mailto:alexander.afanasyev@ucla.edu" target="_blank" class="">alexander.afanasyev@ucla.edu</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Can you show the code?...  It's close to impossible to diagnose the problem without seeing the code :(<div class=""><br class=""></div><div class="">---</div><div class="">Alex<div class=""><div class=""><br class=""><div class=""><br class=""><div class=""><div class="">On Oct 15, 2014, at 11:53 PM, Shahneela Naz <<a href="mailto:shahneela.cs@gmail.com" target="_blank" class="">shahneela.cs@gmail.com</a>> wrote:</div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class="">Dear Sir<br class=""><br class=""></div><div class="">thanks a lot for your kind response.. I have certain confusions which I feel to explain for your kind consideration.. <br class=""></div>I am not using the values for indexing purpose. lifetime/popularity just an attribute which is attached to an <a href="http://item.it/" target="_blank" class="">item.it</a> could be anything other than time. I just want to update that attribute. it is basically not reordering in my case as I am not using it for indexing. the problem which I have understood is that to iterate over all items in cache I have a reference to address which I increment in each iteration. but to modify/update an attribute of a content (which I have attached previously) I need the actual value (content/item) not reference to its address. <br class=""></div><div class="">I am finding it hard to typecast between these two types..<br class=""><br class=""></div><div class="">I hope I was better able to explain my problem now...<br class=""><br class=""></div><div class="">regards,<br class=""><br class=""></div><div class="">shahneela <br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Oct 16, 2014 at 12:09 AM, Alex Afanasyev <span dir="ltr" class=""><<a href="mailto:alexander.afanasyev@ucla.edu" target="_blank" class="">alexander.afanasyev@ucla.edu</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Hi Shahneela,</div><div class=""><br class=""></div><div class="">You're trying to modify value, which is used for indexing purposes inside the policy (i.e., policy sorts all items based on the lifetime, which results in trivial eviction when time comes).</div><div class=""><br class=""></div><div class="">Unfortunately, you cannot directly modify time for the items in the policy container.  What you need to do instead is to remove item from the container, update the value, and then reinsert the value into the container.  There is basic example of this in lfu-policy.h, though it doesn't deal with const iterators.</div><div class=""><br class=""></div><div class="">With boost::intrusive::multiset you should be able to use `typename policy_container::iterator`.  You still should not directly modify the value (as it would invalidate order), but you should be able to do the conversions.</div><div class=""><br class=""></div><div class="">--</div><div class="">Alex</div><div class=""><div class=""><br class=""><div class=""><div class="">On Oct 15, 2014, at 11:55 AM, Shahneela Naz <<a href="mailto:shahneela.cs@gmail.com" target="_blank" class="">shahneela.cs@gmail.com</a>> wrote:</div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class="">Dear Sir,<br class=""><br class=""></div>I want to loop over cache contents to change their lifetime with respect to passing time.. for this I am using policy_container::iterator e.g.<br class=""><br class="">for (typename policy_container::const_iterator item = policy_container::begin ();<br class="">                item != policy_container::end (); item++)<br class=""><br class=""></div>the problem is that I can read time value against an item using get_time(&(*item))..<br class=""></div>but when I want to set new value to the same item it requires Container::const_iterator type...<br class=""></div>I am finding it hard to typecast between iterator and const_iterator types which is required to set a value against an item..<br class=""><br class=""></div>can you kindly help me in this regard..<br class=""><br class=""></div>regards,<br class=""><br class=""></div>shahneela  <br class=""><div class=""><br class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Sep 12, 2014 at 7:07 PM, Alex Afanasyev <span dir="ltr" class=""><<a href="mailto:alexander.afanasyev@ucla.edu" target="_blank" class="">alexander.afanasyev@ucla.edu</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><br class="">
On Sep 12, 2014, at 7:16 AM, Shahneela Naz <<a href="mailto:shahneela.cs@gmail.com" target="_blank" class="">shahneela.cs@gmail.com</a>> wrote:<br class="">
<br class="">
> Dear Users,<br class="">
><br class="">
> I want to make a little change in cache-with-probability class that if a node has certain number of interfaces it should add a content. For this I want to know number of interfaces to which the node is attached.<br class="">
><br class="">
> but when I try to get a node as follows<br class="">
><br class="">
> Ptr<Node> n = This->GetObject<Node>();<br class="">
><br class="">
> it gives error that the function is defined out of scope. it is the problem due to virtual or inline function calls...<br class="">
><br class="">
> can any one kindly help me on this.. If I want to get information related to a node while using policy traits. how can I do this..<br class="">
<br class="">
</div>Hi Shaneela,<br class="">
<br class="">
Where exactly you're adding this? If you're inside any of the policy methods, you can do something like:<br class="">
<br class="">
Ptr<Node> n = item->payload ()->GetContentStore()->template GetObject<Node>();<br class="">
<br class="">
Note that there is "template" keyword before GetObject.  Is is necessary, since policy and all policy methods are part of the template implementation.<br class="">
<br class="">
---<br class="">
Alex<br class="">
<br class="">
<br class="">
> regards,<br class="">
><br class="">
> Shahneela<br class="">
> _______________________________________________<br class="">
> ndnSIM mailing list<br class="">
> <a href="mailto:ndnSIM@lists.cs.ucla.edu" target="_blank" class="">ndnSIM@lists.cs.ucla.edu</a><br class="">
> <a href="http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim" target="_blank" class="">http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim</a><br class="">
<br class="">
</blockquote></div><br class=""></div>
</blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div>
</blockquote></div><br class=""></div></div></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div></div></div><br class=""></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>