list

C++ modifying list while iterating over list

I have a std::list of Bananas, and I want to get rid of the bad ones. Is there any relatively simple way to perform the following pseudocode? foreach(Banana banana in bananaList) { if(banana.isBad()) bananaList.remove(banana); } (Making a transition from C# and Java to C++ has been a rocky road.) ...

Improving pure Python prime sieve by recurrence formula

I am trying to optimize further the champion solution in prime number thread by taking out the complex formula for sub-list length. len() of the same subsequence is too slow as len is expensive and generating the subsequence is expensive. This looks to slightly speed up the function but I could not yet take away the division, though I do...

C# serialising data structure with objects in multiple lists/collections

In C# I wish to serialise a data structure where objects can belong to more than one collection. For example, I have a Person class. I also have a Family class and School class, which each contain a MemberList. An instance of the Person class can be present in both the MemberList of the Family and the School. I wish to serialise the en...

lists in python, with references

How do I copy the contents of a list and not just a reference to the list in Python? ...

Excluding list items created by certain users from a list's view

Hi, I have a custom list created in Sharepoint 2007 and displayed by a content query web part. I would like to Show all items to general admin users except those items created by two users. The two admin users need to see all items in the list. The first requirement is easily done by adding a filter to the view on the created ...

Python - convert list of tuples to string

Which is the most pythonic way to convert a list of tuples to string? I have: [(1,2), (3,4)] and I want: "(1,2), (3,4)" My solution to this has been: l=[(1,2),(3,4)] s="" for t in l: s += "(%s,%s)," % t s = s[:-1] Is there a more pythonic way to do this? ...

MOSS 2007 - Maximum number of views for one list?

Is there a maximum number of views you can create for a list in SharePoint? I mean views like the ones which are listed in the top right corner o the AllItems.aspx page: Are there performance issues which arise when you add a lot of views to one list, like 50-100? ...

What is the most efficient way to merge items with the same type in a generic list in C#?

Example, I have the following interface and classes: public interface IRole { DateTime Since {get;} DateTime Until {get;} } public class Manager : IRole { public DateTime Since {get; private set;} public DateTime Until {get; private set;} } public class Employee : IRole { public DateTime Since {get; private set;} ...

Outputting multiple results from tables

The recipe db continues... categories cid | category_name 1 | desserts 2 | cakes 3 | biscuits recipes id | recipe_name 1 | black forest cake 2 | angel cake 3 | melting moments 4 | croquembouche 5 | crepes suzette ingredients iid | ingredient_code | ingredient_name | ingredient_brand 1 | abc201 | self-ra...

convert list<int> to list<long>

How to convert List<int> to List<long> in C#? ...

IList<T> does not have "where"

In a specific project at my work, I have a method that returns IList. But this interface does not contain where, or FindAll filters. However, when I open a new project, IList contains all. What is the difference? ...

Delete an item from a list

Hey, I was trying to delete an item form a list (without using set): list1 = [] for i in range(2,101): for j in range(2,101): list1.append(i ** j) list1.sort() for k in range(1,len(list1) - 1): if (list1[k] == list1[k - 1]): list1.remove(list1[k]) print "length = " + str(len(list1)) The set function works fine,...

How can I shuffle a list without randomness, and guarantee that a portion of elements will eventually appear on one side?

Given a list of elements, does a shuffling algorithm exist that will guarantee that eventually a selected half portion will be on one side, and the remainder on the other? Example: { 4, 3, 10, 7, 2, 9, 6, 8, 1, 5 } Given the set above, I'd like to have a mixing algorithm that eventually moves the marked ones to the left, even though...

reordering list of dicts arbitrarily in python

I have a list of 4 dicts (always 4) that look something like this: [{'id':'1','name':'alfa'},{'id':'2','name':'bravo'},{'id':'3','name':'charlie'},{'id':'4','name':'delta'}] I know exactly the order I want them in, which is: 2, 3, 1, 4 what's the simplest way of reordering them? ...

Python cached list

Hi, I have a module which supports creation of geographic objects using a company-standard interface. After these objects are created, the update_db() method is called, and all objects are updated into a database. It is important to have all objects inserted in one session, in order to keep counters and statistics before updating a pro...

ASP.NET Vertically wrapping a list generated by a repeater

I've got my repeater generating a list of links that need to appear in a certain order. Meaning I need my list to appear like so -Item1 -Item4 -Item2 -Item5 -Item3 Every solution I've found involves knowing whats going to be in your list and setting classes where the list should break. My issue is that it could be anywhere from 1 to 1...

Stable Sorting, ie, Minimally-Disruptive Sorting.

Suppose I have a list of things (numbers, to keep things simple here) and I have a function I want to use to sort them by, using SortBy. For example, the following sorts a list of numbers by last digit: SortBy[{301, 201}, Mod[#,10]&] And notice how two of (ie, all of) those numbers have the same last digit. So it doesn't matter which ...

Monotonify (list-munging) without a For loop.

For or While loops in Mathematica code always make me feel a little dirty but I was confusing myself trying to do some list munging all functional-like, and resorted to this: (* # Given a list of {x,y} pairs, transform the data as follows: every time # there's a decrease in y-value from one datapoint to the next, say {x1,Y} # fo...

bold and normal font rendering

It is observed in some fonts sat Verdana, that the rendering for bold and normal text does not occupy the same width for a given text. In my application i am making use of one such font ,and there is UI with list and highlighted item. for highlighted item the font is same with bold attribute ,because of above mentioned font issue the tex...

which sorting algorithm is used for std::list's sort member function ?

Possible Duplicate: Which sorting algorithm is used by STLs list::sort()? Which sorting algorithm can be used for sorting std::list ? ...