堆栈分配的不可变数组

时间:2015-03-30 09:01:20

标签: arrays f# immutability value-type stack-allocation

我正在uint64的短数组中对f#进行大量计算;我想堆栈分配它们以避免垃圾收集器运行。在C ++中,我会这样做:

int search(int n, uint64_t* data) {
    while ( /* something */ ) {
        // ... do some computation on data.
        uint64_t* data2 = (uint64_t*) alloca(n * sizeof(uint64_t));
        for (int i=0; i<n; ++i) { data2[i] = /* compute derived value */; }
        int candidate = search (n, data2);
        // ... determine if candidate is better than best etc.
    }
}

但是f#似乎没有原始的,堆栈分配的数组类型?

0 个答案:

没有答案