list

what is difference between unbounded wildcard type List and raw type List?

can please help in understand difference between unbounded wildcard type List and raw type List List a; List<?>; along with this can anybody help me to understand BOUNDED TYPE PARAMETER LIST List<E extends Number>; ...

How do I make a generic List which can accept two different, unrelated types?

I have to define a List and it has two types of possible values 1)String 2)some user defined Class How can I make a List that is type safe in that it only accepts these two types? I want to avoid the use of raw List. ...

Remove elements as you traverse a list in Python

In Java I can do by using an Iterator and then using the .remove() method of the iterator to remove the last element returned by the iterator, like this: import java.util.*; public class ConcurrentMod { public static void main(String[] args) { List<String> colors = new ArrayList<String>(Arrays.asList("red", "green", "blue",...

Display List contents specific field in a ComboBox (C#)

Well, my question is a bit silly, but I've tried lots of different thing without result. I have a ComboBox in my main form and I want to point its data source to the public readonly List PriceChanges list declared in the Filters class. No problem with that but I want to list the Description field. I tried to assign the "Description" ...

How to avoid a loop in R: selecting items from a list

I could solve this using loops, but I am trying think in vectors so my code will be more R-esque. I have a list of names. The format is firstname_lastname. I want to get out of this list a separate list with only the first names. I can't seem to get my mind around how to do this. Here's some example data: t <- c("bob_smith","mary_jane...

C++ How to loop through a list of structs and access their properties

I know I can loop through a list of strings like this: list<string>::iterator Iterator; for(Iterator = AllData.begin(); Iterator != AllData.end(); Iterator++) { cout << "\t" + *Iterator + "\n"; } but how can I do something like this? list<CollectedData>::iterator Iterator; for(Iterator = AllData.begin(); Iterator != ...

Java List parameterized?

Hi, I am quite new to Java ... I wrote a class called DLPFile which is basically a container of other objects like Strings, ints, floats, etc. When putting my files into a List and then saving it in my session (which is from Map class) variable is easy; DLPFile file = new DLPFile(); List <DLPFile >fileList = new ArrayList <DLPFile>...

Efficient way to use python's lambda, map

I need to store a big list of integers in Bigtable(db). For efficiency I am storing them as diff between 2 consecutive items. for eg: original_list = [1005, 1004, 1003, 1004, 1006] Storing the above list(which actually contains more than 1000k items) as start = 1005 diff = [-1, -1, 1, 2] The closest I could manage is, ltp = [st...

How to bind a ListBox to Properties in a Class?

I have one main outstanding issue, I know now how to databind to lists and individual items, but there is one more problem I have with this, I need to bind a listbox to some properties that are in a Class. For Example I have two Properties that are bound in some XAML in a class called Display: Public Property ShowEventStart() As Visibil...

Scala list recursion performance

This question is about the way that Scala does pattern matching and recursion with lists and the performance thereof. If I have a function that recurses over a list and I do it with matching on a cons, for example something like: def myFunction(xs) = xs match { case Nil => Nil case x :: xs => «something» myFunction(xs) } in Hask...

Why does my jQuery selector select all anchors inside the list element?

Been struggling with this simple selector problem a couple of hours now and must be missing something obvious. I have a <ul> in which some <li>s have nested <ul>s. Each <li> contains a link and when this is clicked I want to execute a function (rather than navigate), but importantly, this should only happen for the links contained in the...

Why am I getting a compile error when I'm trying to create a list of a dynamic object at runtime?

I've done some research and found that there apparently is an easy and understandable way to do this using reflection. Type MyType = typeof(MyObject); IList lst = (IList)Activator.CreateInstance((typeof(List<>).MakeGenericType(MyType))); I'm getting compile error. It's telling I do in fact need to supply the type to IList... Am I miss...

How to set ComboBox.SelectionBoxItemTemplate in Silverlight 3.0

I need to be able to have a SelectionBoxItemTemplate for my ComboBox, but am unsure how to do this or if there is another way in Silverlight 3.0 to do this. In my drop-down list I have a List of CheckBoxes, and TextBlocks, this works fine, however the Selected Item is one of these when I click on it, i.e. the Checkbox shows in the top of...

OOP design and Lists and collections (C#)

Hello guys, I need to design a simple piece of software, and i was wondering the best to do it. First of all, sorry for the novice question: what is the best way to work with lists? i tried a few times and did not perceived the correct way to instanciate them and how to use them in OOP. Can anyone clear it up for me? The second questi...

C++ keeping a list of objects and calling a contructor through another function

why isnt my object being created? When I do it like so, I am told error C2065: 'AllReferrals' : undeclared identifier as well as error C2228: left of '.push_back' must have class/struct/union. If I put the list initialization before the class I get error C2065: 'AllReferrals' : undeclared identifier. Thanks! #include <iostream> #inclu...

var paragraph is giving me "unterminated string constant" error

I have this file var paragraph = "Abandon| give up or over| yield| surrender| leave| cede| let go| deliver| turn over| relinquish| depart from| leave| desert| quit| go away from| desert| forsake| jilt| walk out on | give up| renounce| discontinue| forgo| drop| desist| abstain from| recklessness| intemperance| wantonness| lack of r...

Adding items to multiple tables with linq to sql

Hello Everyone, Let's say I have two tables one called Customers and one called CustomerAddresses. Then lets say I have a Customer object which contains a property that is of the type List<Address>. This property holds a list of all the different shipping addresses a customer may have used, so it could contain 0 - n addresses in it (j...

Help with a jquery country/state list

Is there a better way to do this jquery code? Currently I have to use PHP to insert the starting position of the jquery code. The code is for a country/state list. If a user picks USA then a state dropdown list is below it, if any other country is selected, then it will show a different text input box and hide the dropdown list. ...

Sorting a Doubly Linked List C++ Question

Trying to do it through a loop that traverses through the list. In the loop im feeding the head node into a sorting function that I have defined and then im using strcmp to find out if which name in the node should come first. Its not working because writing the names too early. Im comparing them all linearly by going down the list ...

How do array semantic initializers work in C#?

in C# 3, initializers were added. This is a great feature. However, one thing has me confused. When you initialize class, you typically have to specify the member variable or property you are initializing. For example: class C { public int i; } public void blah() { C c = new C() { i = 1 }; } Array semantics have been in C# si...