Hi, I am writing an analysis which requires creating worklist of basic blocks. The worklist should be in FIFO order. I checked SmallVector (and similar others) and found out this is working in LIFO order when I use the functions push_back and pop_back_val to insert and delete elements in the worklist. Can someone suggest an appropriate DS to implement my worklist. Note: I am not concerned about efficiency here. -- Regards, Rekha -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131103/ca057e61/attachment.html>
If you don't care about efficiency you can push (or at least insert) at the front of a(small or otherwise) vector. On Nov 3, 2013 3:32 AM, "Rekha R" <rekharamapai at nitc.ac.in> wrote:> Hi, > > I am writing an analysis which requires creating worklist of basic blocks. > The worklist should be in FIFO order. I checked SmallVector (and similar > others) and found out this is working in LIFO order when I use the > functions push_back and pop_back_val to insert and delete elements in the > worklist. > > Can someone suggest an appropriate DS to implement my worklist. Note: I am > not concerned about efficiency here. > > -- > Regards, > Rekha > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131103/46596c69/attachment.html>
Thank you David for prompt reply. I tried with SmallVector. I inserted elements with push_back(). But when I retrieve elements using pop_back_val the elements are returned in reverse order of insertion (I mean like LIFO order). I need this to be FIFO order. How to achieve that? Regards, Rekha On Sun, Nov 3, 2013 at 8:31 PM, David Blaikie <dblaikie at gmail.com> wrote:> If you don't care about efficiency you can push (or at least insert) at > the front of a(small or otherwise) vector. > On Nov 3, 2013 3:32 AM, "Rekha R" <rekharamapai at nitc.ac.in> wrote: > >> Hi, >> >> I am writing an analysis which requires creating worklist of basic >> blocks. The worklist should be in FIFO order. I checked SmallVector (and >> similar others) and found out this is working in LIFO order when I use the >> functions push_back and pop_back_val to insert and delete elements in the >> worklist. >> >> Can someone suggest an appropriate DS to implement my worklist. Note: I >> am not concerned about efficiency here. >> >> -- >> Regards, >> Rekha >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >>-- Rekha -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131103/cf078d7e/attachment.html>
Stephen Checkoway
2013-Nov-03 15:54 UTC
[LLVMdev] Appropriate DS for implementing worklist
On Nov 3, 2013, at 6:29 AM, Rekha R <rekharamapai at nitc.ac.in> wrote:> I am writing an analysis which requires creating worklist of basic blocks. The worklist should be in FIFO order. I checked SmallVector (and similar others) and found out this is working in LIFO order when I use the functions push_back and pop_back_val to insert and delete elements in the worklist. > > Can someone suggest an appropriate DS to implement my worklist. Note: I am not concerned about efficiency here.How about a std::deque? push_back(), front(), pop_front() are what you need. They're also very efficient. -- Stephen Checkoway