Search Results

Search found 15239 results on 610 pages for 'array population'.

Page 19/610 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • Deleting Part of An Array in Java to Free Memory on Heap

    - by kate
    I am implementing a dynamic programming algorithm for the knapsack problem in Java. I declare the array and then initialize its size to be [number of objects][capacity of knapsack]. When my number of objects or my capacity gets too large, I get a memory error because I run out of space on the heap. My questions is: If I delete rows from my double array as I go along, will Java free the memory as I delete? Or does Java reserve that memory space for the size of the array I originally created? If it's the latter, is there a way to manually free the memory in Java? Thanks for your Help!

    Read the article

  • Make jquery array out of div

    - by Industrial
    Hi everyone, Each div with the class "row" is added upon request from the user, to be able to add multiple items at once. So now is the question how I'll collect all the forms in to an array that PHP can read (like JSON for instance). I'll guess that there's already some easy and effective way of doing this? <div class="container"> <div class="row"> <input type="text" name="value1" id="textfield" /> <input type="text" name="value2" id="textfield" /> <input type="text" name="value3" id="textfield" /> </div> </div> Here's what I would like to achieve out of the shown example: array( array ('value1' => '', 'value2' => '', 'value3' => '') ); Thanks!

    Read the article

  • Unable to send an associative array in JSON format in Zend to client

    - by Anorflame
    Hi, In one of my actions in a controller, I'm using the json view helper to send back a response to an ajax request. On the client side I alert the data that is passed to the success callback function. It works fine as long as the response is a number or an array with default keys. Once I try to send an associative array, it alerts with [object Object]. Server code: $childArray = array('key'=>'value'); $this->_helper->json($childArray); javascript: function displayChildren(data){ alert(data); } ... $.ajax({ url: "/po/add", dataType: "json", data: {format: "json"}, success: displayChildren }); I have no idea what am I doing wrong here, so any help would be appreciated...

    Read the article

  • Passing an array of structures to an Oracle stored procedure (CFMX)

    - by Patti
    I'm looking to write a Oracle stored procedure where I would pass in (from ColdFusion) an array of structures and loop over each iteration to insert the bits and pieces within the structures to the DB., I haven't written this type of procedure / package before. I am planning to do an sp / package similar to what is sketched out in the second reply to this thread: How to pass a array of object to oracle stored procedure Assuming I do, how can I call the procedure from ColdFusion (I'm using MX) and pass in my array? As far as I can see, none of the CF_SQL_Types make sense.

    Read the article

  • php associative array name?

    - by daniel Crabbe
    hello! Just trying to get the name of an assoc array; $test = array('selected' =>$selected, 'sectionList'=>$sectionList, 'categoryList'=>$categoryList); <? foreach($test as $list) { ?> <h3><?=$list?>, <?=$list[id]?>, <?=$list['name']?>, <?=$list['value']?></h3> <? } ?> but either get 'Array' or nothing?! I can see the name when i print_r($test); Do you think this is possible? Thanks in advance, D.

    Read the article

  • An array of structures in C...

    - by 00010000
    For the life of me I can't figure out the proper syntax for creating an array of structures in C. I tried this: struct foo { int x; int y; } foo[][] = { { { 1, 2 }, { 4, 5 }, { -1, -1 } }, { { 55, 44 } { 100, 200 }, } }; So for example foo[1][0].x == 100, foo[0][1].y == 5, etc. But GCC spits out a lot of errors. If anyone could provide the proper syntax that'd be great. EDIT: Okay, I tried this: struct foo { const char *x; int y; }; struct foo bar[2][] = { { { "A", 1 }, { "B", 2 }, { NULL, -1 }, }, { { "AA", 11 }, { "BB", 22 }, { NULL, -1 }, }, { { "ZZ", 11 }, { "YY", 22 }, { NULL, -1 }, }, { { "XX", 11 }, { "UU", 22 }, { NULL, -1 }, }, }; But GCC gives me "elements of array bar have incomplete type" and "excess elements in array initializer".

    Read the article

  • C: Why does gcc allow char array initialization with string literal larger than array?

    - by Ashwin
    int main() { char a[7] = "Network"; return 0; } A string literal in C is terminated internally with a nul character. So, the above code should give a compilation error since the actual length of the string literal Network is 8 and it cannot fit in a char[7] array. However, gcc (even with -Wall) on Ubuntu compiles this code without any error or warning. Why does gcc allow this and not flag it as compilation error? gcc only gives a warning (still no error!) when the char array size is smaller than the string literal. For example, it warns on: char a[6] = "Network"; [Related] Visual C++ 2012 gives a compilation error for char a[7]: 1>d:\main.cpp(3): error C2117: 'a' : array bounds overflow 1> d:\main.cpp(3) : see declaration of 'a'

    Read the article

  • Jagged Edge Arrays in PHP

    - by chriscct7
    I want to store some data in (I guess a semi-2, semi-3d array) in PHP (5.3) What I need to do is store data about each floor like this: Floor Num of Spots Handicap Motorcyle Other 1 100 array(15,16,17) array (47,62) array (99,100) 2 100 array(15,16,17) array (47,62) array (99,100) and on The problem is, is if the Handicap+Motorcyle+Other were ints, I could just store the data in a 2d array. However, they aren't. So I was thinking I could make something almost like a 3D array, with the first two columns only being in 2D. The other thought I had was making a 2D array and for columns 3,4, and 5 instead of saving as array(15,16) //save like 1516 And then split at two digits (1 digit array numbers would be prefaced with a 0). However, I am wondering about the limit of the length of a string, because if I decide to move to a 3 digit length number in the array, like array(100, 104), and I need to store alot of numbers, I am thinking I am going to quickly exceed the max.

    Read the article

  • Handling array passed to object at creation

    - by cecilli0n
    When creating my object I pass it an array of a row from my database. (everything in the array we will need, disregarding unnecessary elements at sql query level) When I need to access certain array elements from within my class, I do so like $this->row['element'] However, As I continue development, I sometimes forget what exactly is in this passed array.(this itself doesn't seem good) I am wondering if their is a professional approach to dealing with this, Or am I the only one who has these "I wonder whats in the array" thoughts. One approach to tackling this could be that when we originally pass the array, in the constructor, we assign each element of the array to its own variable, but is this considered professional practice? Additionally by doing this, we could make those variables constants, in a attempt at immutability. Overall I am trying to adhere to good software craftsmanship. Regards.

    Read the article

  • how to reduce 2d array

    - by owca
    I have a 2d array, let's say like this : 2 0 8 9 3 0 -1 20 13 12 17 18 1 2 3 4 2 0 7 9 How to create an array reduced by let's say 2nd row and third column? 2 0 9 13 12 18 1 2 4 2 0 9

    Read the article

  • How to get an Array in jQuery with multiple-input (same input id)

    - by x4tje
    Hello, I've a form where you're able to add more input fields with jQuery. <input type="text" id="task" name="task[]" /> I get an array when i print it with php after submitting the form. I want to handle this with the $.ajax() but i've no idea how i can turn up my <input type="text" id="task" name="task[]" /> in an array in jQuery. Thanks in advance, Firdaus

    Read the article

  • Python: Create a duplicate of an array

    - by Dan
    I have an double array alist[1][1]=-1 alist2=[] for x in xrange(10): alist2.append(alist[x]) alist2[1][1]=15 print alist[1][1] and I get 15. Clearly I'm passing a pointer rather than an actual variable... Is there an easy way to make a seperate double array (no shared pointers) without having to do a double for loop? Thanks, Dan

    Read the article

  • PHP: How to find most used array key?

    - by oni-kun
    Lets say I have a simple 1D array with 10-20 entries. Some will be duplicate, How would I find out which entry is used the most? like.. $code = Array("test" , "cat" , "test" , "this", "that", "then"); How would I show "test" as the most used entry?

    Read the article

  • Objective-C Array/List Question

    - by Dave C
    What is the best practice, even in general programming, when you have an undefined, possibly infinite, amount of items that you need in an array but don't have defined bounds. Can you define an endless array in objective c that you can keep pushing items onto, like other lanaguages have a list item. Thanks for any help.

    Read the article

  • Print and array to a file..

    - by atif089
    Hi, I would like to print an array to a file. I would like the file to look exactly similar like how a code like this looks. print_r ($abc); assuming $abc is an array. Is there any one lines solution for this rather than regular for each look. P.S - I currently use serialie but i want to make the files readable as readability is quite hard with serialized arrays.

    Read the article

  • Flex: changing value in an array where elements are objects

    - by Treby
    Example: var arr_1:Array = new Array(); arr_1.push({sdate:"2010-02-02",status:"New"}); arr_1.push({sdate:"2010-02-03",status:"New"}); arr_1.push({sdate:"2010-02-04",status:"New"}); arr_1.push({sdate:"2010-02-05",status:"New"}); How can i change element number 3 status to: "Old", without removing it. just update the status value??

    Read the article

  • C Programming: malloc() for a 2D array (using pointer-to-pointer)

    - by vikramtheone
    Hi Guys, yesterday I had posted a question: How should I pass a pointer to a function and allocate memory for the passed pointer from inside the called function? From the answers I got, I was able to understand what mistake I was doing. I'm facing a new problem now, can anyone help out with this? I want to dynamically allocate a 2D array, so I'm passing a Pointer-to-Pointer from my main() to another function called alloc_2D_pixels(...), where I use malloc(...) and for(...) loop to allocate memory for the 2D array. Well, after returning from the alloc_2D_pixels(...) function, the pointer-to-pointer still remains NULL, so naturally, when I try accessing or try to free(...) the Pointer-to-Pointer, the program hangs. Can anyone suggest me what mistakes I'm doing here? Help!!! Vikram SOURCE: main() { unsigned char **ptr; unsigned int rows, cols; if(alloc_2D_pixels(&ptr, rows, cols)==ERROR) // Satisfies this condition printf("Memory for the 2D array not allocated"); // NO ERROR is returned if(ptr == NULL) // ptr is NULL so no memory was allocated printf("Yes its NULL!"); // Because ptr is NULL, with any of these 3 statements below the program HANGS ptr[0][0] = 10; printf("Element: %d",ptr[0][0]); free_2D_alloc(&ptr); } signed char alloc_2D_pixels(unsigned char ***memory, unsigned int rows, unsigned int cols) { signed char status = NO_ERROR; memory = malloc(rows * sizeof(unsigned char** )); if(memory == NULL) { status = ERROR; printf("ERROR: Memory allocation failed!"); } else { int i; for(i = 0; i< cols; i++) { memory[i] = malloc(cols * sizeof(unsigned char)); if(memory[i]==NULL) { status = ERROR; printf("ERROR: Memory allocation failed!"); } } } // Inserted the statements below for debug purpose only memory[0][0] = (unsigned char)10; // I'm able to access the array from printf("\nElement %d",memory[0][0]); // here with no problems return status; } void free_2D_pixels(unsigned char ***ptr, unsigned int rows) { int i; for(i = 0; i < rows; i++) { free(ptr[i]); } free(ptr); }

    Read the article

  • [PHP Array] - Sorting data and print out in alphabetic order

    - by kwokwai
    Hi all, I got an array which contains some data like this: $arrs = Array("ABC_efg", "@@zzAG", "@$abc", "ABC_abc") I was trying to print the data out in this way (Printing in alphabetic order): [String begins with character A] ABC_abc ABC_efg [String begins with character other than A to Z] @$abc @@zzAG I don't know how to do it.

    Read the article

  • using an array in a custom formula in crystal reports xi

    - by Kim Sharpe
    I have a formula which is working; the formula uses an array. I tried to extract the formula to create a custom formula but now get an error in the syntax. I am wondering if the array is causing the problem as the error is on the line: last_element_current:=val(sc_array[1]) + 1; and the error is: the ) is missing and highlights the variable sc_array before the index [1].

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >