[LLVMdev] Best method for filtering LLVM container types?

Talin viridia at gmail.com
Sat Jul 9 11:30:09 PDT 2011


I'm using the various LLVM set containers (SmallPtrSet and the like), and
something I need to do fairly often is iterate over a set, removing all
elements that don't pass a test. Now, doing this on lists is fairly
straightforward using the "it = container.erase(it)" idiom so as to keep the
iterator valid during the delete. However, the set classes don't have a
means to both iterate and mutate the set at the same time. This means that I
tend to use SmallVector in a lot of places where I really want to use a set.
In other cases I copy from one set to another as I'm filtering, although I'm
concerned about the overhead of copying the set.

What I'm wondering is what's the best practice for these kinds of
operations?

-- 
-- Talin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110709/b291496f/attachment.html>


More information about the llvm-dev mailing list