dynamic-arrays

VBA: Iteration speed of variant array vs. typed array vs. non-keyed collection

不打扰是莪最后的温柔 提交于 2019-11-30 12:38:23
My project requires a bunch of dynamically-resizable arrays for different objects. An array may hold any number of objects, potentially thousands, of a single class, but not objects of multiple classes. Mostly I will be iterating through arrays, thus use of a keyed collection is not ideal. I think I have two options: The first option is to develop a 'List' class for each object type, with methods for adding objects (and expanding the array), getting the First and Last indexes and the object count, and retrieving an object by index (the latter 4 will include error handling in case the array is

3D array C++ using int [] operator

僤鯓⒐⒋嵵緔 提交于 2019-11-30 12:08:07
I'm new to C/C++ and I've been cracking my head but still got no idea how to make an "structure" like this It's supposed to be a 3D dynamic array using pointers. I started like this, but got stuck there int x=5,y=4,z=3; int ***sec=new int **[x]; It would be enough to know how to make it for a static size of y and z; Please, I'd appreciate that you help me. Thanks in advance. Manish Shukla To create dynamically 3D array of integers, it's better you understand 1D and 2D array first. 1D array : You can do this very easily by const int MAX_SIZE=128; int *arr1D = new int[MAX_SIZE]; Here, we are

Arraylist in C not working

寵の児 提交于 2019-11-30 10:00:02
I am currently writing a program to implement an arraylist (or dynamic array) in C. Hmm... I think I have 70 - 80% done with it, however, I found a serious problem with my code when testing them on a couple of machines. Briefly, I inserted a group of strings( char* ) into my arraylist, and tried to get and display them after couples of operations. However, this is what I got: CHECK: 1 CHECK: 2 CHECK: ܗ¿èۗ¿ CHECK: EàEàHAÿE؉Ⱥ CHECK: 5 CHECK: 6 Unfortunately, I still cannot figure out where the problem is in my codes, even though I have reviewed my codes twice. arraylist.h #ifndef _ARRAYLIST_H

CUFFT : How to calculate the fft when the input is a pitched array

有些话、适合烂在心里 提交于 2019-11-29 23:34:17
问题 I'm trying to find the fft of a dynamically allocated array. The input array is copied from host to device using cudaMemcpy2D . Then the fft is taken (cufftExecR2C) and the results are copied back from device to host. So my initial problem was how to use the pitch information in the fft. Then I found an answer here - CUFFT: How to calculate fft of pitched pointer? But unfortunately it doesn't work. The results I get are garbage values. Given below is my code. #define NRANK 2 #define BATCH 10

Is a dynamic array of Char allowed when the parameter type is open array of Char?

…衆ロ難τιáo~ 提交于 2019-11-29 12:37:19
问题 I was looking at Delphi: array of Char and TCharArray "Incompatible Types" and started experimenting. What I discovered is rather interesting. procedure Clear(AArray: array of Integer); var I: Integer; begin for I := Low(AArray) to High(AArray) do AArray[I] := 0; end; var MyArray: array of Integer; begin Clear(MyArray); end. This simple little example shows how you can pass a Dynamic Array to a procedure using an Open Array parameter. It compiles and runs exactly as expected. procedure Clear

Why both runtime-sized arrays and std::dynarray in C++14?

不羁的心 提交于 2019-11-29 02:48:09
Draft C++14 includes both runtime-sized arrays and the std::dynarray container. From what I can tell, the only real difference between the two is that std::dynarray has an STL interface (e.g., begin , end , size , etc.), while runtime-sized arrays do not. So why does C++14 need them both? I understand that runtime-sized arrays are part of the core language, while std::dynarray is part of the standard library, but the proposal for std::dynarray makes clear that the authors expect compilers, in many cases, to offer special support for std::dynarray so that it can be as efficient as possible, i.e

Linked list vs. dynamic array for implementing a stack

余生颓废 提交于 2019-11-28 21:00:29
问题 I've started reviewing data structures and algorithms before my final year of school starts to make sure I'm on top of everything. One review problem said "Implement a stack using a linked list or dynamic array and explain why you made the best choice". To me, it seemed more intuitive to use a list with a tail pointer to implement a stack since it may need to be resized often. It seems like for a large amount of data, a list is the better choice since a dynamic array re-size is an expensive

C++ doesn't tell you the size of a dynamic array. But why?

三世轮回 提交于 2019-11-28 21:00:00
I know that there is no way in C++ to obtain the size of a dynamically created array, such as: int* a; a = new int[n]; What I would like to know is: Why? Did people just forget this in the specification of C++, or is there a technical reason for this? Isn't the information stored somewhere? After all, the command delete[] a; seems to know how much memory it has to release, so it seems to me that delete[] has some way of knowing the size of a . You will often find that memory managers will only allocate space in a certain multiple, 64 bytes for example. So, you may ask for new int[4], i.e. 16

Dynamically allocating array explain

筅森魡賤 提交于 2019-11-28 18:29:57
This is sample code my teacher showed us about "How to dynamically allocate an array in C?". But I don't fully understand this. Here is the code: int k; int** test; printf("Enter a value for k: "); scanf("%d", &k); test = (int **)malloc(k * sizeof(int*)); for (i = 0; i < k; i++) { test[i] = (int*)malloc(k * sizeof(int)); //Initialize all the values } I thought in C, to define an array you had to put the [] after the name, so what exactly is int** test ; isn't it just a pointer to a pointer? And the malloc() line is also really confusing me..... Grijesh Chauhan According to declaration int**

How do I get an empty array of any size in python?

可紊 提交于 2019-11-28 16:16:58
I basically want a python equivalent of this in C: int a[x]; but in python I declare an array like: a = [] and the problem is I want to assign random slots with values like: a[4] = 1 but I can't do that with python, since the array is empty. If by "array" you actually mean a Python list, you can use a = [0] * 10 or a = [None] * 10 You can't do exactly what you want in Python (if I read you correctly). You need to put values in for each element of the list (or as you called it, array). But, try this: a = [0 for x in range(N)] # N = size of list you want a[i] = 5 # as long as i < N, you're okay