arrays

Calling a global Array

Hi, I'm currently trying to draw shapes with 2D Arrays. In my class there is a global array defined with public char canvas[][]; Up until now, I have only declared arrays with char canvas[][] = new char[height][width]; If this Array has already been declared, and I'm not supposed to amend the code I've been given, how do I call an in...

c++ sort with structs

Hi, I am having a hard time with this problem which requires a sort of customer names, customer ids, and finally amount due. I have the whole program figured, but cannot figure out the last prototype needed to do the sorting. i have a struct called Customers, and i will provide the int main() part also. I just need any help to gt started...

How to create a method for an array class?

Sorry, I know this is programming 101, but I can't find any good documentation... I have an array, and I want to cast each member as an object and then call them by the name assigned (this would be so much simpler if javascript allowed for non-number index values). For instance: var things = ['chair', 'tv', 'bed']; var costs = ['10',...

Faster enumeration: Leveraging Array Enumeration

So, I have a class with an array inside. Currently, my strategy for enumerating over the class's items is to use the code, foreach (item x in classInstance.InsideArray) . I would much rather use foreach (item x in classInstance) and make the array private. My main concern is that I really need to avoid anything slow; the array gets hi...

How to get the size of an Array?

Hello, In C# I use the Length property embedded to the array I'd like to get the size of. How to do that in C++? ...

PHP: Sort an array

I've got an array with data from a MySQL table in nested set model I'd like to get sorted, not only alphabetical but also with the child nodes directly after the parent node. Example - array to be sorted (before the sorting): Array ( [0] => Array ( [id] => 1 [name] => Kompetenser [parent] ...

Javascript: What is the difference between an array and an object?

The following two different code snippets seem equivalent to me: var myArray = Array(); myArray['A'] = "Athens"; myArray['B'] = "Berlin"; and var myObject = {'A': 'Athens', 'B':'Berlin'}; because they both behave the same, and also typeof(myArray) == typeof(myObjects) (both yield 'object'). Is there any difference between these va...

More compact way to do this?

I have a couple of functions that loop around the surrounding cells of a cell. The grid is contained inside an array. In my code, I have checks to make sure it's not one of the edge cells, as checking an undefined cell causes an error. As such, I have code like this: if(x > 0) { var firstX = x - 1; } else { var firstX = x; } i...

Passing a managed (C#) string[] array to a COM DLL.

Setup: I have a COM DLL that calls a method inside a managed C# DLL. This function returns a C# string[] array, which is marshaled to a SAFEARRAY. Problem: When I try to access the strings within the safearray I only get the first char of the string. What am I doing wrong? The code: // Pointer to the managed interface Databa...

Fastest algorithm for circle shift N sized array for M position

What is the fastest algorithm for circle shifting array for m positions? For example [3 4 5 2 3 1 4] shift m = 2 positions should be [1 4 3 4 5 2 3] Thanks a lot ...

Byte array in objective-c

How can create a byte array in objective c programming ... i have the data that is "0x12,0x23,0x34,0x45,0x56,0x67,0x78,0x89,0x12,0x23,0x34,0x45,0x56,0x67,0x78,0x89" i want it prepare as a byte array... pls help me.. ... if anybody have any sample project.. pls give me... ...

VB6 Dynamic Array Determination

In VB6 you can declare an array statically and dynamically. When an array is declared dynamically, is it possible to determine if the array was declared dynamic and therefore would possibly need a "redim" before it can be used? i.e. I'm looking for something like: if myarray is dynamic then redim ... end if myarray(x) = y ...

Dynamically allocating and setting to zero an array of floats

Hi How do I automatically set a dynamically allocated array of floats to zero(0.0) during allocation Is this OK float* delay_line = new float[filter_len]; //THIS memset(delay_line, 0.0, filter_len); //can I do this for a float?? //OR THIS for (int i = 0; i < filter_len; i++) delay_line[i] = 0.0; Which is the most efficient way ...

What's the simplest way to extend a numpy array in 2 dimensions?

I have a 2d array that looks like this: XX xx What's the most efficient way to add an extra row and column: xxy xxy yyy For bonus points, I'd like to also be able to knock out single rows and columns, so for example in the matrix below I'd like to be able to knock out all of the a's leaving only the x's - specifically I'm trying to...

How can I remove the leading zeroes from an integer generated by a loop and store it as an array?

I have a for loop generating integers. For instance: for (int i=300; i>200; i--) {(somefunction)*i=n; cout<<n; } This produces an output on the screen like this: f=00000000000100023; I want to store the 100023 part of this number (i.e just ignore all the zeros before the non zero numbers start but then keeping the zer...

how do i remove an element of an array and shift the reamining elements down

hi guys how do i remove an element of an array and shift the reamining elements down so if i have an array array[]={1,2,3,4,5} and want to delete 3 and shift the rest so i have array[]={1,2,4,5} how would i go abot this in the least amount of code! ...

Returning an array in Specman

How do I return an array from a method call in Specman? E.g. method a : list of uint is { var data: list of uint; ..... result = data; }; extend sys { var data_sys: list of uint; run() is also { data_sys = a(); }; }; My print out shows some elements are different from array data and data_sys. Can you tell me what I mi...

How to convert int[] to Integer[] in Java?

I'm new to Java and very confused. I have a large dataset of length 4 int[] and I want to count the number of times that each particular combination of 4 integers occurs. This is very similar to counting word frequencies in a document. I want to create a Map<int[], double> that maps each int[] to a running count as the list is iterate...

hardcode byte array in C

I'm debugging a network application. I have to simulate some of the data exchanged in order for the application to work. In C++ you can du something like char* myArray = { 0x00, 0x11, 0x22 }; however I can't seem to find a C equivalent for this syntax. Basically I just want to fill an array with hard coded values ...

What is a difference of Array and Hash? :php

What is differents from an arrangement in a hash in PHP? An arrangement: array(1,2,3...) A hash: array(key1=value1, key2=value2, ...) Or will it be a thing to treat as the totally same thing? ※ For example, will the function arguments allows array be effective for the hash? Because I distinguish it by the conventional language...