Search Results

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

Page 100/610 | < Previous Page | 96 97 98 99 100 101 102 103 104 105 106 107  | Next Page >

  • Objective-C: how to allocate array of GLuint

    - by sashaeve
    I have an array of GLuint with fixed size: GLuint textures[10]; Now I need to set a size of array dynamically. I wrote something like this: *.h: GLuint *textures; *.m: textures = malloc(N * sizeof(GLuint)); where N - needed size. Then it used like this: glGenTextures(N, &textures[0]); // load texture from image -(GLuint)getTexture:(int)index{ return textures[index]; } I used the answer from here, but program fell in runtime. How to fix this? Program is written on Objective-C and uses OpenGL ES.

    Read the article

  • append versus resize for numpy array

    - by Abruzzo Forte e Gentile
    Hi all I would like to append a value at the end of my numpy.array. I saw numpy.append function but this performs an exact copy of the original array adding at last my new value. I would like to avoid copies since my arrays are big. I am using resize method and then set the last index available to the new value. Can you confirm that resize is the best way to append a value at the end? Is it not moving memory around someway? Thanks AFG oldSize = myArray,shape(0) myArray.resize( oldSize + 1 ) myArray[oldSize] = newValue

    Read the article

  • Initialization of array on heap

    - by Radek Šimko
    How do i manually initiate values in array on heap? If the array is local variable (in stack), it can be done very elegant and easy way, like this: int myArray[3] = {1,2,3}; Unfortunately, following code int * myArray = new int[3]; myArray = {1,2,3}; outputs an error by compiling error: expected primary-expression before ‘{’ token error: expected `;' before ‘{’ token Do i have to use cycle, or not-so-much-elegant way like this? myArray[0] = 1; myArray[1] = 2; myArray[2] = 3;

    Read the article

  • Getting count() of class static array

    - by xylar
    Is it possible to get the count of a class defined static array? For example: class Model_Example { const VALUE_1 = 1; const VALUE_2 = 2; const VALUE_3 = 3; public static $value_array = array( self::VALUE_1 => 'boing', self::VALUE_2 => 'boingboing', self::VALUE_3 => 'boingboingboing', ); public function countit() { // count number $total = count(self::$value_array ); echo ': '; die($total); } } At the moment calling the countit() method returns :

    Read the article

  • how to add values in array

    - by nhoyti
    hi guys, i just want to ask help again. I've created a method to read values in gridview, i was able to get and read values from the gridview. The problem now, is how can i store the values inside an array and i want it to pass on the other page. here's the code i've created private void getrowvalues() { string combinedvalues; foreach (GridViewRow row in gvOrderProducts.Rows) { string prodname = ((Label)row.FindControl("lblProductName")).Text; string txtvalues = ((TextBox)row.FindControl("txtQuantity")).Text; combinedvalues = prodname + "|" + txtvalues; } } i want the result string combinedvalues to be put in an array or collection of strings which i can be access in other page. Is there a way to do it? Any inputs will be greatly appreciated. thanks!!

    Read the article

  • C++ associative array with arbitrary types for values

    - by Gerald Kaszuba
    What is the best way to have an associative array with arbitrary value types for each key in C++? Currently my plan is to create a "value" class with member variables of the types I will be expecting. For example: class Value { int iValue; Value(int v) { iValue = v; } std::string sValue; Value(std::string v) { sValue = v; } SomeClass *cValue; Value(SomeClass *v) { cValue = c; } }; std::map<std::string, Value> table; A downside with this is you have to know the type when accessing the "Value". i.e.: table["something"] = Value(5); SomeClass *s = table["something"].cValue; // broken pointer Also the more types that are put in Value, the more bloated the array will be. Any better suggestions?

    Read the article

  • Need help setting up json array

    - by torr
    A database query returns several rows which I loop through as follows: foreach ($query->result() as $row) { $data[$row->post_id]['post_id'] = $row->post_id; $data[$row->post_id]['post_type'] = $row->post_type; $data[$row->post_id]['post_text'] = $row->post_text; } If I json_encode the resulting array ($a['stream']) I get { "stream": { "1029": { "post_id": "1029", "post_type": "1", "post_text": "bla1", }, "1029": { "post_id": "1030", "post_type": "3", "post_text": "bla2", }, "1029": { "post_id": "1031", "post_type": "2", "post_text": "bla3", } } } But the json should actually look like this: { "stream": { "posts": [{ "post_id": "1029", "post_type": "1", "post_text": "bla1", }, { "post_id": "1030", "post_type": "3", "post_text": "bla2", }, { "post_id": "1031", "post_type": "2", "post_text": "bla3", }] } } How should I build my array to get this json right?

    Read the article

  • A good way to look back arbitrary number of items in the Array.Fold in F#

    - by tk
    In the folder function of the Array.Fold operation, i want to look back arbitrary number of items. The only way i can figure out is like this. let aFolder (dataArray, curIdx, result) (dataItem) = let N = numItemsToLookBack(result, dataItem) let recentNitems = dataArray.[curIdx - n .. curIdx - 1] let result = aCalc(result, dataItem, recentNitems ) dataArray, curIdx + 1, result myDataArray | Array.fold aFolder (myDataArray, 0, initResult) As you can see, I passed the whole dataArray and index to the folder function to get the "recentNitems". But this way allows the folder function to access not only preceding data, but also the following data. Is there a better (or more functional) way?

    Read the article

  • Getting the last element of a Postgres array, declaratively

    - by Wojciech Kaczmarek
    How to obtain the last element of the array in Postgres? I need to do it declaratively as I want to use it as a ORDER BY criteria. I wouldn't want to create a special PGSQL function for it, the less changes to the database the better in this case. In fact, what I want to do is to sort by the last word of a specific column containing multiple words. Changing the model is not an option here. In other words, I want to push Ruby's sort_by {|x| x.split[-1]} into the database level. I can split a value into array of words with Postgres string_to_array or regexp_split_to_array functions, then how to get its last element?

    Read the article

  • How to dispatch a multimethod on the type of an array

    - by Arthur Ulfeldt
    I'm working on a multimethod that needs to update a hash for a bunch of different things in a sequence. Looked fairly straitforward until I tried to enter the 'type of an array of X'. (defmulti update-hash #(class %2)) (type (byte 1)) => java.lang.Byte (defmethod update-hash java.lang.Byte [md byte] (. md update byte)) (type (into-array [ (byte 1)])) => [Ljava.lang.Byte; (defmethod update-hash < WHAT GOES HERE > [md byte]

    Read the article

  • iOS Development: Should the "playersToInvite" property contain an array of strings or an array of GKPlayer objects?

    - by BeachRunnerJoe
    Should the playersToInvite property of the GKMatchRequest object contain an array of NSString objects that hold the player id's or should it contain an array of GKPlayer objects? The documentation on this critical property is not clear at all and I've tried both ways, but my code isn't working, so I can't tell by experimentation. Here's the description for that property in the docs... A list of players to invite to the match. Why did they even bother writing that? Thanks for your help!

    Read the article

  • error while converting the byte arry to image ,after modifying the byte array and the byte array is

    - by geehta
    Hi, this is my code. Here i hv formed the byte array of img, i am trying to add some vlue to this byte array say 10 and i'll take care that the value is not exceeding 255. later if i try to redraw the image via the following code i am getting error at this line... what can be the problem.. without modification if i try to draw the image it is coming but if i cahnge some value it is not drawing.. public Image btoi(byte[] bt) { ms = new MemoryStream(bt, 0, bt.Length); img = Image.FromStream (ms, true); // error at this line ms.Close(); return img; }

    Read the article

  • Inserting a number into a sorted array!

    - by Jay
    I would like to write a piece of code for inserting a number into a sorted array at the appropriate position (i.e. the array should still remain sorted after insertion) My data structure doesn't allow duplicates. I am planning to do something like this: 1. Find the right index where I should be putting this element using binary search 2. Create space for this element, by moving all the elements from that index down. 3. Put this element there. Is there any other better way?

    Read the article

  • C - memset segfault for statically allocated char array

    - by user1327031
    I get a segfault when trying to memset an array of chars that was allocated statically, but not for an array of the same length that was allocated using malloc. variable definitions: //static char inBuff[IN_BUFF_LEN]; //dynamic char * inBuffD; function call: //static, cast used because char** != char (*) [n] serverInit(portNum, (char**) &inBuff, &serv_addr, &sockfd) //dynamic serverInit(portNum, &inBuffD, &serv_addr, &sockfd) use within the function: memset(*inBuffAdr, 0, IN_BUFF_LEN); I suspect that my problem is in the difference of the function calls, or to be more precise, my incomplete understanding of the "char** != char (*) [n]" situation. But I have been banging at this for too long and can't see the forest from the trees so any hints and advice would be very appreciated.

    Read the article

  • Inserting and removing a string into/from an array

    - by alex
    Hello all! I have an array and variable. If the variable does not exist in the array it has to be added, otherwise it has to be removed. Why the following code does not work? $ar = ["a","b","c"]; $vr = "b"; foreach ($ar as $i => $value) { if ($value == $vr) { unset ($ar[$i]); } else { $ar[] = $vr; $ar = array_unique($ar); } } Thanks.

    Read the article

  • C++ string array from ifstream

    - by David Beck
    I have a program that I need to read in an array of strings from a file. The array must be C type strings (char * or char[]). Using the following code, I get a bad access error: for (i = 0; i < MAX_WORDS && !inputFile.eof(); i++) { inputFile >> words[i]; } words is declared as: char *words[MAX_WORDS];

    Read the article

  • Python/Numpy - Save Array with Column AND Row Titles

    - by Scott B
    I want to save a 2D array to a CSV file with row and column "header" information (like a table). I know that I could use the header argument to numpy.savetxt to save the column names, but is there any easy way to also include some other array (or list) as the first column of data (like row titles)? Below is an example of how I currently do it. Is there a better way to include those row titles, perhaps some trick with savetxt I'm unaware of? import csv import numpy as np data = np.arange(12).reshape(3,4) # Add a '' for the first column because the row titles go there... cols = ['', 'col1', 'col2', 'col3', 'col4'] rows = ['row1', 'row2', 'row3'] with open('test.csv', 'wb') as f: writer = csv.writer(f) writer.writerow(cols) for row_title, data_row in zip(rows, data): writer.writerow([row_title] + data_row.tolist())

    Read the article

  • Iterating Through a jQuery Object Array

    - by DeltaFox
    I know this has been asked and answered a couple times already, but I'm still confused about how to reference the current object when iterating over a jQuery array. For example, the following code gives me the error "TypeError: genH3Array[i].next is not a function". What is the right way to reference the current array object? var genH3Array = $('#Generation_II').parent(); genH3Array.push($('#Generation_III').parent());; genH3Array.push($('#Generation_IV').parent()) $.each(genH3Array, function(i, value) { if(genH3Array[i].next().attr("align") == "center") { genH3Array[i].next().next().next().insertBefore(heading.next()) } genH3Array[i].next().next().insertBefore(heading.next()) genH3Array[i].next().insertBefore(heading.next()) })

    Read the article

  • seprate a string array to several small arrays

    - by blgnklc
    how can I separate an array in smaller arrays? string[] str = new string[145] I want two arrays for this; like string[] str1 = new string[99]; string[] str2 = new string[46]; how can I do this from the source of str? 1- Then I want to put togetger the arrays into List all together but there is only add item? no add items? or any other way to make the string[145] array again..

    Read the article

  • Separating Variables Inside an Array

    - by Jake Avila Talledo
    Hey i have an array an I need to separate each value so it would be something like this $arry = array(a,b,c,d,e,f) $point1 = (SELECT distance FROM Table WHERE Origin = a AND Destination = b); $point2 = (SELECT distance FROM Table WHERE Origin = b AND Destination = c); $point3 = (SELECT distance FROM Table WHERE Origin = c AND Destination = d); $point4 = (SELECT distance FROM Table WHERE Origin = d AND Destination = e); $point5 = (SELECT distance FROM Table WHERE Origin = e AND Destination = f); $point6 = (SELECT distance FROM Table WHERE Origin = f AND Destination = g); $point7 = (SELECT distance FROM Table WHERE Origin = g AND Destination = f); $total_trav = $point1+$point2+$point3+$point4+$point5+$point6+$point7

    Read the article

  • How to find the Mode in Array C#?

    - by sarah
    I want to find the Mode in an Array. I know that I have to do nested loops to check each value and see how often the element in the array appears. Then I have to count the number of times the second element appears. The code below doesn't work, can anyone help me please. for (int i = 0; i < x.length; i ++) { x[i]++; int high = 0; for (int i = 0; i < x.length; i++) { if (x[i] > high) high = x[i]; } }

    Read the article

< Previous Page | 96 97 98 99 100 101 102 103 104 105 106 107  | Next Page >