list

Problem with custom IComparer for List (sort) - c#

Hi, can anyone help, i have problem doing a sort, I thought i had it sorted but appears not to be working. I have a List which stores the following values 8,6,10,11,7 I also have another List (accessories in my class and it has a propert called accessoryId current the classes are in the order of id which is currenty 6,7,8,10,11) H...

STL List to hold structure pointers

I have a structure called vertex and I created some pointers to them. What I want to do is add those pointers to a list. My code below, when it tries to insert the pointer into the list, creates a segmentation fault. Can someone please explain what is going on? #include <iostream> #include <list> #define NUM_VERTICES 8 using namesp...

WPF Error: "Items collection must be empty before using ItemsSource."

Hello, Does anyone know why I keep getting the "Items collection must be empty before using ItemsSource"-Error? Here is the code: <ScrollViewer Margin="8,8,8,8" Grid.Row="3" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled"> <WrapPanel Orientation="Vertical"> ...

Sorting a Python list by key... while checking for string OR float?

Ok, I've got a list like this (just a sample of data): data = {"NAME": "James", "RANK": "3.0", "NUM": "27.5" ... } Now, if I run something like this: sortby = "NAME" //this gets passed to the function, hence why I am using a variable sortby instead data.sort(key=itemgetter(sortby)) I get all the strings sorted properly - alphabetic...

add a <div> before 5th <li> and add another </div> after the last <li> from a list?

how can i make it possible say i have a unordered list of 17 items. so now i want to add a div tag just before the the 5th item and the closing div will go after the last item of the list. the result will look some thing like this. <ul> <li><img src="http://static.flickr.com/66/199481236_dc98b5abb3_s.jpg" width="75" height...

Displaying Documents (filtered) from a library in Sharepoint

Using the latest current version of Sharepoint. I have aded a "Foo" document library containing documents of a custom Foo document type. The document repository carries along a FooID for each document, which will correspond to a primary key in an external database's [Foo] table that we are using for other purposes. I have a Foo.aspx p...

LWUIT list items

Hi, i need to add in list components that are not equal in height, is there a way for it to work? ...

Is returning a std::list costly?

I was wondering if returning a list, instead of returning a pointer to one, was costly in term of performance because if I recall, a list doesn't have a lot of attributes (isn't it something like 3 pointers? One for the current position, one for the beginning and one for the end?). ...

How does one add a LinkedList<T> to a LinkedList<T> in C#?

One would think the simple code llist1.Last.Next = llist2.First; llist2.First.Previous = llist1.Last; would work, however apparently in C#'s LinkedList, First, Last, and their properties are Get only. The other method I could think of was llist1.AddLast(llist2.First); However, this does not work either - it fails because the first...

Finding partial strings in a list of strings - python

I am trying to check if a user is a member of an Active Directory group, and I have this: ldap.set_option(ldap.OPT_REFERRALS, 0) try: con = ldap.initialize(LDAP_URL) con.simple_bind_s(userid+"@"+ad_settings.AD_DNS_NAME, password) ADUser = con.search_ext_s(ad_settings.AD_SEARCH_DN, ldap.SCOPE_SUBTREE, \ "sAMAccountName...

Comparing and updating array values in Python

I'm developing a Sirius XM radio desktop player in Python, in which I want the ability to display a table of all the channels and what is currently playing on each of them. This channel data is obtained from their website as a JSON string. I'm looking for the best data structure that would allow the cleanest way to compare and update t...

Sort List alternative in c#

I have a number of objects, all from the same class(ColorNum) Each object has 2 member variabels (m_Color and m_Number) Example: ColorNum1(Red,25) ColorNum2(Blue,5) ColorNum3(Red,11) ColorNum4(White,25) The 4 objects are in the ColorNumList List<ColorNum> ColorNumList = new List<ColorNum>(); Now I want to order the list so the obj...

Navigating through list items

I have the following code: var from = 0, step = 5; function showNext(list) { list .find('li').hide().end() .find('li:lt(' + (from + step) + '):not(li:lt(' + from + '))') .show(); from += step; } // show initial set showNext($('ul')); // clicking on the 'more' link: $('#more').click(function(e) { e.preventDefault(); ...

reallocating list in python

Ok this is my problem. I am trying something like this: for i in big_list: del glist[:] for j in range(0:val) glist.append(blah[j]) Idea is to reset list and reuse it for next set of data points. The problem is for some reason if the first list had 3 points. Therefore it used glist[0] glist[1] glist[2] The next...

Extract only numbers from data in Jython

Hello, Here is my problem. I'm working on a Jython program and I have to extract numbers from a PyJavaInstance: [{string1="foo", xxx1, xxx2, ..., xxxN, string2="bar"}] (where xxx are the floating point numbers). My question is how can I extract the numbers and put them in a more simple structure like a python list. Thank you in adv...

What is the best way to return two lists in C#?

I am almost embarrassed to ask this question, but as a long time C programmer I feel that perhaps I am not aware of the best way to do this in C#. I have a member function that I need to return two lists of a custom type (List<MyType>) and I know beforehand that I will always have a return value of only two of these lists. The obvious ...

"stable_sort()ing" a STL <list> in C++

Hi all! I think the question title is clear enough: is is possible to stable_sort() a std::list in C++? Or do I have to convert it to a std::vector? I'm asking because I tried a simple example and it seems to require RandomAccessIterators, which a linked list doesn't have. So, how do I stable sort a std::list()? EDIT: sample code that ...

Using jQuery.data to store a list of items

I'm working on a page where I need to associate a list of objects with a row of a table, and I'm using jQuery. jQuery.data seems to just associate a piece of data with a key, whereas I need more like id=4,setting=2 id=3,setting=1 ... I don't know how long the list could be, and it could be empty. Is there a sensible way of doing thi...

Auto-Initializing C# Lists

I am creating a new C# List (List<double>). Is there any way, other than to do a loop over the list, to initialize all the starting values to 0? Thank you. ...

Pythonic way to get some rows of a matrix

I was thinking about a code that I wrote a few years ago in Python, at some point it had to get just some elements, by index, of a list of lists. I remember I did something like this: def getRows(m, row_indices): tmp = [] for i in row_indices: tmp.append(m[i]) return tmp Now that I've learnt a little bit more sinc...