C++ 什么是树木专用的boost\std容器?

C++ 什么是树木专用的boost\std容器?,c++,boost,tree,std,C++,Boost,Tree,Std,因此,我想将成对的字符串路径my_file_object存储在这样的容器中,预期总对象大小为100000 我需要按绝对路径进行搜索以获取对象,例如,我可以搜索a/b/c/file.h) 我需要能够列出文件夹中的所有项目名称,如文件夹a/b/c/包含文件file.h、file.cpp、文件夹bin/和文件夹bin2/ 我需要能够按绝对路径添加新的文件,并更新它们 我需要能够删除文件 我想知道五件事——STL/boost中是否有这样的容器?这个实现对读取是线程安全的吗 另外,我想知道它是否比将我

因此,我想将成对的
字符串路径my_file_object
存储在这样的容器中,预期总对象大小为100000

  • 我需要按绝对路径进行搜索以获取对象,例如,我可以搜索
    a/b/c/file.h
  • 我需要能够列出
    文件夹
    中的所有项目名称,如文件夹
    a/b/c/
    包含文件
    file.h
    file.cpp
    、文件夹
    bin/
    和文件夹
    bin2/
  • 我需要能够按绝对路径添加新的
    文件
    ,并更新它们
  • 我需要能够删除
    文件
我想知道五件事——STL/boost中是否有这样的容器?这个实现对读取是线程安全的吗


另外,我想知道它是否比将我的所有对放在
std::map
中更快,因此我可以通过?

快速搜索、快速插入和删除以及文件夹文件列表。如果您想要树状结构,请使用


如果您想要一个文件系统抽象(可以访问有问题的文件系统,而不是您似乎正在描述的内存中的某个快照),请使用

如果您想要树状结构,请使用


如果您想要一个文件系统抽象(可以访问有问题的文件系统,而不是您似乎正在描述的内存中的快照),请使用排除
std::map
的要求是什么?据我所知,它将在这里工作得很好:

typedef std::map<std::string,file_object_t> paths_t;
paths_t paths;

//I need to have search by absolute path
paths_t::iterator fileIterator = paths.find("a/b/c/file.h");
if( fileIterator  != paths.end() ) {
  ...
} 

//I need to be capable to list all item names in folder like folder a/b/c/
std::string folder = "a/b/c/";
paths_t::iterator folderBegin = paths.upper_bound(folder );
paths_t::iterator folderEnd = paths.upper_bound(folder+MAX_CHAR);
std::for_each(folderBegin,folderEnd,...);

//I need to be capable to add new files by absolute path
if( !paths.insert(paths_t::value_type("a/b/c/file.h",file)).second ) {
  //add file failed 
}

//and update them.
paths["a/b/c/file.h"].some_method_that_updates_file();

//I need to be capable to delete files
paths.erase(fileIterator);
typedef std::映射路径\u t;
路径;
//我需要通过绝对路径进行搜索
paths_t::iterator fileIterator=paths.find(“a/b/c/file.h”);
if(fileIterator!=path.end()){
...
} 
//我需要能够列出文件夹a/b/c中的所有项目名称/
std::string folder=“a/b/c/”;
paths_t::迭代器folderBegin=paths.upper_-bound(文件夹);
paths\u t::迭代器folderEnd=paths.upper\u界(folder+MAX\u CHAR);
std::对于每个(folderBegin,folderEnd,…);
//我需要能够添加绝对路径的新文件
if(!paths.insert(paths_t::value_type(“a/b/c/file.h”,file)).second){
//添加文件失败
}
//并更新它们。
路径[“a/b/c/file.h”]。更新文件()的某些方法;
//我需要能够删除文件
擦除(fileIterator);

您有什么要求排除了
std::map
?据我所知,它将在这里工作得很好:

typedef std::map<std::string,file_object_t> paths_t;
paths_t paths;

//I need to have search by absolute path
paths_t::iterator fileIterator = paths.find("a/b/c/file.h");
if( fileIterator  != paths.end() ) {
  ...
} 

//I need to be capable to list all item names in folder like folder a/b/c/
std::string folder = "a/b/c/";
paths_t::iterator folderBegin = paths.upper_bound(folder );
paths_t::iterator folderEnd = paths.upper_bound(folder+MAX_CHAR);
std::for_each(folderBegin,folderEnd,...);

//I need to be capable to add new files by absolute path
if( !paths.insert(paths_t::value_type("a/b/c/file.h",file)).second ) {
  //add file failed 
}

//and update them.
paths["a/b/c/file.h"].some_method_that_updates_file();

//I need to be capable to delete files
paths.erase(fileIterator);
typedef std::映射路径\u t;
路径;
//我需要通过绝对路径进行搜索
paths_t::iterator fileIterator=paths.find(“a/b/c/file.h”);
if(fileIterator!=path.end()){
...
} 
//我需要能够列出文件夹a/b/c中的所有项目名称/
std::string folder=“a/b/c/”;
paths_t::迭代器folderBegin=paths.upper_-bound(文件夹);
paths\u t::迭代器folderEnd=paths.upper\u界(folder+MAX\u CHAR);
std::对于每个(folderBegin,folderEnd,…);
//我需要能够添加绝对路径的新文件
if(!paths.insert(paths_t::value_type(“a/b/c/file.h”,file)).second){
//添加文件失败
}
//并更新它们。
路径[“a/b/c/file.h”]。更新文件()的某些方法;
//我需要能够删除文件
擦除(fileIterator);

如果您不想了解所有功能,我会说如果您想了解所有功能,您必须编写自己的类。如果您不想了解所有功能,我会说如果您想了解所有功能,您必须编写自己的类。我真的没有!)但是写STD和Boost的人很聪明,所以我选择了一些更快的东西=)是什么让你觉得这很慢?我真的没有!)但是写STD和Boost的人都很聪明,所以我选择了一些更快的东西=)是什么让你觉得这很慢?