可扩展的stl集,如C ++的容器 [英] Scalable stl set like container for C++

查看:109
本文介绍了可扩展的stl集,如C ++的容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要存储大量整数.可以有 输入整数流中的重复项,我只需要 在其中存储独特的内容. 我最初使用的是stl set,但是当它离开OutOfMem时 输入的整数数过高. 我正在寻找一些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. I am looking for some C++ container library which would allow me to store numbers with the said requirement possibly backed by file i.e container should not try to keep all numbers in-mem. I don't need to store this data persistently, I just need to find unique values amongst it.

推荐答案

看看 STXXL ;可能就是您要寻找的.

Take a look at the STXXL; might be what you're looking for.

我自己还没有使用过它,但是从文档中开始-您可以使用stream::runs_creator创建数据的排序运行(无论多少适合内存),然后使用stream::runs_merger合并排序的流,以及最后使用stream::unique过滤唯一性.

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.

这篇关于可扩展的stl集,如C ++的容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆