dynamic-arrays

Accessing the _CopyArray procedure

Is there a way to access (and call) procedures like _CopyArray that are defined in the interface in the unit System? NB: I am trying to create a routine that makes a deep clone of any dynamic array, and do not use Delphi 2010 (using Delphi 2007). The reason why I am trying to solve this without using Copy is the fact that I have only a...

Delphi SetLength Custom Indexing

In Delphi, it is possible to create an array of the type var Arr: array[2..N] of MyType; which is an array of N - 1 elements indexed from 2 to N. If we instead declare a dynamic array var Arr: array of MyType and later allocate N - 1 elements by means of SetLength(Arr, N - 1) then the elements will be indexed from 0 to N - ...

Can I use the [] operator in C++ to create virtual arrays

I have a large code base, originally C ported to C++ many years ago, that is operating on a number of large arrays of spatial data. These arrays contain structs representing point and triangle entities that represent surface models. I need to refactor the code such that the specific way these entities are stored internally varies for s...

How to create multi-dimensional jagged arrays in VbScript ?

I need to create multi-dimensional array of strings. Each row of the array can have varying number of strings. Something like the follwing code: twoDimension = Array(Array()) ReDim Preserve twoDimension(3) For i = 0 to 2 If i = 1 Then twoDimension(i) = Array(1,2,3) End If If i = 2Then twoDimension(i) = Array(1,...

how to Clean up(destructor) a dynamic Array of pointers??

Is that Destructor is enough or do I have to iterate to delete the new nodes?? #include "stdafx.h" #include<iostream> using namespace std; struct node{ int row; int col; int value; node* next_in_row; node* next_in_col; }; class MultiLinkedListSparseArray { private: char *logfile; no...

Is a dynamic array automatically deallocated when it goes out of scope?

in this example procedure foobar; var tab:array of integer; begin setlength(tab,10); end; is the array destroyed or the memory is leaking? ...

Associative array with mixed (numerical and string) indices?

How would one implement a dynamic associative array that could take any number of mixed indices (integers, strings, or both)? I aim to simulate structures by providing, for example, people[3].location as syntactical sugar for people[3, "location"]. How would you recommend representing this kind of array internally? By the way, I am usi...

Can I resize a Delphi array without losing its previous contents?

Hello all, I have a dynamic array. But initially I am not knowing the length of the array. Can I do like first I set the length of it as 1 and then increase length as I needed without lost of previously stored data? I know I can do such task using TList. But I want to know whether I can do it with array or not? ...

O* p = new O[5]; What does p point to?

To the first O of the array? ...

SomeClass* initialEl = new SomeClass[5];

Should SomeClass* initialEl = new SomeClass[5]; necessarily compile, assuming SomeClass does not have a non-publicly declared default constructor? Consider: /* * SomeClass.h * */ #ifndef SOMECLASS_H_ #define SOMECLASS_H_ class SomeClass { public: SomeClass(int){} ~SomeClass(){} }; #endif /* SOMECLASS_H_ */ /* * main.c...

Does std::vector use the assignment operator of its value type to push_back elements?

If so, why? Why doesn't it use the copy constructor of the value type? I get the following error: /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/vector.tcc: In member functio n `ClassWithoutAss& ClassWithoutAss::operator=(const ClassWithoutAss&)': /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/vector.tcc:238: instantiate d f...

C++ vector copy elements?

I would like to use a dynamic array in C++ (something like an ArrayList or a Vector in Java.) In this example are the t1, t2... objects are copied or only its address is added to the vector? Do I need to implement a copy constructor for Node class or will the default constructor make a "proper" copy (because there is a pointer in the cla...

About the fate of malloc()ed arrays of arrays.

Hello everyone - my first question on Stackoverflow. Let me start with a bit of code. It's a bit repetitive so I'm going to cut out the parts I repeat for different arrays (feel free to ask for the others). However, please ignore the code in preference to answering the Qs at the bottom. Firstly: thank you to answerers in advance. Se...

multible-dynamic-array overflow?

Hello, I have a question, I'm programming with asp.net I have a multible-dynamic array array_results(i, 0) = tmpdoc.Get("title") array_results(i, 0) += tmpdoc.Get("doc_typ") array_results(i, 1) = tmpdoc.Get("pfad") array_results(i, 2) = tmpdoc.Get("date_of_create") array_results(i, 3) = tmpdoc.Get("last_change") array_results(i, 5)...

Dynamic arrays in VBScript with Split(). Is there a better way?

Hi, all! A lot of the scripts I write at my job depend on the creation of dynamically-sizable arrays. Arrays in VBScript make this a pretty arduous task, as one has to Redim arrays every time one wants to resize them. To work around this, I've started making comma-delimited strings and using Split(...) to create 1D arrays out of it. Wh...

Android Dynamic Array

Hello all, I am parsing an xml file through Android Pull Parser technique. first, have a look at the below xml file: <childs> <students> <name> hello </name> <address> xyz </address> </stdents> <students> <name> abc </name> <address> def </address> </stdents> </childs> Co...

C dynamically growing array

I have a program that reads a "raw" list of in-game entities, and I intend to make an array holding an index number (int) of an indeterminate number of entities, for processing various things. I would like to avoid using too much memory or CPU for keeping such indexes... A quick and dirty solution I use so far is to declare, in the main...

PHP Dynamically adding dimensions to an array using for loop

Here is my dilemma and thank you in advance! I am trying to create a variable variable or something of the sort for a dynamic associative array and having a hell of a time figuring out how to do this. I am creating a file explorer so I am using the directories as the keys in the array. Example: I need to get this so I can assign it va...

How to initialize a dynamic array in java?

If I have a class that needs to return an array of strings of variable dimension (and that dimension could only be determined upon running some method of the class), how do I declare the dynamic array in my class' constructor? If the question wasn't clear enough, in php we could simply declare an array of strings as $my_string_array = ...

Declaring a huge dynamic array with tiny cells [C++]

Hello, I have this project I'm working on. The following conditions apply In this project I need to create one huge array (hopefully I will be able to create one as big as ~7.13e+17, but this target is still up ahead.) Each cell inside the array can contain one of the three values: 0,1,2 I'm using C++ as my language. I tried using th...