排序浮动指针阵列
Sorting floating Pointer array
我们有:
private void function(ptr* data, const int size_of_data){
std::sort(std::begin(data), std::end(data), floatcomparer);
这实际上是可能的吗?还有另一种方法吗?因为我到达这里error: no instance of overloaded function ""std::begin" matches the argument types are: (float *).
我知道我们需要像STD使用一样快速排序算法的大小,而PTR*则没有提供随附的尺寸。但是不应该有一种方法,因为我知道我指向的数组有多大?
您的函数签名是错误的,并且您的命令不正确地调用std::sort
,您想要更类似的东西:
void function(float* data, std::size_t size_of_data) {
std::sort(data, data + size_of_size, std::less<float>());
}
std::sort(arr, arr+ size, std::greater<float>());
在哪里可以在此形式中使用通过float arr
func(float[],int sz){...}
使用此比较器可以对其进行排序。
相关文章:
- EIGEN地图类:将C阵列映射到VectorXD指针以有效的方式
- 通过从当地的C风格阵列中返回指针来获取一个悬空的指针
- 将C 中的每个指针删除作为阵列的指针安全吗?
- 重新分配指针阵列的一部分的安全方法
- 排序阵列会使指针链接错误
- 指针阵列在一个对象数组中函数
- 指针阵列打印值
- C 在指针阵列中删除第一个元素,以效应后来的元素
- 问题将信息复制到指针阵列中
- 从指针打印动态int阵列中获取怪异的字符
- 将指针或一系列指针存储在动态阵列中
- 删除指向排序的字符串阵列的指针会在运行后会有一个错误
- 阵列指针返回垃圾
- 指针的C 动态阵列
- 来自指针向量的OpenGL阵列缓冲区
- C 指针到阵列
- 通过使用指针(C )比较阵列中的元素
- 即使阵列腐烂到指针,如何将函数的参数保留为数组,这很好
- 防止C样式阵列指针的升级
- 删除char阵列指针触发了一个神秘的断点