w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Take parameter, determine if its an object or list<>; if list<> then loop and treat each item as object
You could do something like this: public static Dictionary<string, object> Pick(object obj, Array Picklist) { Dictionary<string, object> dic = new Dictionary<string, object> (); IEnumerable items = obj as IEnumerable ?? new[] { obj }; foreach(string key in Picklist) { foreach(object item in items) { dic.Add(key, item.GetType().GetProperty(key).GetValue(item, null)); } } return dic; } Note however, this will fail if you actually try to provide two or more items, since it will attempt to add the same key to the dictionary twice. It will also fail if you try to pass an object which doesn't have one of the specified properties. It's unclear exactly what you want this method to do in these cases, but this code s

Categories : C#

Unable to pass an address of array of type char *[2] to function taking char ***
char *array[2] = {"string", "value"}; is an array with 2 elements of char *. Using array as an address results to a pointer to the first element, i. e. of type char **. Using &array results to a pointer to the same place, but of type char *(*)[2] (not sure if the spelling is right). This is not the same as a char *** - the representation in memory is completely different. To be more verbose, +++++++++++++++++++++++ + array[0] + array[1] + +++++++++++++++++++++++ this is the array. char ** p1 = array; // is a pointer to the first element, which in turn is a pointer. char *(*p2)[2] = &array; // is a pointer to the whole array. Same address, but different type, i. e. sizeof(*p1) != sizeof(*p2) and other differences. char ***p3 = &p1; // Now, p1 is a different pointer va

Categories : C

Parameter Values - pass a value not in the list
Without knowing more on what is 'acceptable' for the parameter value this question is nearly impossible to answer. In SSRS the first level of acceptance of a parameter is the type which is the common 'text' (string of equivalent in code), integer or DateTime. If you are passing a parameter to the report NOT in the format it wants it will bomb. That should be as designed. If you limit your scope of 'available' values of a parameter by attaching the parameter to a dataset stating: "Get values from Dataset". If you give the parameter a value NOT in this collection it will also bomb. This would be the argument equivalent of selecting 6 when your choices are 1-5. And getting the standard .NET equivalent of 'argument is outside the bounds of the array.' That is also by design. For debug

Categories : Sql Server

How to pass a list of string as a parameter after grouping them in SSRS?
The issue with your parameter may be it's AVAILABLE or Default values being not set correctly if you are getting the first indexed item in an array. EG: If I set up a parameter to go with me and it is super simple like: declare @Temp table ( id int, Name varchar(8) ) insert into @Temp values (1, 'A'), (1, 'B'), (2, 'C'); Select Id , Name from @Temp If I have a grouping that is having subreports and other things it may be setting only one value EVEN if it is allowing multiple. If you want your parameter to be agnostic of scope(meaning it does not care where in the report it is to determine values). You can set it's available values and default values to be 'get values from a query' and set up a dataset met to only ever return the same static values it will only get those values

Categories : Arrays

How to pass a list of values to one Oracle Report parameter?
There are two ways you could solve this in Oracle Reports. I would usually prefer option #1. Option 1: use INSTR to compare the values and (INSTR(','||:p_kod_urusan||',', ','||mhn.kod_urusan||',') > 0 or :p_kod_urusan is null) Option 2: use a lexical parameter and (mhn.kod_urusan IN (&p_kod_urusan) or :p_kod_urusan is null) With option 2, you need to watch out for the SQL injection vulnerability, as well as a potential performance issue caused by hard parsing and multiple query plans. I'm not sure why you're replacing the string '[^,]+' with a comma. I've assumed your parameter is already a comma-delimited list of values.

Categories : SQL

C# Metro Unable to access object properties from List
Your properties in your Tile class are set to private. To be able to access the properties from outside the class you will need to declare them as public: public class Tile { public int ID { get; set; } public string Name { get; set; } public double Frequency { get; set; } public double Divider { get; set; } public int Value { get; set; } public int Turns { get; set; } public int StartLevel { get; set; } } You can keep your same constructor, although that will end up being a mess to maintain as you add/subtract properties. Another way you can instantiate your list of Tile objects is like so: List<Tile> tList = new List<Tile> { new Tile { ID = 0, Name = "Example1" } }; ...for as many public properties as you need to set

Categories : C#

suppose output python list as javascript list in html, but the char "'" is printed
From the docs on Filtering it would appear that $:categoriesPython might do the trick By default, Templetor uses web.websafe filter to do HTML-encoding. render.hello("1 < 2") "Hello 1 < 2" To turnoff filter use : after $. For example: The following will not be html escaped. $:form.render()

Categories : Javascript

Overloading two functions with object and list parameter
A List<string> is not a List<object>; however, List<string> is an object - so it makes perfect sense to choose that overload. Try instead: public static void Log<T>(IList<T> objects) { foreach (var obj in objects) { Console.WriteLine(obj); } } or even: public static void Log<T>(IEnumerable<T> objects) { foreach (var obj in objects) { Console.WriteLine(obj); } } You might also like: public static void Log(params object[] objects) { foreach (var obj in objects) { Console.WriteLine(obj); } } which can be used as: Log("Test","Test2");

Categories : C#

How to make List of Unique data from multiple List containing duplicate values
To not use loops, use recursive calls of functions. You can use a hash array, or an object and set its properties with your values, use "true" value for simplicity. When you override, its not a problem, it will just get re-set as true. Afterwards, you loop through the hash array or object and all its properties are unique (and all have the value true). If you have a particular language of programming, mention it as a comment, I might give you the function to do it.

Categories : Java

generating unique ordered non duplicate combinations in java for a list of list
1: Is this homework? 2: How many lists do you anticipate using as a maximum? Basically... there's not going to be some sort of magical way to do this... you're going to have to check to see if the string you're building already contains the letter you're considering adding, and that's what you want to optimize -- checking if your String already contains a letter. If you're doing this for homework, I think you can use a String.contains( 'a' ) || String.contains( 'A' ) to see if the String already contains a certain letter ('a' in this case). I'll leave the rest of it to you. Note that this is an O(n^2) operation. If you're doing this for a more... industrial... application, then I see another option. If you're going to have a large number of String lists, then you'll probably want to

Categories : Java

Find duplicate items within a list of list of tuples Python
Update: After rereading your question, it appears that you're trying to create equivalence classes, rather than collecting values for keys. If [[(1, 2), (3, 4), (2, 3)]] should become [(1, 2, 3, 4)] , then you're going to need to interpret your input as a graph and apply a connected components algorithm. You could turn your data structure into an adjacency list representation and traverse it with a breadth-first or depth-first search, or iterate over your list and build disjoint sets. In either case, your code is going to suddenly involve a lot of graph-related complexity, and it'll be hard to provide any output ordering guarantees based on the order of the input. Here's an algorithm based on a breadth-first search: import collections # build an adjacency list representation of you

Categories : Python

Delete duplicate tuples from list of list in Python
Use sets: One-liner: >>> seen = set() >>> [ [y for y in x if y not in seen and not seen.add(y)] for x in a] [[('bring', 'VBG'), ('puffy', 'NN'), ('eyes', 'NNS'), ('back', 'RB')], [('droopy', 'NN')]] The above code is equivalent to: >>> a = [[('bring', 'VBG'), ('puffy', 'NN'), ('eyes', 'NNS'), ('back', 'RB')], [('droopy','NN'), ('eyes', 'NNS')]] >>> seen = set() >>> out_lis = [] for x in a: temp = [] for y in x: if y not in seen: seen.add(y) temp.append(y) out_lis.append(temp) ... >>> out_lis [[('bring', 'VBG'), ('puffy', 'NN'), ('eyes', 'NNS'), ('back', 'RB')], [('droopy', 'NN')]]

Categories : Python

what should I use to pass parameters? List / Array / Object in C#
One option would be to use a Dictionary<string,string>. This would allow you to have keyed values passed through your functions. private void myFoo(Dictionary<string,string> data) {} Build it as: var dict = new Dictionary<string,string>(); dict.Add("data1", "een"); dict.Add("data2", "twee"); Fetch via: var value = dict["data1"]; // You can also use TryGetValue, etc.

Categories : C#

How can I "redirect" to another URL and pass a list object using Flask
If the list isnt very long, you could pass it on the query string, say comma separated: comma_separated = ','.join(some_list) return redirect(url_for('show_list', some_list=comma_separated)) # returns something like 'http://localhost/show_list?some_list=a,b,c,d' Then in the template in your view, you can iterate over them like so: {% for item in request.args.get('some_list', '').split(',') %} {{ item }} {% endfor %} For longer lists, or if you didnt want to expose it on the query string, you could also store the list in the session: session['my_list'] = some_list return redirect(url_for('show_list')) Then in the template: {% for item in session.pop('my_list', []) %} {{ item }} {% endfor %}

Categories : Python

Pass object (List) as part of Exception
Exceptions contains Data property (which is a dictionary). It can be used to pass additional information: try { // throw new Exception } catch(Exception e) { // whatever e.Data["SomeData"] = new List<string>(); }

Categories : C#

C# calling C DLL, pass char * as parameter not correct
When you only receive one character like that, it normally means that you are passing a Unicode (UTF16) string to a C/C++ function that is expecting an 8 bit format such as ASCII, UTF8 or ANSI. The 16-bit Unicode format ends up with one byte of its two bytes being set to zero for characters in the ASCII/ANSI range, and because a C/C++ program treats a zero byte as an end-of-string character, it truncates the string. It's easy to try using ANSI to see if it helps; change CharSet = CharSet.Auto to CharSet = CharSet.Ansi

Categories : C#

What kind of List is List list = Database.getAllData();?
You don't have to know; that's the point. The interface is what matters to you, not the implementation. You can't know without looking at the source of that method. But even if you do, it's immaterial to your client. All you call are List methods.

Categories : Java

Java Method with the parameter “List>”
The way I see it, you don't have Class type in the list. Your list is specified to contain classes not instances of the OrderChange class private boolean validateOrderChange(List<? extends OrderChange>> input, boolean verifyOnly) { for (OrderChange orderChange : input) { if (StringUtil.isNullOrEmpty(orderChange.getRph())) { return false; } } }

Categories : Java

How compare a char / single char string - with some list of alphabets set
If the starting letter is always an English character (or anything representable by a reasonably small integer that fits into an unsigned char), then here's a solution (the fastest possible one I can think of - uses no jumps except for the first check for initialization and only plain old integers are used instead of the somewhat heavier-weight comparison of NSString instances): - (UIColor *)colorFromName:(NSString *)name { static UIColor *strs[1 << CHAR_BIT] = { nil }; static BOOL initted = NO; if (!initted) { strs['a'] = [UIColor greyColor]; strs['b'] = [UIColor whiteColor]; // ... strs['z'] = [UIColor blueColor]; initted = YES; } unsigned char first = tolower([name characterAtIndex:0]); return strs[first]; }

Categories : IOS

Pass java object to new android instance on list view click
Let your BeerData class implements the Parcelable interface. Then just do : lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Intent i = new Intent(MainActivity.this, SecondActivity.class); i.putExtra("myBeerObject", lv.getItemAtPosition(arg2)); startActivity(i); } }); From the second class : Bundle b = getIntent().getExtras(); BeerData beer = b.getParcelable("myBeerObject"); Here's an example of how to implement the interface correctly.

Categories : Java

Get a list option value from an auto populated JSON list and pass to JS function
Seems I needed to use :selected console.log($('#meh :selected').text()); Example: http://jsfiddle.net/764W9/8/

Categories : Javascript

How do I pass a list of values to xargs as a single argument list?
Just ls|xargs command will do. Of course, if the list doesn't exceed the command line length limit, command `ls` also suffices.

Categories : Bash

adding char[] to char** (string to a list of strings)
You can't copy strings using =, you have to use a function - such as the standard strcpy function. So: configurations[*multiplicity][start] = "a,"; should be: strcpy(configurations[*multiplicity][start], "a,"); And the same type of patterns elsewhere.

Categories : C

Unable to cast object of type WhereSelectListIterator 2 System.Collections.Generic.List
As the error is trying to tell you, LINQ methods return special iterator types the implement IEnumerable<T>; they do not return List<T>. This enables deferred execution. Since the object isn't actually a List<T>, you can't cast it to a type that it isn't. If you need a List<T>, you can either call ToList(), or skip LINQ entirely and use List<T>.ConvertAll(), which is like Select(), but does return List<T>.

Categories : Linq

How can I use a template parameter of class to pass as argument of template for my linked list?
EventType is a formal parameter of your template so there's no meaning when you instantiate your template like this (as long as there's no actual class EventType) SFALinkedList<SFACallback<EventType> >::iterator iter; You should pass an actual parameter to instantiate the template e.g., SFALinkedList<SFACallback<SFAEvent> >::iterator iter; Also, I believe if you have an actual class EventType compiler wouldn't allow to use it as a formal parameter.

Categories : C++

How can I pass a list of values as a parameter to a Visual Studio web performance test or load test plugin?
Sadly, plugin property values are indeed limited to bool, string and numeric types. This restriction is hard-coded within the Microsoft.VisualStudio.QualityTools.WebTestFramework assembly. There is no way to support other types (well, with one exception) or get any enhanced editor features such as in your Test Mix collection example. If you want a property to accept a list of strings, for example, the only option is to have a property of type string, and parse the string into a list by splitting on a delimiter. Disappointing, but true.

Categories : C#

Avoiding duplicate Null Checks (Pass a User Control as a Parameter)
I suggest you just return a DateTime? and let the caller do the defaulting: public static DateTime? SafeGetDateTime(this OracleDataReader reader, int colIndex) { return reader.IsDBNull(colIndex) ? null : (DateTime?) reader.GetDateTime(colIndex); } Now you can use: DateTime fromReaderOrNow = reader.SafeGetDateTime(1) ?? DateTime.Now; And if you need the control part: DateTime? fromReader = reader.SafeGetDateTime(1); if (fromReader == null) { control.Checked = false; } DateTime fromReaderOrNow = fromReader ?? DateTime.Now; If you really need to do that in multiple places, you can wrap up a method to do - and you won't be repeating the SafeGetDateTime code. (I would encourage you to separate our your database code further from your UI co

Categories : C#

Python Object list keep changing when I change an other object list
Lose the class attributes. You are not using them anyway. In fact it's causing your bug because all the instances appear to share the same CHAN list class ircServer: def __init__(self, HOST, PORT): self.HOST = HOST self.PORT = PORT self.CHAN = [] def addChan(self, CHANEL): self.CHAN.append(CHANEL) Also consider reading PEP8 and following at least most of the guidelines there

Categories : Python

Is there a way to print out an object from a script as it would appear in the REPL? (e.g. myList: List[String] = List(Hello there, World!)
The Scala equivalent of this would be the getClass method (from Java) on java.lang.Object. For instance: scala> 1.getClass res0: Class[Int] = int scala> Nil.getClass res1: Class[_ <: scala.collection.immutable.Nil.type] = class scala.collection.immutable.Nil$ scala> "hello".getClass res2: Class[_ <: String] = class java.lang.String

Categories : Scala

Using C# LINQ to concat a filtered List to List
If names is empty, what you're meant to do is this: var names = businessNames.Select(item => item.Name).ToList(); Another option is to use the List<T>'s ConvertAll method, like so: var names = buisnessNames.ConvertAll(item => item.Name); However, if it may be not empty, you'd need to use an if statement too: var names = new List<string>(); //some code if (names.Any()) names.AddRange(/*your selected method*/); else names = //your selected method;

Categories : C#

Getting List for Select tag from Map> based in iterator index
When iterating a map via the iterator tag var attribute is not necessary, because the current item pushed to the value stack on each iteration. So, referencing value attribute of the map entry as a list collection. <s:iterator value="listOne" status="stat"> <s:select name="col%{#stat.index}" listKey="KEY" listValue="VALUE" list="dynamicList['%{top}']" /> </s:iterator>

Categories : Java

How to creat a new list from existing list with elements which contains the same id in Linq to object?
list.GroupBy(x => new { x.RefId, x.RefName }) .Select(g => new TestNew() { RefId = g.Key.RefId, RefName = g.Key.RefName, ListGroup = g.Select(y => new Group() { ID = y.ID, Name = y.Name }).ToList() }).ToList();

Categories : C#

Error converting an object list to tag list with dynamic UI in shiny
I would guess one problem is that the plot_output_list should not be indexed by strings, but instead by number, i.e. plot_output_list[[symbol]] <- ... should be plot_output_list[[i]] <- ...; i <- i + 1 If that doesn't work, try running traceback() right after you hit the error so we can see where the error comes from.

Categories : R

When I access a list on an object it incorrectly returns as empty list
You replace the neighbours parameter with an empty list def __init__(self, (x,y,z), n, radius, neighbours): neighbours = [] # <- HERE self.neighbours = neighbours Remove that line, and you should be able to access the neighbour list.

Categories : Python

Sorted/unique list of object instances from a larger list?
One way to do this is using itertools.groupby(): import itertools x3 = [next(g) for k, g in itertools.groupby(x2, lambda x:(x.a, x.b))] This picks the first element of each group with the same key.

Categories : Python

How to short*cirtcuit [] to create a list-like object instead of the standard list ? Is it even possible?
As stated here, python doesn't allow you to override its syntax. Although, this answer contains a hack that might help you (probably not).

Categories : Python

AutoMapper for a list scenario only seems to repeat mapping the first object in the list
For anyone else with this problem, it appears as if the documentation was not working for me. A colleague made the following suggestion: userSearchModel.UserList = UserEvent.Select(item => Mapper.Map<User, UserListModel>(item)); It worked like a charm.

Categories : C#

Append different object into list but the list result in same objects repeating
Whenever you call neighbor_list.append(neighbor) you just add a reference to neighbor, rather than a new list. This means that every list in neighbor_list is just the current value of neighbor. To fix this, you should make a copy of the list like this: neighbor_list.append(copy.copy(neighbor) Documentation for copy

Categories : Python

How to parse String List into List using Gson
Your getGenericClass() won't work, you need to retrieve the class of T. You can provide it : Class<T> type; public Class<T> getType() { return this.type; } or get it at runtime (unsafe, you can find many post on this subjet I think) public Class<T> getType() { return (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; } Then to build the list token you can use this code : static TypeToken<?> getGenToken(final Class<?> raw, final Class<?> gen) throws Exception { Constructor<ParameterizedTypeImpl> constr = ParameterizedTypeImpl.class.getDeclaredConstructor(Class.class, Type[].class, Type.class); constr.setAccessible(true); ParameterizedTypeImpl paramType = cons

Categories : List

Reliable way to pass Object variable to method that expects Object parameter
(I removed all this part because it is not applicable anymore to the new text of the question) --- SAMPLE CODE (original question) Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Dim Obj As Object 'Argument as Object treated as String Obj = "converting into string although still is an object" Dim outString As String = ObjToString(Obj) 'Is, complex behaviour; equals (=), always the same Obj = "This one is 1" Dim is1 As Integer = IsVsEqual(Obj, False) '1 Dim equal1 As Integer = IsVsEqual(Obj, True) '1 Obj = 1.0d 'This one 2 Dim outIndex2 As Integer = IsVsEqual(Obj, False) '2 Dim equal2 As Integer = IsVsEqual(Obj, True) '1 End Su

Categories : Vb.Net



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