Search Results

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

Page 68/610 | < Previous Page | 64 65 66 67 68 69 70 71 72 73 74 75  | Next Page >

  • Any array function or user defned function to pick up only first occurance of value from the array?

    - by OM The Eternity
    If i have an array Array ( [0] => Array ( [0] => 137 [id] => 137 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => 0 [oldvalue] => 0 [5] => 62 [newvalue] => 62 [6] => checked_out [field] => checked_out [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:28 [changedone] => 2010-05-11 17:46:28 ) [1] => Array ( [0] => 138 [id] => 138 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => 0000-00-00 00:00:00 [oldvalue] => 0000-00-00 00:00:00 [5] => 2010-05-11 12:16:28 [newvalue] => 2010-05-11 12:16:28 [6] => checked_out_time [field] => checked_out_time [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:28 [changedone] => 2010-05-11 17:46:28 ) [2] => Array ( [0] => 139 [id] => 139 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => Subhash [oldvalue] => Subhash [5] => Subhashgfhfgh [newvalue] => Subhashgfhfgh [6] => name [field] => name [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:35 [changedone] => 2010-05-11 17:46:35 ) [3] => Array ( [0] => 140 [id] => 140 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => subhash [oldvalue] => subhash [5] => subhashhfhf [newvalue] => subhashhfhf [6] => alias [field] => alias [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:35 [changedone] => 2010-05-11 17:46:35 ) [4] => Array ( [0] => 141 [id] => 141 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => 62 [oldvalue] => 62 [5] => 0 [newvalue] => 0 [6] => checked_out [field] => checked_out [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:35 [changedone] => 2010-05-11 17:46:35 ) [5] => Array ( [0] => 142 [id] => 142 [1] => 153 [trackid] => 153 [2] => jos_menu [table_name] => jos_menu [3] => UPDATE [operation] => UPDATE [4] => 2010-05-11 12:16:28 [oldvalue] => 2010-05-11 12:16:28 [5] => 0000-00-00 00:00:00 [newvalue] => 0000-00-00 00:00:00 [6] => checked_out_time [field] => checked_out_time [7] => 0 [live] => 0 [8] => 2010-05-11 17:46:35 [changedone] => 2010-05-11 17:46:35 ) ) Now here u can see that the index "field" has repeated values i.e. "checked_out" and "checked_out_time" other indexes have single occurrence, now what should I do to select/grab the first occurrence of the repetitive values only?

    Read the article

  • actionscript 3 array question

    - by Naro
    var arr1:Array = new Array(); arr1.push(item1); arr1.push(item2); arr1.push(item3); then arr1 and its elements get passed to other functions is there a way to know the index of an item in the array? GetParentArrayIndex(item2) would give me 1;

    Read the article

  • FileHelpers cannot map converted field into destination array

    - by jaffa
    I have the following record (reduced for brevity): [DelimitedRecord(",")] [IgnoreFirst] [IgnoreEmptyLines()] public class ImportRecord { [FieldQuoted] [FieldTrim(TrimMode.Both)] public string FirstName; [FieldQuoted] [FieldTrim(TrimMode.Both)] public string LastName; [FieldQuoted] [FieldTrim(TrimMode.Both)] [FieldOptional] [FieldConverter(typeof(TestPropertyConverter))] public int[] TestProperty; } Converter code: public class TestPropertyConverter : ConverterBase { public override object StringToField(string from) { var ret = from.Split('|').Select(x => Convert.ToInt32(x)).ToArray(); return ret; } } So an example record could be: John, Smith, 1|2|3|4 It would expect the values 1,2,3,4 to expand and fill the TestProperty array. However, I'm getting the following exception: At least one element in the source array could not be cast down to the destination array type. I've tried to debug into the code and it seems to blow-up in the ExtractFieldValue() function inside FieldBase.cs where it tries to return out of the function. The following line seems to be the culprit: res.ToArray(ArrayType); It seems to expect the 'res' variable to be the destination type array, but it contains 1 element of the array itself. Can anyone suggest if I'm doing this wrong or a possible fix?

    Read the article

  • Converting contents of a byte array to wchar_t*

    - by Christopher MacKinnon
    I seem to be having an issue converting a byte array (containing the text from a word document) to a LPTSTR (wchar_t *) object. Every time the code executes, I am getting a bunch of unwanted Unicode characters returned. I figure it is because I am not making the proper calls somewhere, or not using the variables properly, but not quite sure how to approach this. Hopefully someone here can guide me in the right direction. The first thing that happens in we call into C# code to open up Microsoft Word and convert the text in the document into a byte array. byte document __gc[]; document = word->ConvertToArray(filename); The contents of document are as follows: {84, 101, 115, 116, 32, 68, 111, 99, 117, 109, 101, 110, 116, 13, 10} Which ends up being the following string: "Test Document". Our next step is to allocate the memory to store the byte array into a LPTSTR variable, byte __pin * value; value = &document[0]; LPTSTR image; image = (LPTSTR)malloc( document->Length + 1 ); Once we execute the line where we start allocating the memory, our image variable gets filled with a bunch of unwanted Unicode characters: ????????????????? And then we do a memcpy to transfer over all of the data memcpy(image,value,document->Length); Which just causes more unwanted Unicode characters to appear: ????????????????? I figure the issue that we are having is either related to how we are storing the values in the byte array, or possibly when we are copying the data from the byte array to the LPTSTR variable. Any help with explaining what I'm doing wrong, or anything to point me in the right direction will be greatly appreciated.

    Read the article

  • Convert Java String to Array

    - by Bruce
    This is a weird problem. Here is my code String reply = listen.executeUrl("http://localhost:8080/JavaBridge/reply.php); executeUrl returns as String object whatever is returned by the reply.php file. Now comes the problem. In reply.php I am returning an PHP array and reply is a String. When I do System.out.println("Reply = "+reply); I get Reply = array(2) { [0]=> string(14) "Dushyant Arora" [1]=> string(19 ) "@dushyantarora13 hi"} But reply is still a String. How do I convert it into a String array or an Array.

    Read the article

  • Having problems creating an array from XML data in Acrobat Javascript, please help if you can

    - by Kevin Minke
    I have a manually created array that already works example below: var PartsData = { 179: { ref:"", partNum: "201-2007-C00-00", descript: "System Monitor Card (Tracewell Only)", cage: "39764", qty: "1", SMR: "XBOZZ", UOC: "A" }}; Now this array above is is just one value in the array and it works fine. Here is the XML that I am trying to use to dynamically change the values. <?xml version="1.0" encoding="utf-8"?> <partsTables> <partsList> <part sheetNum="ta1"> <breakDownIndexNo>-1 </breakDownIndexNo> <referenceDesg/> <indent>20534220P01 </indent> <description/> <cage>TAC RI, GRADE-A SHOCK (TEC RACK), ALT P/N 72304-1</cage> <qtyPerAssy>23991 </qtyPerAssy> <smr>1 </smr> <uoc>ADODD </uoc> <blank/> </part> </partsList> </partsTables> I have this parsing just fine in Acrobat. Now I want to make the array work for me in using these values. if I have the following below it will work. Where part.item(i).indent.value equals the value of the indent node, etc. newArr = { 179: { ref: part.item(i).referenceDesg.value, partNum: part.item(i).indent.value, descript: part.item(i).cage.value, cage: part.item(i).qtyPerAssy.value, qty: part.item(i).smr.value, SMR: part.item(i).uoc.value, UOC: part.item(i).blank.value}}; As soon as I try to make the 179 value, which is in the breakDownIndexNo node, dynamic by using the direct part.item(i).breakDownIndexNo.value it will not compile. Acrobat is using javascript so I'm not sure why I can not get this to parse. I have tried to create a variable out of the breakDownIndexNo node and typed it to both a String and an Integer. this will let it create the array but it will not let me output from the array. newArr[indexNum].partNum gives me "no properties" where newArr[179].partNum if I were to manually set the index number to 179 will print out the value of part.item(i).indent.value. If any of you have an idea or an answer please let me know.

    Read the article

  • How to efficiently resize an array of values, without boxing, used within a Dictionary<string, float[]>

    - by makerofthings7
    In the code below, Pages is defined as public SortedDictionary<DateTime, float[]> Pages { get; set; } I am trying to dynamically increase the size of this array. Can anyone tell how to increase the sized of the innermost float[]? var tt = currentContainer.Pages[dateTime]; Array.Resize<float>(ref tt, currentContainer.Pages.Count + 1); Fail 1 I tried the following code and get index out of range exception SortedDictionary<DateTime, float[]> Pages = new SortedDictionary<DateTime,float[]>(); float[] xx = new float[1]; xx[0] = 1; DateTime tempTime = DateTime.UtcNow; Pages.Add(tempTime, xx); var tt = Pages[tempTime]; Array.Resize<float>(ref tt, Pages.Count + 1); Pages[tempTime][1] = 2; Fail 2 The following gives a compile time error (property, index, or dynamic member can't be used as a ref value) SortedDictionary<DateTime, float[]> Pages = new SortedDictionary<DateTime,float[]>(); float[] xx = new float[1]; xx[0] = 1; DateTime tempTime = DateTime.UtcNow; Pages.Add(tempTime, xx); var tt = Pages[tempTime]; // The line below is different from Fail 1 above ... compile time error Array.Resize<float>(ref Pages[tempTime], Pages.Count + 1); Pages[tempTime][1] = 2; Question What is the most performant answer to resize this array? Would the answer change if it's likely that the final size will be 100-200 floats or 700-900 floats? What if I change my allocation size from +1 to +128? .. or larger?

    Read the article

  • Linear Search with Jagged Array?

    - by Nerathas
    Hello, I have the following program that creates 100 random elements trough a array. Those 100 random value's are unique, and every value only gets displayed once. Although with the linear search it keeps looking up the entire array. How would i be able to get a Jagged Array into this, so it only "scans" the remaining places left? (assuming i keep the table at 100 max elements, so if one random value is generated the array holds 99 elements with linear search scans and on...) I assume i would have to implent the jagged array somewhere in the FoundLinearInArray? Hopefully this made any sence. Regards. private int ValidNumber(int[] T, int X, int Range) { Random RndInt = new Random(); do { X = RndInt.Next(1, Range + 1); } while (FoundLinearInArray(T, X)); return X; }/*ValidNumber*/ private bool FoundLinearInArray(int[] A, int X) { byte I = 0; while ((I < A.Length) && (A[I] != X)) { I++; } return (I < A.Length); }/*FoundInArray*/ public void FillArray(int[] T, int Range) { for (byte I = 0; I < T.Length; I++) { T[I] = ValidNumber(T, I, Range); } }/*FillArray*/

    Read the article

  • Auto pointer for unsigned char array?

    - by Gianluca
    I'd need a class like std::auto_ptr for an array of unsigned char*, allocated with new[]. But auto_ptr only calls delete and not delete[], so i can't use it. I also need to have a function which creates and returns the array. I came out with my own implementation within a class ArrayDeleter, which i use like in this example: #include <Utils/ArrayDeleter.hxx> typedef Utils::ArrayDeleter<unsigned char> Bytes; void f() { // Create array with new unsigned char* xBytes = new unsigned char[10]; // pass array to constructor of ArrayDeleter and // wrap it into auto_ptr return std::auto_ptr<Bytes>(new Bytes(xBytes)); } ... // usage of return value { auto_ptr<Bytes> xBytes(f()); }// unsigned char* is destroyed with delete[] in destructor of ArrayDeleter Is there a more elegant way to solve this? (Even using another "popular" library)

    Read the article

  • C++ Converting image to integer array

    - by jonathanasdf
    How would I go about converting the pixels in an image (.png file) to an integer array, where each pixel is converted to its ARGB integer equivalent? I would like to do this without using external libraries. Not a 2D integer array by the way, a 1D one (where access is through array[row*width+col]). Thanks.

    Read the article

  • Stable separation for two classes of elements in an array

    - by AndreyT
    Consider the following problem. We are given an array of elements belonging to one two classes: either red or blue. We have to rearrange the elements of the array so that all blue elements come first (and all red elements follow). The rearrangement must be done is stable fashion, meaning that the relative order of blue elements must be preserved (same for red ones). Is there a clever algorithm that would perform the above rearrangement in-place? A non-in place solution is, of course, straightforward. An obvious in-place solution would be to apply any stable sorting algorithm to the array. However, using a full-fledged sorting algorithm on an array intuitively feels like an overkill, especially taking into account the fact that we are only dealing with two classes of elements. Any ideas greatly appreciated.

    Read the article

  • turn array into object active record can use

    - by stormdrain
    I'm running a query and then decrypting it in the controller. After it is decrypted I was putting the results into an array and sending that to the view. The problem is with this solution I need to rewrite all of my views to parse the arrays sent instead of the active record objects sent before. Is there a way to turn the decrypted array back into an object that will work with existing active record code in the view? Before Controller: $name = $this->Clients_model->getNameData('*','client_id='.$clid,''); $data['name'] = $name; $this->load->view('names/name_view',$data); View: if($name->num_rows()) > 0){ foreach($name->result() as $row){ echo $row->data; [...] Now Controller: $name = $this->Clients_model->getNameData('*','client_id='.$clid,''); $nameArray= array(); foreach ($name->result() as $row){ $x = $row; $keys = array('id','client_id'); $unenc = array(); foreach ($x as $key=>$value){ if(! in_array($key, $keys)){ $unenc[$key]=$this->encrypt->decode($value,$this->e_key); }else{ $unenc[$key]=$value; } } array_push($nameArray,$unenc); } //Creates an object with the data, but doesn't work with CI active record //foreach ($nameArray as $akey => $aval) { // $namea -> {$akey} = $aval; //} //return $data; $data['name'] = $nameArray; $this->load->view('names/name_view',$data); View: if(count($name) > 0){ foreach($name as $key=>$row){ echo $row['data']; [...] In the second (now) controller there is some commented out code that will make an object, but it doesn't behave as expected with active record. Is there a way to take the $nameArray() array and change it into an object that will work with existing view code (such as the code in the 'before:view' above)? Thanks!

    Read the article

  • Doing a SetLength on an array passed into a proc by reference

    - by csharpdefector
    Hi All, Sure, even I can do this... var testarray : array of string; setlength(testarray, 5); but if I want to get clever and have a procedure into which I pass the array by referance like this I cant do it! procedure DoStuffWithArray(var passedarray : array of string); begin setlength(passedarray, 5); end; compiler says 'incompatible types' on the single line of code in my proc. I can do other stuff on the array like set set element values if i do a setlength before i call the proc, but I cannot do the setlength in my proc, which is what I want to do. Any help much appreciated, thanks all.

    Read the article

  • Correct syntax for matching a string inside a variable against an array

    - by Jamex
    Hi, I have a variable, $var, that contains a string of characters, this is a dynamic variable that contains the values from inputs. $var could be 'abc', or $var could be 'blu', I want to match the string inside variable against an array, and return all the matches. $array = array("blue", "red", "green"); What is the correct syntax for writing the code in php, my rough code is below $match = preg_grep($var, $array); (incorrect syntax of course) I tried to put quotes and escape slashes, but so far no luck. Any suggestion? TIA

    Read the article

  • Removing Duplicates in an array in C

    - by LuckySlevin
    The question is a little complex. The problem here is to get rid of duplicates and save the unique elements of array into another array with their original sequence. For example : If the input is entered b a c a d t The result should be : b a c d t in the exact state that the input entered. So, for sorting the array then checking couldn't work since I lost the original sequence. I was advised to use array of indices but I don't know how to do. So what is your advise to do that?

    Read the article

  • what use does the javascript for each method have (that map can't do)?

    - by JohnMerlino
    Hey all, The only difference I see in map and foreach is that map is returning an array and foreach is not. However, I don't even understand the last line of the foreach method "func.call(scope, this[i], i, this);". For example, isn't "this" and "scope" referring to same object and isn't this[i] and i referring to the current value in the loop? I noticed on another post someone said "Use forEach when you want to do something on the basis of each element of the list. You might be adding things to the page, for example. Essentially, it's great for when you want "side effects". I don't know what is meant by side effects. Array.prototype.map = function(fnc) { var a = new Array(this.length); for (var i = 0; i < this.length; i++) { a[i] = fnc(this[i]); } return a; } Array.prototype.forEach = function(func, scope) { scope = scope || this; for (var i = 0, l = this.length; i < l; i++) func.call(scope, this[i], i, this); } Finally, are there any real uses for these methods in javascript (since we aren't updating a database) other than to manipulate numbers like this: alert([1,2,3,4].map(function(x){ return x + 1})); //this is the only example I ever see of map in javascript. Thanks for any reply.

    Read the article

  • Find most significant bit (left-most) that is set in a bit array

    - by Claudiu
    I have a bit array implementation where the 0th index is the MSB of the first byte in an array, the 8th index is the MSB of the second byte, etc... What's a fast way to find the first bit that is set in this bit array? All the related solutions I have looked up find the first least significant bit, but I need the first most significant one. So, given 0x00A1, I want 9.

    Read the article

  • PHP: How to overwrite values in one array with values from another

    - by Svish
    I have an array with default settings, and one array with user-specified settings. I want to merge these two arrays so that the default settings gets overwritten with the user-specified ones. I have tried to use array_merge, which does the overwriting like I want, but it also adds new settings if the user has specified settings that doesn't exist in the default ones. Is there a better function I can use for this than array_merge? Or is there a function I can use to filter the user-specified array so that it only contains keys that also exist in the default settings array? (PHP version 5.3.0)

    Read the article

  • c++ Array passing dilemma

    - by Thomas
    Hi, I am writing a function that takes a string, string pointer and an int. The function splits the string based on a set of rules and puts each token into an array. I need to return the array out of the function with the number of elements in the int variable etc. I am stuck as to how I return the array as I can not use auto other wise it is destroyed and I am reluctant to use new as I feel this is patchy. I have other ideas on how to go about this but would like to see how other people go about this first. I could also be wrong and it could be possible to pass an auto out of an array. I can also not use vectors so there goes a copy constructor.

    Read the article

  • Clean solution to this ruby iterator trickiness?

    - by mstksg
    k = [1,2,3,4,5] for n in k puts n if n == 2 k.delete(n) end end puts k.join(",") # Result: # 1 # 2 # 4 # 5 # [1,3,4,5] # Desired: # 1 # 2 # 3 # 4 # 5 # [1,3,4,5] This same effect happens with the other array iterator, k.each: k = [1,2,3,4,5] k.each do |n| puts n if n == 2 k.delete(n) end end puts k.join(",") has the same output. The reason this is happening is pretty clear...Ruby doesn't actually iterate through the objects stored in the array, but rather just turns it into a pretty array index iterator, starting at index 0 and each time increasing the index until it's over. But when you delete an item, it still increments the index, so it doesn't evaluate the same index twice, which I want it to. This might not be what's happening, but it's the best I can think of. Is there a clean way to do this? Is there already a built-in iterator that can do this? Or will I have to dirty it up and do an array index iterator, and not increment when the item is deleted?

    Read the article

< Previous Page | 64 65 66 67 68 69 70 71 72 73 74 75  | Next Page >