Search Results

Search found 15255 results on 611 pages for 'sparse array'.

Page 41/611 | < Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >

  • C#: returns array from object.

    - by jitm
    Hello, There is the next task: I need to check if input parameter (object) is array, then return array of input elements. For example I have input array like this: int [] array = {1,2,3,4}; And method private object[] GetArray(object @from) { } So, I need to check in this method that input variable is array and after return this array. For checking I use if(@from.GetType().IsArray) And how to create array from object ??? Is it possible ? Thanks.

    Read the article

  • Problem in sort by date in multi array?

    - by AB
    I want to sort array A based on values in Array B actually in Array A I have topics like keyboard Laptop Desktop mouse and in Array B i have dates associated with each value in Array A how i can achieve this....I was thinking of using multi array but i m not sure if there is any default method of sorting multi array ...or if there is any other method to achieve this?

    Read the article

  • PHP Array Not Working in Function

    - by lemonpole
    Hello all. I'm currently experimenting with arrays in PHP, and I created a fake environment where a team's information will be displayed. $t1 = array ( "basicInfo" => array ( "The Sineps", "December 25, 2010", "lemonpole" ), "overallRecord" => array (0, 0, 0, 0), "overallSeasons" => array ( 1 => array (14, 0, 0), 2 => array (9, 5, 2), 3 => array (12, 4, 0), 4 => array (3, 11, 2) ), "games" => array ( "<img src=\"images/cs.gif\" alt=\"Counter-Strike\" />", "<img src=\"images/cs.gif\" alt=\"Counter-Strike\" />", "<img src=\"images/cs.gif\" alt=\"Counter-Strike\" />", "<img src=\"images/cs.gif\" alt=\"Counter-Strike\" />" ), "seasonHistory" => array ( "Season I", "Season II", "Season III", "Season IV" ), "divisions" => array ( "Open", "Main", "Main", "Invite" ) ); // Displays the seasons the team has been in along // with the record of each season. function seasonHistory() { // Make array variable local-scope. global $t1; // Count the number of seasons. $numrows = count($t1["seasonHistory"]); // Loop through all the variables until // it reaches the last entry made and display // each item seperately. for($v = 0; $v <= $numrows; $v++) { // Echo each season. echo "<tr><td>{$t1["games"][$v]}</td>"; echo "<td>{$t1["seasonHistory"][$v]}</td>"; echo "<td>{$t1["divisions"][$v]}</td></tr>"; } } I have tested several possible problems out and after narrowing them down I have come down to one conclusion and that is my function is not connecting to the array for some reason. I don't know what else to do because I thought making the array global would fix that problem. What works: I can echo $t1["games"][0] on the page I need it to display and it gives me the content. I tried echo $t1["games"][0] INSIDE the function and then calling the function and it doesn't display anything.

    Read the article

  • drupal_get_form is not passing along node array

    - by ElectronicBlacksmith
    I have not been able to get drupal_get_form to pass on the node data. Code snippets are below. The drupal_get_form documentation (api.drupal.org) states that it will pass on the extra parameters. I am basing the node data not being passed because (apparently) $node['language'] is not defined in hook_form which causes $form['qqq'] not to be created and thus the preview button shows up. My goal here is that the preview button show up using path "node/add/author" but doesn't show up for "milan/author/add". Any alternative methods for achieving this goal would be helpful but the question I want answered is in the preceding paragraph. Everything I've read indicates that it should work. This menu item $items['milan/author/add'] = array( 'title' = 'Add Author', 'page callback' = 'get_author_form', 'access arguments' = array('access content'), 'file' = 'author.pages.inc', ); calls this code function get_author_form() { //return node_form(NULL,NULL); //return drupal_get_form('author_form'); return author_ajax_form('author'); } function author_ajax_form($type) { global $user; module_load_include('inc', 'node', 'node.pages'); $types = node_get_types(); $type = isset($type) ? str_replace('-', '_', $type) : NULL; // If a node type has been specified, validate its existence. if (isset($types[$type]) && node_access('create', $type)) { // Initialize settings: $node = array('uid' = $user-uid, 'name' = (isset($user-name) ? $user-name : ''), 'type' = $type, 'language' = 'bbb','bbb' = 'TRUE'); $output = drupal_get_form($type .'_node_form', $node); } return $output; } And here is the hook_form and hook_form_alter code function author_form_author_node_form_alter(&$form, &$form_state) { $form['author']=NULL; $form['taxonomy']=NULL; $form['options']=NULL; $form['menu']=NULL; $form['comment_settings']=NULL; $form['files']=NULL; $form['revision_information']=NULL; $form['attachments']=NULL; if($form["qqq"]) { $form['buttons']['preview']=NULL; } } function author_form(&$node) { return make_author_form(&$node); } function make_author_form(&$node) { global $user; $type = node_get_types('type', $node); $node = author_make_title($node); drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t($node-title), 'node/' . $node-nid))); $form['authorset'] = array( '#type' = 'fieldset', '#title' = t('Author'), '#weight' = -50, '#collapsible' = FALSE, '#collapsed' = FALSE, ); $form['author_id'] = array( '#access' = user_access('create pd_recluse entries'), '#type' = 'hidden', '#default_value' = $node-author_id, '#weight' = -20 ); $form['authorset']['last_name'] = array( '#type' = 'textfield', '#title' = t('Last Name'), '#maxlength' = 60, '#default_value' = $node-last_name ); $form['authorset']['first_name'] = array( '#type' = 'textfield', '#title' = t('First Name'), '#maxlength' = 60, '#default_value' = $node-first_name ); $form['authorset']['middle_name'] = array( '#type' = 'textfield', '#title' = t('Middle Name'), '#maxlength' = 60, '#default_value' = $node-middle_name ); $form['authorset']['suffix_name'] = array( '#type' = 'textfield', '#title' = t('Suffix Name'), '#maxlength' = 14, '#default_value' = $node-suffix_name ); $form['authorset']['body_filter']['body'] = array( '#access' = user_access('create pd_recluse entries'), '#type' = 'textarea', '#title' = 'Describe Author', '#default_value' = $node-body, '#required' = FALSE, '#weight' = -19 ); $form['status'] = array( '#type' = 'hidden', '#default_value' = '1' ); $form['promote'] = array( '#type' = 'hidden', '#default_value' = '1' ); $form['name'] = array( '#type' = 'hidden', '#default_value' = $user-name ); $form['format'] = array( '#type' = 'hidden', '#default_value' = '1' ); // NOTE in node_example there is some addition code here not needed for this simple node-type $thepath='milan/author'; if($_REQUEST["theletter"]) { $thepath .= "/" . $_REQUEST["theletter"]; } if($node['language']) { $thepath='milan/authorajaxclose'; $form['qqq'] = array( '#type' = 'hidden', '#default_value' = '1' ); } $form['#redirect'] = $thepath; return $form; } That menu path coincides with this theme (PHPTemplate)

    Read the article

  • Sum multi dimensional array based on a key in php

    - by user1328178
    I have mutiple arrays say for now 2, first array has Cities(Mumbai, Pune. Bangalore, Hyderabad) And 2nd array has Mumbia nad Hyderabd. I want to sum up the values based on the Key. Array ( [Mumbai] = Array ( [ga:pageviews] = 1 [ga:visits] = 1 [ga:newVisits] = 1 [ga:pageviewsPerVisit] = 1 [ga:entranceBounceRate] = 1 [ga:avgTimeOnSite] = 1 [ga:timeOnSite] = 1 [ga:bounces] = 1 ) [Pune] => Array ( [ga:pageviews] => 2 [ga:visits] => 2 [ga:newVisits] => 2 [ga:pageviewsPerVisit] => 2 [ga:entranceBounceRate] => 2 [ga:avgTimeOnSite] => 2 [ga:timeOnSite] => 2 [ga:bounces] => 2 ) [Bangalore] => Array ( [ga:pageviews] => 3 [ga:visits] => 3 [ga:newVisits] => 3 [ga:pageviewsPerVisit] => 3 [ga:entranceBounceRate] => 3 [ga:avgTimeOnSite] => 3 [ga:timeOnSite] => 3 [ga:bounces] => 3 ) [Hyderabad] => Array ( [ga:pageviews] => 4 [ga:visits] => 4 [ga:newVisits] => 4 [ga:pageviewsPerVisit] => 4 [ga:entranceBounceRate] => 4 [ga:avgTimeOnSite] => 4 [ga:timeOnSite] => 4 [ga:bounces] => 4 ) ) 2nd Array: Array ( [Mumbai] = Array ( [ga:pageviews] = 5 [ga:visits] = 5 [ga:newVisits] = 5 [ga:pageviewsPerVisit] = 5 [ga:entranceBounceRate] = 5 [ga:avgTimeOnSite] = 5 [ga:timeOnSite] = 5 [ga:bounces] = 5 ) [Hyderabad] => Array ( [ga:pageviews] => 2 [ga:visits] => 2 [ga:newVisits] => 2 [ga:pageviewsPerVisit] => 2 [ga:entranceBounceRate] => 2 [ga:avgTimeOnSite] => 2 [ga:timeOnSite] => 2 [ga:bounces] => 2 ) ) I want the result as: Array ( [Mumbai] = Array ( [ga:pageviews] = 6 [ga:visits] = 6 [ga:newVisits] = 6 [ga:pageviewsPerVisit] = 6 [ga:entranceBounceRate] = 6 [ga:avgTimeOnSite] = 6 [ga:timeOnSite] = 6 [ga:bounces] = 6 ) [Pune] => Array ( [ga:pageviews] => 2 [ga:visits] => 2 [ga:newVisits] => 2 [ga:pageviewsPerVisit] => 2 [ga:entranceBounceRate] => 2 [ga:avgTimeOnSite] => 2 [ga:timeOnSite] => 2 [ga:bounces] => 2 ) [Bangalore] => Array ( [ga:pageviews] => 3 [ga:visits] => 3 [ga:newVisits] => 3 [ga:pageviewsPerVisit] => 3 [ga:entranceBounceRate] => 3 [ga:avgTimeOnSite] => 3 [ga:timeOnSite] => 3 [ga:bounces] => 3 ) [Hyderabad] => Array ( [ga:pageviews] => 6 [ga:visits] => 6 [ga:newVisits] => 6 [ga:pageviewsPerVisit] => 6 [ga:entranceBounceRate] => 6 [ga:avgTimeOnSite] => 6 [ga:timeOnSite] => 6 [ga:bounces] => 6 ) ) Thanks for your help.... Ruth.

    Read the article

  • Find the right value in recursive array

    - by fire
    I have an array with multiple sub-arrays like this: Array ( [0] => Array ( [Page_ID] => 1 [Page_Parent_ID] => 0 [Page_Title] => Overview [Page_URL] => overview [Page_Type] => content [Page_Order] => 1 ) [1] => Array ( [0] => Array ( [Page_ID] => 2 [Page_Parent_ID] => 1 [Page_Title] => Team [Page_URL] => overview/team [Page_Type] => content [Page_Order] => 1 ) ) [2] => Array ( [Page_ID] => 3 [Page_Parent_ID] => 0 [Page_Title] => Funds [Page_URL] => funds [Page_Type] => content [Page_Order] => 2 ) [3] => Array ( [0] => Array ( [Page_ID] => 4 [Page_Parent_ID] => 3 [Page_Title] => Strategy [Page_URL] => funds/strategy [Page_Type] => content [Page_Order] => 1 ) [1] => Array ( [0] => Array ( [Page_ID] => 7 [Page_Parent_ID] => 4 [Page_Title] => A Class Fund [Page_URL] => funds/strategy/a-class-fund [Page_Type] => content [Page_Order] => 1 ) [1] => Array ( [0] => Array ( [Page_ID] => 10 [Page_Parent_ID] => 7 [Page_Title] => Information [Page_URL] => funds/strategy/a-class-fund/information [Page_Type] => content [Page_Order] => 1 ) [1] => Array ( [Page_ID] => 11 [Page_Parent_ID] => 7 [Page_Title] => Fund Data [Page_URL] => funds/strategy/a-class-fund/fund-data [Page_Type] => content [Page_Order] => 2 ) ) [2] => Array ( [Page_ID] => 8 [Page_Parent_ID] => 4 [Page_Title] => B Class Fund [Page_URL] => funds/strategy/b-class-fund [Page_Type] => content [Page_Order] => 2 ) I need a function to find the right Page_URL so if you know the $url is "funds/strategy/a-class-fund" I need to pass that to a function that returns a single array result (which would be the Page_ID = 7 array in this example). Having a bit of a stupid day, any help would be appreciated!

    Read the article

  • How to transform gameObjects in array?

    - by user1764781
    I have an array of available gameObjects in the scene. An array of GO should be transformed according to received floats through UDP connection. I know it is simple, but can't figure it out how to accomplish the transformation an array of GO according to received unique floats for each GO, any help will be appreciated. Here is a transformation floats, it might be helpful I guess: x =ReadSingleBigEndian(data, signalOffset); signalOffset+=4; y= ReadSingleBigEndian(data, signalOffset); signalOffset+=4; z= ReadSingleBigEndian(data, signalOffset); signalOffset+=4; alpha= ReadSingleBigEndian(data, signalOffset); signalOffset+=4; theta= ReadSingleBigEndian(data,signalOffset); signalOffset+=4; phi= ReadSingleBigEndian(data,signalOffset); signalOffset+=4;

    Read the article

  • IsNullOrEmpty generic method for Array to avoid Re-Sharper warning

    - by Michael Freidgeim
    I’ve used the following extension method in many places. public static bool IsNullOrEmpty(this Object[] myArr) { return (myArr == null || myArr.Length == 0); }Recently I’ve noticed that Resharper shows warning covariant array conversion to object[] may cause an exception for the following codeObjectsOfMyClass.IsNullOrEmpty()I’ve resolved the issue by creating generic extension method public static bool IsNullOrEmpty<T>(this T[] myArr) { return (myArr == null || myArr.Length == 0); }Related linkshttp://connect.microsoft.com/VisualStudio/feedback/details/94089/add-isnullorempty-to-array-class    public static bool IsNullOrEmpty(this System.Collections.IEnumerable source)        {            if (source == null)                return true;            else            {                return !source.GetEnumerator().MoveNext();            }        }http://stackoverflow.com/questions/8560106/isnullorempty-equivalent-for-array-c-sharp

    Read the article

  • HLSL: An array of textures and sampler states

    - by nate142
    The shader must switch between multiple textures depending on the Alpha value of the original texture for each pixel. Now this would word fine if I didn't have to worry about SamplerStates. I have created my array of textures and can select a texture based on the Alpha value of the pixel. But how do I create an Array of SamplerStates and link it to my array of textures? I attempted to treat the SamplerState as a function by adding the (int i) but that didn't work. Also I can't use Texture.Sample since this is shader model 2.0. //shader model 2.0 (DX9) texture subTextures[255]; SamplerState MeshTextureSampler(int i) { Texture = (subTextures[i]); }; float4 SampleCompoundTexture(float2 texCoord, float4 diffuse) { float4 SelectedColor = SAMPLE_TEXTURE(Texture, texCoord); int i = SelectedColor.a; texture SelectedTx = subTextures[i]; return tex2D(MeshTextureSampler(i), texCoord) * diffuse; }

    Read the article

  • Working out of a vertex array for destrucible objects

    - by bobobobo
    I have diamond-shaped polygonal bullets. There are lots of them on the screen. I did not want to create a vertex array for each, so I packed them into a single vertex array and they're all drawn at once. | bullet1.xyz | bullet1.rgb | bullet2.xyz | bullet2.rgb This is great for performance.. there is struct Bullet { vector<Vector3f*> verts ; // pointers into the vertex buffer } ; This works fine, the bullets can move and do collision detection, all while having their data in one place. Except when a bullet "dies" Then you have to clear a slot, and pack all the bullets towards the beginning of the array. Is this a good approach to handling lots of low poly objects? How else would you do it?

    Read the article

  • Separating merged array of arithmetic and geometric series

    - by user1814037
    Given an array of positive integers in increasing order. Separate them in two series, an arithmetic sequence and geometric sequence. The given array is such that a solution do exist. The union of numbers of the two sequence must be the given array. Both series can have common elements i.e. series need not to be disjoint. The ratio of the geometric series can be fractional. Example: Given series : 2,4,6,8,10,12,25 AP: 2,4,6,8,10,12 GP: 4,10,25 I tried taking few examples but could not reach a general way. Even tried some graph implementation by introducing edges if they follow a particular sequence but could not reach solution.

    Read the article

  • Data structures for a 3D array

    - by Smallbro
    Currently I've been using a 3D array for my tiles in a 2D world but the 3D side comes in when moving down into caves and whatnot. Now this is not memory efficient and I switched over to a 2D array and can now have much larger maps. The only issue I'm having now is that it seems that my tiles cannot occupy the same space as a tile on the same z level. My current structure means that each block has its own z variable. This is what it used to look like: map.blockData[x][y][z] = new Block(); however now it works like this map.blockData[x][y] = new Block(z); I'm not sure why but if I decide to use the same space on say the floor below it wont allow me to. Does anyone have any ideas on how I can add a z-axis to my 2D array? I'm using java but I reckon the concept carries across different languages.

    Read the article

  • Actionscript - Dropping Multiple Objects Using an Array?

    - by Eratosthenes
    I'm trying to get these fireBalls to drop more often, im not sure if im using Math.random correctly also, for some reason I'm getting a null reference because I think the fireBalls array waits for one to leave the stage before dropping another one? this is the relevant code: var sun:Sun=new Sun var fireBalls:Array=new Array() var left:Boolean; function onEnterFrame(event:Event){ if (left) { sun.x = sun.x - 15; }else{ sun.x = sun.x + 15; } if (fireBalls.length>0&&fireBalls[0].y>stage.stageHeight){ // Fireballs exit stage removeChild(fireBalls[0]); fireBalls.shift(); } for (var j:int=0; j<fireBalls.length; j++){ fireBalls[j].y=fireBalls[j].y+15; if (fireBalls[j].y>stage.stageHeight-fireBall.width/2){ } } if (Math.random()<.2){ // Fireballs shooting from Sun var fireBall:FireBall=new FireBall; fireBall.x=sun.x; addChild(fireBall); fireBalls.push(fireBall); } }

    Read the article

  • Assigning an item to an existing array in a list within a dictionary [on hold]

    - by Rouke
    I have a Dictionary declared like: public var PoolDict : Dictionary.<String, List.<GameObject[]> >; I made a function to add items to the list and array function Add(key:String, obj:GameObject) { if(!PoolDict.ContainsKey(key)) { PoolDict[key] = new List.<GameObject[]>(); } //PlaceHolder - Not what will be in final version PoolDict[key].Add(null); //Attempts - Errors- How to add to existing array? PoolDict[key].Add(obj); PoolDict[key][0].Add(obj); } I'd like to replace the line after //PlaceHolder with code that will assign a gameObject to an existing array in a list that's associated with a key. How could this be done?

    Read the article

  • Simplest way to match array of strings to search in perl?

    - by Ben Dauphinee
    What I want to do is check an array of strings against my search string and get the corresponding key so I can store it. Is there a magical way of doing this with Perl, or am I doomed to using a loop? If so, what is the most efficient way to do this? I'm relatively new to Perl (I've only written 2 other scripts), so I don't know a lot of the magic yet, just that Perl is magic =D Reference Array: (1 = 'Canon', 2 = 'HP', 3 = 'Sony') Search String: Sony's Cyber-shot DSC-S600 End Result: 3

    Read the article

  • Where can I find information on the Get, Set and Address methods for multidimensional System.Array i

    - by Rob Smallshire
    System.Array serves as the base class for all arrays in the Common Language Runtime (CLR). According to this article, For each concrete array type, [the] runtime adds three special methods: Get/Set/Address. and indeed if I disassemble this C# code, int[,] x = new int[1024,1024]; x[0,0] = 1; x[1,1] = 2; x[2,2] = 3; Console.WriteLine(x[0,0]); Console.WriteLine(x[1,1]); Console.WriteLine(x[2,2]); into CIL I get, IL_0000: ldc.i4 0x400 IL_0005: ldc.i4 0x400 IL_000a: newobj instance void int32[0...,0...]::.ctor(int32, int32) IL_000f: stloc.0 IL_0010: ldloc.0 IL_0011: ldc.i4.0 IL_0012: ldc.i4.0 IL_0013: ldc.i4.1 IL_0014: call instance void int32[0...,0...]::Set(int32, int32, int32) IL_0019: ldloc.0 IL_001a: ldc.i4.1 IL_001b: ldc.i4.1 IL_001c: ldc.i4.2 IL_001d: call instance void int32[0...,0...]::Set(int32, int32, int32) IL_0022: ldloc.0 IL_0023: ldc.i4.2 IL_0024: ldc.i4.2 IL_0025: ldc.i4.3 IL_0026: call instance void int32[0...,0...]::Set(int32, int32, int32) IL_002b: ldloc.0 IL_002c: ldc.i4.0 IL_002d: ldc.i4.0 IL_002e: call instance int32 int32[0...,0...]::Get(int32, int32) IL_0033: call void [mscorlib]System.Console::WriteLine(int32) IL_0038: ldloc.0 IL_0039: ldc.i4.1 IL_003a: ldc.i4.1 IL_003b: call instance int32 int32[0...,0...]::Get(int32, int32) IL_0040: call void [mscorlib]System.Console::WriteLine(int32) IL_0045: ldloc.0 IL_0046: ldc.i4.2 IL_0047: ldc.i4.2 IL_0048: call instance int32 int32[0...,0...]::Get(int32, int32) IL_004d: call void [mscorlib]System.Console::WriteLine(int32) where the calls to the aforementioned Get and Set methods can be clearly seen. It seems the arity of these methods is related to the dimensionality of the array, which is presumably why they are created by the runtime and are not pre-declared. I couldn't locate any information about these methods on MSDN and their simple names makes them resistant to Googling. I'm writing a compiler for a language which supports multidimensional arrays, so I'd like to find some official documentation about these methods, under what conditions I can expect them to exist and what I can expect their signatures to be. In particular, I'd like to know whether its possible to get a MethodInfo object for Get or Set for use with Reflection.Emit without having to create an instance of the array with correct type and dimensionality on which to reflect, as is done in the linked example.

    Read the article

  • How to pass an associative array as argument to a function in Bash?

    - by niksfirefly
    How do you pass an associative array as an argument to a function? Is this possible in Bash? The code below is not working as expected: function iterateArray { local ADATA="${@}" # associative array for key in "${!ADATA[@]}" do echo "key - ${key}" echo "value: ${ADATA[$key]}" done } Passing associative arrays to a function like normal arrays does not work: iterateArray "$A_DATA" or iterateArray "$A_DATA[@]"

    Read the article

  • How can I multiply each item in an array easily with PHP?

    - by Henry
    I have an array called $times. It is a list of small numbers (15,14,11,9,3,2). These will be user submitted and are supposed to be minutes. As PHP time works on seconds, I would like to multiply each element of my array by 60. I've been playing around with array_walk and array_map but I can't get those working :S Thanks.

    Read the article

  • Delphi 6: How to search a dynamic array for sub-string quickly?

    - by Robert Oschler
    How can I search a dynamic array of char in Delphi 6 for a sub-string and get back an index to a match, not a pointer? I've seen functions in Delphi 6 that do this for strings but not for dynamic char arrays. There is a function called SearchBuf but that function returns a PChar pointer to the match location when what I need is the array index of the match. Thanks.

    Read the article

< Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >