简体   繁体   English

像容器一样的可扩展的stl集,用于C ++

[英]Scalable stl set like container for C++

I need to store large number of integers. 我需要存储大量的整数。 There can be duplicates in the input stream of integers, I just need to store distinct amongst them. 输入的整数流中可能有重复项,我只需要在它们之间存储不同的值即可。 I was using stl set initially but It went OutOfMem when input number of integers went too high. 我最初使用的是stl set,但是当输入的整数数量过高时,它就消失了。 I am looking for some C++ container library which would allow me to store numbers with the said requirement possibly backed by file ie container should not try to keep all numbers in-mem. 我正在寻找一些C ++容器库,该库将允许我存储具有上述要求的数字(可能由文件支持),即容器不应尝试将所有数字保留在内存中。 I don't need to store this data persistently, I just need to find unique values amongst it. 我不需要永久存储这些数据,我只需要在其中找到唯一的值。

Take a look at the STXXL ; 看看STXXL ; might be what you're looking for. 可能就是您要寻找的。

Edit: I haven't used it myself, but from the docs - you could use stream::runs_creator to create sorted runs of your data (however much fits in memory), then stream::runs_merger to merge the sorted streams, and finally use stream::unique to filter uniques. 编辑:我自己还没有使用过它,但是从文档中开始-您可以使用stream::runs_creator创建数据的排序运行(但是适合内存),然后使用stream::runs_merger合并排序的流,最后使用stream::unique过滤唯一性。

由于您需要的内存大于RAM,因此您可以查看memcached

Have you considered using DB (maybe SQLite )? 您是否考虑过使用DB(也许是SQLite )? Or it would be too slow? 还是太慢了?

You should seriously at least try a database before concluding it is too slow. 在确定数据库太慢之前,您应该至少认真尝试一下。 All you need is one of the lightweight key-value store ones. 您需要的只是轻量级键值存储库之一。 In the past I have used Berkeley DB, but here is a list of other ones . 过去,我曾使用Berkeley DB,但这是其他列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM