Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/155.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;:按公共基数分组整数以节省内存_C++_Performance_Vector_Integer_Ram - Fatal编程技术网

C++ C++;:按公共基数分组整数以节省内存

C++ C++;:按公共基数分组整数以节省内存,c++,performance,vector,integer,ram,C++,Performance,Vector,Integer,Ram,考虑无符号int值的(排序)向量 std::vector<unsigned int> data = {1234,1254,1264,1265,1267,1268,1271,1819,1832,1856, 1867,1892,3210,3214,3256,3289}; 在上面的示例中,我将值按100的块分组。按2^8=256或2^16=65536的组对数据进行分组更符合逻辑 是否有一种数据类型(在std::或boos

考虑无符号int值的(排序)向量

std::vector<unsigned int> data = {1234,1254,1264,1265,1267,1268,1271,1819,1832,1856,
                                  1867,1892,3210,3214,3256,3289};
在上面的示例中,我将值按100的块分组。按2^8=256或2^16=65536的组对数据进行分组更符合逻辑


是否有一种数据类型(在std::或boost::或其他中)可以为我实现这种技巧,或者我必须为此编写自己类型的容器?这听起来可能是个好主意吗?

对于非常受限的场景中的特定输入,这是一个可行的想法。唉,std::没有提供这种结构。您的特定建议可以合理地以树状方式实施

注意一般的基数感知排序,因为它们通常使用大列表,因此比常规向量使用更多内存

data =
{
   {12..
      ..34, ..54, ..64, ..65, ..67, ..68, ..71
   },
   {18..
      ..19, ..32, ..56, ..67, ..92
   }
   {32..
      ..10, ..14, ..56, ..89
   }
};