w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Compare maps with char array as values - Java
containsValue = map1.equals(map2.values()); should be: containsValue = map1.values().equals(map2.values()); while(it.hasNext()) is useless in your code and you didn't use the iterator inside the loop. Regarding defining a list of char[], use: List<char[]> list;

Categories : Java

Access af:table values from JavaScript array (for google maps task)
This is the same question, as the one you asked before... Check my answer in the other Question I want af:table values get in javascript array

Categories : Javascript

Get NumPy Array Indices in Array B for Unique Values in Array A, for Values Present in Both Arrays, Aligned with Array A
For such things it is important to have lookups in B as fast as possible. Dictionary provides O(1) lookup time. So, first of all, let us construct this dictionary: >>> indices = dict((value,index) for index,value in enumerate(B)) >>> indices {8: 2, 16: 3, 2: 0, 4: 1, 32: 4} And then just go through A and find corresponding indices: >>> [indices[item] for item in A] [1, 1, 0, 2, 2, 2, 2, 2, 3, 4, 3, 3, 4]

Categories : Python

Jackson parsing JSON containing an array of objects and array of maps w/ dynamic keys
You could probably get around this by writing your own custom deserializer and register it with the object mapper that you are using. This should work as you will have complete control of how each object is deserialized into a User object. See this jackson documentation on how to roll your own deserializer. Would also like to say, if you have control over the json structure - I would change the key value (which I am guessing is an ID for the user) to be a part of the actual json object as opposed to being the key. This will help you avoid the issue all together. For example: "users":{ { "id":"1234", "firstname":"Joe", "lastname":"Smith" }, { "id":"9876", "firstname":"Bob", "lastname":"A

Categories : Java

Converting enums to array of values (Putting all JSON values in an array)
You could convert it to an array, or you can just iterate the properties of the object (which is how you would create the array anyway): for(var i in types){ var type = types[i]; //in the first iteration: i = "WHITE", type = 0 //in the second iteration: i = "BLACK", type = 1 } Just for completeness, you can create the array with that method as follows: var arr = []; for(var i in types){ var type = types[i]; arr.push(type); } //arr = [0, 1] to make this reusable you could create a helper function: function ObjectToValueArray(obj){ var arr = []; for(var i in obj){ var v = obj[i]; arr.push(v); } return arr; } Which can be called like so: model.validate("typesColumn", ObjectToValueArray(types));

Categories : Javascript

Storing values to array and Counting total array values
$arrayage21to30 and $arrayage31to40 should be out of foreach just try this code: <?php $arrayage21to30 = array(); $arrayage31to40 = array(); foreach($arrayagevalues as $value) { if($value['Age'] >= 21 && $value['Age'] <= 30) { array_push($arrayage21to30, $value['Age']); } if($value['Age'] >= 31 && $value['Age'] <= 40) { array_push($arrayage31to40, $value['Age']); } } echo count($arrayage21to30), " "; echo count($arrayage31to40), " "; if you want to calculate the sum, you can use arrray_sum: echo array_sum($arrayage21to30), " "; echo array_sum($arrayage31to40), " ";

Categories : PHP

How to add sqlite database values into an array?I was retrived but how can I put these values into array?
Did you #import the header that declares the incorrectly named getData: method? Note: If you are writing raw SQL, you are wasting your time. Use FMDB (or similar) if you need database portability beyond iOS/OS X. If you are targeting only iOS / OS X, then Core Data is an excellent solution that has a very tight integration with the system. Some other issues: This makes no sense: depositArray=[[NSMutableArray alloc]init]; depositArray=[dbModelClass getData:str]; The first line allocates an array. The second line immediately assigns a new value to the variable pointing to that original array, both losing the reference to it and leaking memory. Also, methods should not be prefixed with get. That is reserved for very specific use cases.

Categories : Objective C

Find duplicate values in an array which creates a new array with key as duplicate keys and values as the dupes
This should do what you want. Loop over the array, and see if the value was already in there. If so, add it to the result. $arr_duplicates = array(); foreach($array as $k=>$v){ // array_search returns the 1st location of the element $first_index = array_search($v, $array); // if our current index is past the "original" index, then it's a dupe if($k != $first_index){ $arr_duplicates[$k] = $first_index; } } DEMO: http://ideone.com/Kj0dUV

Categories : PHP

Automapper maps source to destination but dest values are always null
expression.ForAllMembers(opt => opt.Ignore()); You're telling AutoMapper to ignore all properties, so nothing gets mapped. If you just want to ignore non-matching properties, see this answer for one way, otherwise you're going to have to explicitly map each property between the objects.

Categories : Entity Framework

Google Interactive Maps adding markers from database values
Yes you are able to create an interactive map where you can intercept the users click and stoe the location in the database. You can do something like: google.maps.event.addListener(map, 'click', function(event){ // Catch click location from event }); To get the location where is clicked. Not sure how Google does it. But would also suggest loading the markers from your database before you load the map. How many markers do you have stored in your database that it is slowing down the process? You could create a JSON / XML file and load the first x number of markers and load your map. After your map has loaded load the remaining markers (bit by bit).

Categories : Django

How to convert x/y coordinates from a 2D pixel map into LatLng Values of Google Maps
We were able to use the example I posted in my comment to create a projection that is mostly able to translate our x/y image coordinates to Google Map API v3. The example shows how to translate to a Image that measures 50x50 pixel and we just had to translate this. Because our map has no square shape we hat to add an offset to the y values and correct the x values by a correction factor. It seems that Google Map API can only handle LatLng values up to some kind of maximum so we hat to choose a smaller size for our projection and wrote a function to translate from original size to this new fictive size which produced LatLng values the API can handle.

Categories : Google Maps

Iterate through array changing all values in an array that match a from/to associated array
What about using array preg_grep ( string $pattern , array $input [, int $flags = 0 ] )[1] with some kind less or more sophisticated regular expression? You might need simple array of corrected (like Linux Ubuntu) values for that. EDIT: Code example for crystal clearance: $regex = '/^[a-Z ]*' . $user_input . '[a-Z ]*$/'; $correct_values = {"Linux Ubuntu", "Linux Debian", "Windows XP", ...}; //const $corrected_value = preg_grep($regex, $correct_values); [1] http://php.net/manual/en/function.preg-grep.php

Categories : PHP

Filter google maps array with jquery
Store the markers in a global accessible array, the you be able to iterate over the markers in the slide-callback and set their visibility by comparing the slider-values against the value of the marker-attributes. Example for the volumen-slider(assuming a global accessible array named markers which contains all markers): $.each(markers,function(i,o){ o.setVisible(ui.values[0]<=o.volumen && ui.values[1]>=o.volumen); });

Categories : PHP

Google Maps JavaScript API V3, plot array of Lat/Lon Points
After your last location called Liberty you have a ";" - remove this. So it should be: <script type="text/javascript"> function initialize() { var map; var mapOptions = { zoom: 9, center: new google.maps.LatLng(39.03454, -94.587315), mapTypeId: google.maps.MapTypeId.ROADMAP, }; map = new google.maps.Map(document.getElementById('body-space-inside'), mapOptions); var business_locations = [ ['South Plaza', '5105 Main St Kansas City, MO 64112', '39.03454', '-94.587315'], ['City Market', '427 Main Street Kansas City, MO 64105', 39.108518, -94.582635], ['Barry Road East', '221 Northeast Barry Road Kansas City, MO 64155', 39.246116, -94.57759], ['Barry Road West', '7007 NW Barry Road Kansas Cit

Categories : Javascript

Center and open InfoWindow with array in google maps
Make an array of google.maps.Markers (in the global scope), trigger a 'click' event on the appropriate marker // Marker Creation for (i = 0; i < markers.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(markers[i][2], markers[i][3]), map: map, flat: true, icon: markers[i][4] }); gmarkers.push(marker); // Find Bounds bounds.extend(marker.getPosition()); // Marker Center google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { // Center on marker map.setCenter(marker.getPosition()); infowindow.setContent(markers[i][1]); infowindow.open(map, marker); } })(marker, i)); } Then to click on the

Categories : Javascript

How to display infowindow and polylines using array of addresses in google maps?
google.maps.event.addListener(mark[i], 'click', function() { info[i].open(map,mark[i]); }); i is available inside the for loop. The loop prints the markers. When someone actually clicks the mark[i], the event is happening outside the loop, so i has no value and info[i] is no use. You can do this: specify title of a marker. mark[i]=new google.maps.Marker({ position: res[0].geometry.location, map: map, title: i }); Catch the title in the click event and display appropriate info. google.maps.event.addListener(mark[i], 'click', function( e ) { info[ e.title ].open(map, e); }); I haven't tested the last bit of code, you need to experiment with the event target.

Categories : Javascript

How to organize values in a numpy array into bins that contain a certain range of values?
Numpy has some pretty powerful bin counting functions. >>> binplace = np.digitize(avgs, bins) #Returns which bin an average belongs >>> binplace array([1, 6, 2, 3, 5, 4, 1, 4, 6, 6, 2, 3, 5, 6, 3, 1, 2, 3, 5, 7, 5, 3, 4]) >>> np.where(binplace == 1) (array([ 0, 6, 15]),) >>> np.where(binplace == 2) (array([ 2, 10, 16]),) >>> avgs[np.where(binplace == 1)] array([ 11.02, 11.3 , 11.01])

Categories : Python

PHP do calculations with values from two arrays based on array element values
let's say that the first array is $DAs and the second is $CAs <?php foreach($DAs as $i=>$da){ foreach($CAs as $j=>$ca){ if($da['DebitAccount'] == $ca['CreditAccount']){ //output echo 'Account number is '.$da['DebitAccount'].', Value is '.$da['SUM(j.Amount)']-$ca['SUM(j.Amount)'].' ('.$da['SUM(j.Amount)'].' - '.$ca['SUM(j.Amount)'].')'; //deduct the credit $DAs[$i]['SUM(j.Amount)'] -= $ca['SUM(j.Amount)']; //we need to use $DAs[$i] to be able to modify its value, because foreach can only give a copy of it. } } } ?>

Categories : PHP

Making null values from array into averages of existing values
determine all sequences of null (store start and end index of each sequence) determine the border elements for each sequence and caclculate average (be sure to handle the extra cases start and end of array correctly) replace the null by the calculated value

Categories : Java

Create markers from JSON array php mySQL Google Maps v2 android
I've Got the right code here its working perfect. it has been updated to go to the current location as well because I've been messing with it since the fix. import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GooglePlayServicesUtil; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.Marker; import com.google.android.gms.maps.model.MarkerOptions; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.Dialog; import android.location.Criteria;

Categories : Android

Define and use array of text values corresponding to numeric values
You might find this helpful: Ruby on Rails: Where to define global constants?. In Rails, since all models are autoloaded by default, you might find it convenient to define your constants in the models, as follows class User < ActiveRecord::Base ACCOUNTING = 0 ENGINEERING = 1 EDUCATION = 2 end or even class User < ActiveRecord::Base FIELDS = { accounting: 0, engineering: 1, education: 2 } end These can be used anywhere with User::ACCOUNTING or User::FIELDS[:accounting]. To use the second version inside a form, you can use select('user', 'study_field', User::FIELDS) Refer to select for more details.

Categories : Ruby On Rails

Filter out certain array keys (and their values), while keeping other array keys and values
array_diff_key($arr, array_flip(array('foo', 'bar', ...))) http://php.net/array_diff_key The flip is just for convenience, you could also define the array of keys to remove using array('foo' => null, ...).

Categories : PHP

Google Maps Engine - Importing Google Maps "My Maps" Data
Actually it seems like the google maps engine does indeed give you option of importing the maps you saved in your 'My Maps' as layers on to your map. Have a look at the screencap below: It has the option of uploading your csv or xlsx files, but there's also the option right under to add the maps you saved in "My Maps". I assume you'll need to be logged into your Google account with the saved maps to access this though.

Categories : Google Maps

Adding multiple markers to Google Maps API v2 from List array with the helping of AsyncTask
First: You shouldn't used nested AsyncTasks. That's not supported. You should however try to combine your image downloads for your users. Here's what you need to do: Create an asyntask that loops through your users in the doInBackground method. In the doInBackground for each user, download the bitmap, Use the publishProgress method when you've retrieved the bitmap. Calling publishProgress will trigger the onProgressUpdate method on the UI thread, where you can add your marker to the map. See the DownloadFilesTask example on the Android developers site.

Categories : Android

I want to compare values from one array with values of another array
Loop through the first array and compare each value to each value of the second array: $i = 0 foreach($words as $array1){ foreach($h1words as $array2){ if($array1 === $array2){ //equal }else{ //not equal } } $i++ } This will loop through each value in $words and compare it to each value in $h1words.

Categories : PHP

CakePHP: creating an array field that holds the count of specific values from another array
Replace those with these three: 'SUM(CASE PanelPref.panel_rating_id WHEN 3 THEN 1 ELSE 0 END) AS rated_three', 'SUM(CASE PanelPref.panel_rating_id WHEN 2 THEN 1 ELSE 0 END) AS rated_two', 'SUM(CASE PanelPref.panel_rating_id WHEN 1 THEN 1 ELSE 0 END) AS rated_one' Those items are part of the "fields" array, which correspond to the SELECT area of a generic T-SQL code block. What it looks like you want is a count of ratings for the item, and so this sum of case is the sort of hacky workaround for this.

Categories : Arrays

Ajax JSON multi array - determing array index contains specified values
You can accomplish this with the jQuery each function. function(returnedData) { $.each(returnedData, function(i,o) { if (o.image_report_type == "nuclear") { //Do Something } }); } Here is a jsFiddle Demonstrating this technique

Categories : Json

When I add a Three-digit number to my array and show it the array thinks i entered three values
you are not accessing the array the correct way. var arr = new Array(); // or var arr = []; function add() { var nevalue=document.getElementById("adad").value; arr.push(parseFloat(nevalue)); document.getElementById("adad").value=""; document.getElementById("show").innerHTML=""; } function display() { for(var i=0; i<arr.length; i++) { document.getElementById("show").innerHTML+=parseFloat(arr[i])+"<br>"; } alert(arr.length); }

Categories : Javascript

Array of Fibonacci values; Value of high index turns array value into negative
Overflow. Once the value exceeds the maximum 'capacity' of the 32bit int, the result will wrap around and start from the minimum value (a negative). http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html long and BigInteger are able to store higher values than int.

Categories : Java

Deal array values to a single field of a structure array (in Matlab)
deal does what it is expected to do. It distributes the input arguments among the outputs, and if it has only one argument (the vector 1:2) it replicates it as many times as the number of output arguments. You were probably looking for: [b(1:2).a] = deal(1, 2); %// or simply [b.a] = deal(1, 2) In the general case, you'll probably have to create a cell array from your values (e.g using num2cell) and use a comma-separated list, for instance: C = num2cell(v); %// v stores the values [b.a] = deal(C{:});

Categories : Arrays

How to most efficiently generate an array based on collapsed values in an array of objects?
Edit: Sorry, misread your question. This doesn't really do what you want -- It doesn't take the names into account. But it is still not fully clear to me what the problem exactly is. The trick with this kind of problem usually is to keep a map (or nested maps) of the information you have collected so far, and to update it as needed. The map key usually should be the information you need to merge, so the lookup is efficient. I haven't tested the code, it should just collapse the objects into rows. Depending on what your problem really is, it may or may not be a reasonable starting point. The code puts labels into row 0 of the result, but it should be easy to add support for a predefined list as a starting point... function collapse (array) { var labels = []; var result = [labels

Categories : Javascript

MongoDB - select document where all values in field array are present in a given array
Basically there are some ways to match array. There is no exact solution for your need. Considering you have documents like : { "_id" : ObjectId("51b05a712961f4704684d901"), "x" : [ 6, 7, 8, 9 ] } { "_id" : ObjectId("51b05a712961f4704684d902"), "x" : [ 7, 8, 9, 10 ] } { "_id" : ObjectId("51b05a712961f4704684d903"), "x" : [ 8, 9, 10, 11 ] } You can use query1 like: db.collection.find({x:[3,4,5,6]}) The result is exact match only for arrays like x result1: { "_id" : ObjectId("51b05a712961f4704684d8fe"), "x" : [ 3, 4, 5, 6 ] } query1 will not match : { "_id" : ObjectId("51b05a712961f4704684d8fe"), "x" : [ 3, 4, 5] } { "_id" : ObjectId("51b05a712961f4704684d8fe"), "x" : [ 3, 4, 5, 6, 7] } You can use : query2 like: db.t.find({x:{$all:[3,4]}}) result2 can be: { "_id" : ObjectI

Categories : Database

How to create a multi-dimensional array and have a property attached to a class determine where values are in the array? C#
First, you can define your 2d map array like this: int[,] map = new int[5, 5]; See MSDN on Multidimensional Arrays for more. Yes I would suggest putting the map into a class although if you are just learning this stuff do whatever you can to cobble it together in the short term I guess! Second, I think your player could have an X, Y position. So keeping with your style above, maybe add this to your player class: public int x_pos { get; set; } public int y_pos { get; set; } You can then use a function to update his location and afterward say map[player.x_pos, player.y_pos] = 1, or whatever the code for "player" is. Third, consider that maybe a square on your map has lava. And a monster is standing there. Or a certain square is shallow water, and the player is standing

Categories : C#

Unsetting array values in a foreach loop not working properly when array length is large
$sentUser=array(); if(!empty($uids_eidsArr)){ foreach($uids_eidsArr as $k=>$v){ //echo $v; // echo $r->id;('-', $eArr= explode('-', $v); $headers= 'From: Ldamsin <admin@domain.org>' . " "; $headers.="MIME-Version: 1.0 "; $headers.="Content-Type: text/html; charset="iso-8859-1" "; $content = $res_dup[0]->newsletter_content; if(!in_array($eArr[0], $sentUser)){ @mail($eArr[1], $res_dup[0]->newsletter_subject, $content, $headers); // mail to client $this->db->set('user_id',$sent_by); $this->db->set('sent_to',$eArr[0]); $this->db->set('isSubscriber',$isSubscriber); $this->db->set('content_i

Categories : PHP

Values ​​of an array showing wrong values
You're prefixing the keys with 0, so they're being treated as octal numbers. e.g. $_LANG[027(octal)] is actually $_LANG[23(decimal) $_LANG[010(octal)] is actually $_LANG[8(decimal)] Either use strings: $_LANG['027'] or normal decimals: $_LANG[27]

Categories : PHP

I try to set some values to an array of integers but the values won't stick
You're incrementing cX and cY before printing. Try this: coordX[cX][cY] = cX; coordY[cX][cY] = cY; System.out.println("X=" + coordX[cX][cY]); System.out.println("Y=" + coordY[cX][cY]); cX = cX + 1;

Categories : Java

Finding Values in an array with duplicates values
There are a couple of ways to do what you want to do. The easiest is probably to use a dictionary like @Richard Morgan suggests in his comment to you. You can also loop through the array and create a new array with just the correct names. Sample Code: Private Sub UniqueArray(oldData as Variant) as Collection Set UniqueArray = New Collection Dim i as integer Dim j as integer Dim foundFlag as boolean For i = 1 to oldData.Count foundFlag = False FOr j = i + 1 to oldData.Count If oldData(i) = oldData(j) then foundFlag = True End If Next j If not foundFlag then UniqueArray.Add oldData(i) Next Again, I think using a dictionary is probably better, but this should work.

Categories : Arrays

Keep keys with their values after values have been sorted in array?
Don't sort the values alone, sort through a 2D array -- an array of arrays. so it will look something like Key1 | Val1 ----------- Key2 | Val2 ----------- Key3 | Val3 Then you sort based on the values, but you move both. When sorted, it might look like Key3 | Val3 ----------- Key1 | Val1 ----------- Key2 | Val2 And then when you're referring to the first value, you do array[0][1] and for the key to that value you would do array[0][0].

Categories : Javascript

How to aggregate all array values of multiple records in Postgres array?
select distinct unnest(a) from (values (array[1, 2]), (array[2, 3]) ) s(a); unnest -------- 3 1 2 Or aggregated in an array: select array_agg(a order by a) from ( select distinct unnest(a) as a from (values (array[1, 2]), (array[2, 3]) ) s(a) ) s; array_agg ----------- {1,2,3}

Categories : Arrays

Retrieving and saving values from array of textboxes to an array of integers
Try to use Structure and ListOf .. Structure DataBets Dim TextBox as TextBox Dim Value as Integer End Structure Dim lBet as List(Of DataBets) Dim stBet as DataBets = New DataBets When your ctxFirstHalf filled .. stBet.TextBox = ctxFirstHalf stBet.Value = val(ctxFirstHalf.Text) lBet.Add(stBet) To access it .. Msgbox lBet(0).Value '---->this will show your ctxFirstHalf int

Categories : Arrays



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.