<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; "><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="background-color: rgb(241, 240, 240); position: static; z-index: auto; "><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 style=""><div style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 12px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px; FONT-FAMILY: Arial Narrow">------------------ 原始邮件 ------------------</div><div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; 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="line-height: 1.5; font-family: 微软雅黑; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; margin: 10px; "><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 align="left" size="1" style="width: 210px; height: 1px; "><div><span>Aaron</span></div></div></blockquote></div><br></div></div>
</blockquote></div><br></body></html>