<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<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"></HEAD>
<BODY style="MARGIN: 10px">
<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></BODY></HTML>