<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Yes. It would work for either lfu or lru policy (even random, though it doesn't make much sense), there will be just different interpretations what is the first, second,... element.<br><br>---<div>Alex</div></div><div><br>On May 9, 2013, at 6:48 PM, Aaron <<a href="mailto:aaronishere@qq.com">aaronishere@qq.com</a>> wrote:<br><br></div><blockquote type="cite"><div>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<style>
BLOCKQUOTE {
MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em
}
OL {
MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
UL {
MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
DIV.FoxDiv20130510094335774040 {
WORD-WRAP: break-word; COLOR: #000000; -WEBKIT-NBSP-MODE: SPACE; -WEBKIT-LINE-BREAK: AFTER-WHITE-SPACE
}
P {
MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
BODY {
LINE-HEIGHT: 1.5; FONT-FAMILY: 微软雅黑; COLOR: #000080; FONT-SIZE: 10.5pt
}
</style>
<meta name="GENERATOR" content="MSHTML 8.00.7600.16912">
<div>Hi, Alex</div>
<div> </div>
<div>Is it possible for ns3::ndn::cs::lfu/lru? </div>
<div> </div>
<hr style="WIDTH: 210px; HEIGHT: 1px" align="left" color="#b5c4df" size="1">
<div><span>Aaron</span></div>
<div> </div>
<div style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 0cm; PADDING-RIGHT: 0cm; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<div style="PADDING-BOTTOM: 8px; PADDING-LEFT: 8px; PADDING-RIGHT: 8px; BACKGROUND: #efefef; COLOR: #000000; FONT-SIZE: 12px; PADDING-TOP: 8px">
<div><b>From:</b> <a href="mailto:alexander.afanasyev@ucla.edu">Alex
Afanasyev</a></div>
<div><b>Date:</b> 2013-05-10 09:20</div>
<div><b>To:</b> <a href="mailto:aaronishere@qq.com">Aaron</a></div>
<div><b>CC:</b> <a href="mailto:ndnsim@lists.cs.ucla.edu">ndnsim</a></div>
<div><b>Subject:</b> Re: Question</div></div></div>
<div>
<div class="FoxDiv20130510094335774040">
<div>Hi Aaron,</div>
<div><br></div>
<div>Hmm... Again, in general there is no notion of beginning or ending in PIT.
It is just a complex tree-like structure, where items are stored until
they are explicitly removed (interest gets satisfied or timed out).</div>
<div><br></div>
<div>The default implementation of PIT in
ndnSIM (ns3::ndn::pit::Persistent) has "persistent" item replace
policy, meaning that if there is a limit on number of entires and this
limit is reached, new entries will be rejected.</div>
<div><br></div>
<div>The behavior similar to what you described is happening with
ns3::ndn::pit::Lru, where "item in the beginning" is the oldest PIT entry.
Is it what you're asking? If yes, then you can "remove" second-old,
third-old, or older items like this:</div>
<div style="FONT-FAMILY: sans-serif; OVERFLOW: auto"><pre style="Z-INDEX: auto; POSITION: static; BACKGROUND-COLOR: rgb(241,240,240)"><pre><span style="COLOR: rgb(64,0,0); FONT-WEIGHT: bold">typename</span> policy_container<span style="COLOR: rgb(128,96,48)">::</span><span style="COLOR: rgb(128,0,64)">iterator</span> item <span style="COLOR: rgb(128,96,48)">=</span> policy_container<span style="COLOR: rgb(128,96,48)">::</span>begin <span style="COLOR: rgb(128,96,48)">(</span><span style="COLOR: rgb(128,96,48)">)</span><span style="COLOR: rgb(128,96,48)">;</span>
<span style="COLOR: rgb(0,221,221)">std</span><span style="COLOR: rgb(128,96,48)">::</span>advance <span style="COLOR: rgb(128,96,48)">(</span>item<span style="COLOR: rgb(128,96,48)">,</span> <span style="COLOR: rgb(192,0,0)">2</span><span style="COLOR: rgb(128,96,48)">)</span><span style="COLOR: rgb(128,96,48)">;</span>
<span style="COLOR: rgb(64,0,0); FONT-WEIGHT: bold">if</span> <span style="COLOR: rgb(128,96,48)">(</span>item <span style="COLOR: rgb(128,96,48)">!</span><span style="COLOR: rgb(128,96,48)">=</span> policy_container<span style="COLOR: rgb(128,96,48)">::</span>end <span style="COLOR: rgb(128,96,48)">(</span><span style="COLOR: rgb(128,96,48)">)</span><span style="COLOR: rgb(128,96,48)">)</span>
<span style="COLOR: rgb(128,96,48)">{</span>
base_<span style="COLOR: rgb(128,96,48)">.</span>erase <span style="COLOR: rgb(128,96,48)">(</span><span style="COLOR: rgb(128,96,48)">&</span><span style="COLOR: rgb(128,96,48)">(</span><span style="COLOR: rgb(128,96,48)">*</span>item<span style="COLOR: rgb(128,96,48)">)</span><span style="COLOR: rgb(128,96,48)">)</span><span style="COLOR: rgb(128,96,48)">;</span>
<span style="COLOR: rgb(128,96,48)">}</span></pre></pre></div>
<div><br></div>
<div>std::advance operation is not very efficient (it has linear complexity),
but if you don't go too far away from the beginning, it should work reasonably
well.</div>
<div><br></div>
<div>---</div>
<div>Alex</div><br>
<div>
<div>On May 9, 2013, at 6:02 PM, "Aaron" <<a href="mailto:aaronishere@qq.com">aaronishere@qq.com</a>> wrote:</div><br class="Apple-interchange-newline">
<blockquote type="cite">hi, Alex<br>since the insert function always erase the item in the beginning. if it's possible to delete the first several items something like when A comes, erases the beginning, then B comes,erases the second,C erases the third. Say we only replace the first five item, then when F comes, re-erases the beginning<br>
<div></div>
<div>
<div style="PADDING-BOTTOM: 2px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; FONT-FAMILY: Arial Narrow; FONT-SIZE: 12px; PADDING-TOP: 2px">------------------ 原始邮件 ------------------</div>
<div style="PADDING-BOTTOM: 8px; PADDING-LEFT: 8px; PADDING-RIGHT: 8px; BACKGROUND: #efefef; FONT-SIZE: 12px; PADDING-TOP: 8px">
<div><b>发件人:</b> "alexander.afanasyev"<<a href="mailto:alexander.afanasyev@ucla.edu">alexander.afanasyev@ucla.edu</a>><wbr></div>
<div><b>发送时间:</b> 2013年5月10日(星期五) 上午7:42</div>
<div><b>收件人:</b> "aaronishere"<<a href="mailto:aaronishere@qq.com">aaronishere@qq.com</a>>;</div>
<div><b>抄送:</b> "<a href="mailto:ndnsim@lists.cs.ucla.edu">ndnsim@lists.cs.ucla.edu</a>"<<a href="mailto:ndnsim@lists.cs.ucla.edu">ndnsim@lists.cs.ucla.edu</a>>;</div>
<div><b>主题:</b> Re: Question</div></div></div>
<div>Hi Aaron,</div>
<div><br></div>It is almost impossible to get a position number of an item,
since the PIT data structure is a recursive hash-based container. Is
there any specific use case why you want to get this number? If you
really need such functionality, the custom PIT policy can track PIT item
positions.
<div><br></div>
<div>To iterate over all elements of PIT you can do the following:</div>
<div><br></div>
<div>Ptr<ndn::Pit> pit = ?;</div>
<div>for (Ptr<pit::Entry> entry = pit->Begin (); entry != pit->End
(); entry = pit->Next (entry))</div>
<div>{</div>
<div>...</div>
<div>}</div>
<div><br></div>
<div>---</div>
<div>Alex<br>
<div><br>
<div>
<div>On May 9, 2013, at 4:35 PM, aaronishere <<a href="mailto:aaronishere@qq.com">aaronishere@qq.com</a>> wrote:</div><br class="Apple-interchange-newline">
<blockquote type="cite">
<div style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; MARGIN: 10px; FONT: medium/1.5 微软雅黑; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; WORD-SPACING: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">
<div>Hi, Alex</div>
<div> </div>
<div> Is there some way to get the position number of item in the
*-policy.h, such as the lookuped item is the 5th item in the
container?</div>
<div> </div>
<div>Another is how to loop of all pit-entry, such as</div>
<div>for ( pitentry::begin, pitentry::end, Next( ) )</div>
<div>{</div>
<div>......</div>
<div>},</div>
<div>I'm not clear abou it.</div>
<div> </div>
<div>Thanks!!</div>
<div> </div>
<hr style="WIDTH: 210px; HEIGHT: 1px" align="left" size="1">
<div><span>Aaron</span></div></div></blockquote></div><br></div></div></blockquote></div><br></div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>ndnSIM mailing list</span><br><span><a href="mailto:ndnSIM@lists.cs.ucla.edu">ndnSIM@lists.cs.ucla.edu</a></span><br><span><a href="http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim">http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim</a></span><br></div></blockquote></body></html>