arrays

Storing an integer into a char* in C++

I'm writing some code that returns an integer, which then needs to be outputted using printw from the ncurses library. However, since printw only takes char*, I can't figure out how to output it. Essentially, is there a way to store a integer into a char array, or output an integer using printw? ...

Creating a multidimensional array from row

How would I take an array such as this: Array ( [key1] => item1 [key2] => item2 [key3] => item3 [key4] => item4 [key5] => item5 [key6] => item6 ) php: $array = array('key1' => 'item1','key2' => 'item2', 'key3' => 'item3','key4' => 'item4', 'key5' => 'item5','key6' => 'item6'); and create a multidimensional array with every 3 val...

how do to initialize array in java?

i am initializing an array data like: public class Array { int data[] = new int[10]; /** Creates a new instance of Array */ public Array() { data[10] = {10,20,30,40,50,60,71,80,90,91}; } } NB points an error at the line data[10] = {10,20,30,40,50,60,71,80,90,91}; i cudn't get wat it is? any suggestions. ...

reading int from console

How can I convert a String array into an int array in java? I am reading a stream of integer characters into a String array from the console, with BufferedReader br = new BufferedReader (new InputStreamReader(System.in)); for(c=0;c<str.length;c++) str[c] = br.readLine(); where str[] is String typed. I want to compare the str[] ...

how will I find odd elements from two arrays

I have one array int a[] = {1,2,3}; int b[] = {1,2}; how will I find the odd element in array ...

Getting a typed array from a discriminate union of different types of arrays in F#

If I have a discriminate union of different types of arrays how can i convert them to their 'actual' types? type ItemStuff = | Colors of string[] | Sizes of int[] let foo = Sizes [|1;2;3|] After running the above when I get the value of foo I see: val foo : ItemStuff = Sizes [|1;2;3|] How can I get an actual array of int's...

Constructing a python set from a numpy matrix

I'm trying to execute the following >> from numpy import * >> x = array([[3,2,3],[4,4,4]]) >> y = set(x) TypeError: unhashable type: 'numpy.ndarray' How can I easily and efficiently create a set from a numpy array? ...

Remove "NULL rows" from a String array using LINQ

How would you remove "NULL rows" from a String array using LINQ? Take this structure (String[,]): "Hello", "World", "Foo", "Bar" null, null, null, null null, null, null, null "Hello", "World", "Foo", "Bar" "Hello", "World", "Foo", "Bar" null, null, "Foo", "Bar" The two rows after the first row should be removed. T...

Defining two dimensional Dynamic Array

How can I define two dimensional dynamic array?? If I want to use list,can I use it for two dimensional ?? ...

Selecting every nth item from an array

What would be the most efficient way to select every nth item from a large array? Is there a 'smart' way to do it or is looping the only way? Some points to consider: The array is quite large with 130 000 items I have to select every 205th item The items are not numerically indexed, so for($i = 0; $i <= 130000; $i += 205) won't work ...

Perl Array Question

Never done much programming -- been charged at work with manipulating the data from comment cards. Using perl so far I've got the database to correctly put its daily comments into an array. Comments are each one LINE of text within the database, so I just split the array on the line-break. my @comments = split("\n", $c_data); And yes,...

array of pointers allocation

Hi all, typedef struct { struct table **symbols; // array of the stack int top; //index of the top element int size; //maximum size of the stack }stack; void *createStack(int size) { stack *stck; stck = (stack *) malloc(sizeof(stack)); stck->symbols = .... stck->size = size; stck->top = -1; printf("stack is created...

How can I prevent perl from reading past the end of a tied array that shrinks when accessed?

Is there any way to force Perl to call FETCHSIZE on a tied array before each call to FETCH? My tied array knows its maximum size, but could shrink from this size depending on the results of earlier FETCH calls. here is a contrived example that filters a list to only the even elements with lazy evaluation: use warnings; use strict; pa...

Jquery: Matching indexes of two arrays, string and object to replace text in object?

I have two arrays, one is full of strings, the other is an array of objects. The indexes on each correspond, and I want to replace the text of each of the objects in my object array with the corresponding text in my string array. For example, I have an array like this: var textarr = ["value1", "value2", "value3"] and a Jquery object ...

Sqlite3 Database versus populating Arrays

hi, I am working on a program that requires me to input values for 12 objects, each with 4 arrays, each with 100 values. (4800) values. The 4 arrays represent possible outcomes based on 2 boolean values... i.e. YY, YN, NN, NY and the 100 values to the array are what I want to extract based on another inputted variable. I previously ...

PHP-ILooping an arrays values through a larger array

I want to know if it is possible to take an array and insert the array's values into a bigger array, multiple times, so that the values of the smaller array fill up the bigger array. Say array1 has values ([0 => 'a'],[1 => 'b'],[2 => 'c']), and array2 can hold 8 values. So, how would I take the values of array1 and insert them into arr...

C++ Array Constructor

hi together, I was just wondering, whether an array member of a class could be created immediately upon class construction: class C { public: C(int a) : i(a) {} private: int i; }; class D { public: D() : a(5, 8) {} D(int m, int n) : a(m,n) {} private: C a[2]; }; As far as...

Defining Arrays in Prototype Classes?

Hi there, I was trying to create a prototype object with four attributes: 'name', 'basis' and 'rows', which are values taken from a form and 'head' which should be an array of string values. Classdef: var TableTemplate = Class.create(); TableTemplate.prototype = { initialize: function(name, basis, head, rows) { thi...

C++ Array vs vector

when using C++ vector, time spent is 718 milliseconds, while when I use Array, time is almost 0 milliseconds. Why so much performance difference? int _tmain(int argc, _TCHAR* argv[]) { const int size = 10000; clock_t start, end; start = clock(); vector<int> v(size*size); for(int i = 0; i < size; i++) { for(int j = 0; j < size; j+...

UIImage to byte array

Hi Frineds, I am new in iPhone development. I want to convert an Image to Byte array. I tried to do this.But i didn't get any result. Please give me guideline for this problem. or provide me some tutorial regarding this problem... Thanks in Advance, Pathik Patel ...