list

Iterating through a list in Python

I am trying to iterate through a list and take each part of the list, encode it and join the result up when it is all done. As an example, I have a string which produces a list with each element being 16 characters in length. message = (u'sixteen-letters.sixteen-letters.sixteen-letters.sixteen-letters.') result = split16(message, 16) m...

Difference between Select and ConvertAll in C#

I have some List: List<int> list = new List<int> { 1, 2, 3, 4, 5 }; I want to apply some transformation to elements of my list. I can do this in two ways: List<int> list1 = list.Select(x => 2 * x).ToList(); List<int> list2 = list.ConvertAll(x => 2 * x).ToList(); What is the difference between these two ways? ...

BlackBerry ListCall back error

i am implementing ListField to show users data in next screen. but its throwing an exception can u plz guide me whats wrong with this code. import java.io.*; import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; import net.rim.device.api.system.*; import net.rim.device.api.ut...

Create Sharepoint List which has gantt view - programmatically

I am new to sharepoint therefore don't know much - any help would be highly appreciated. Basically i want to programatically (in the same project) :- 1. create a List and make it a Gantt View 2. Add add appropriate cololumns (that would generate the Gantt chart) to the List 3. And finally i would like to add values/data to the coloums ...

Getting all combinations of pairs from a list in Ruby

I have a list of elements (e.g. numbers) and I want to retrieve a list of all possible pairs. How can I do that using Ruby? Example: l1 = [1,2,3,4,5] -> l2 = [[1,2][1,3][1,4][1,5][2,3][2,4][2,5][3,4][3,5][4,5]] ...

Menu List Float Not displaying correctly in Firefox and Safari

I have a nav that is displayed below the images. I created the nav using the ul and li. The issue I am having is that in Firefox and Safari there is a space above the list while in Explorer it is displaying correctly with the flush against the header. Please help! ...

How do I un-highlight a previously selected line in an MFC CListCtrl programmatically (VS 6)?

Does anyone know how to un-highlight a previously selected line in an MFC CListCtrl programmatically ? ...

Scheme How to Take the first item in the List ?

Say I want to take the first item of the lists '(4 3 1) '(5 6 8) I want something like this (first '(4 3 1) '(5 6 8)) should return me the first item (4 3 1) as result. Is there something like this in scheme build-in function I can call ? car doesn't work, as it only returns me the first item inside 1 list list-ref doesn't work,...

Fastest nested loops over a single list (with elements remove or not)

Hello, I am looking for advice about how to parse a single list, using two nested loops, in the fastest way, avoiding doing len(list)^2 comparisons, and avoiding duplicate files in groups. More precisely: I have a list of 'file' objects, that each has a timestamp. I want to group the files by their timestamp and a time offset. Ex. star...

Extremely large Boolean list in Python

I want to create an object in python that is a collection of around 200,000,000 true/false values. So that I can most effectively change or recall any given true/false value, so that I can quickly determine if any given number, like 123,456,000 is true or false or change its value. Is the best way to do this a list? or an array? or a cl...

Key compare using dictionary

Hi all, I have a file with the following structure: system.action.webMessage=An error has happened during web access. system.action.okMessage=Everything is ok. core.alert.inform=Error number 5512. I need a script to compare the keys in 2 files with this structure. I was working in a script to convert the file into a dictionary and use...

How to remove elements from a generic list while iterating around it?

I am looking for a better 'pattern' for working with a list of elements which each need processed and then depending on the outcome are removed from the list. You can't use .Remove(element) inside a foreach (var element in X)... you also can't use for (int i = 0; i < elements.Count(); i++) and .RemoveAt(i). Previously I have done craz...

Problem getting generic extension method to work correctly

I'm trying to create the extension method AddRange for HashSet so I can do something like this: var list = new List<Item>{ new Item(), new Item(), new Item() }; var hashset = new HashSet<Item>(); hashset.AddRange(list); This is what I have so far: public static void AddRange<T>(this ICollection<T> collection, List<T> list) { fore...

Spread out elements over a fixed width div?

Hi Is there way to spread out elements, (eg: <li>'s inside a <ul>), within a div? EG: I have 3 elements, so they all get 30% EG: I have 5 elements, so they get 20% What is the best way to do this? ...

SQL Joining tables based on a list of names

Hi, I'm looking for a way to join a series of SQL tables based on a list of table names. The list of table names can change as the system grows but I need to make sure the join operates on all the tables as they grow. Each table in the list will have a common column called ActivityID which is a foreign key back to the Activity table wh...

Bad Fairness with a ReadWriteLock / SharedLock under load

Hello, we are currently designing a multithreaded server application. To optimize performance, we decided to implement a ReadWriteLock, i.e. multiple threads can get a lock if they only want to read but just one thread may hold the write lock. This lock is used with a list and iterating over the list is the "read" operation. Now this...

List<T> is cleared problem

Please take a look at the code. It shouldn't take long to have a glimpse. class Teacher { private int _id; public int ID { get { return _id; } set { _id = value; } } private string _message; public string Message { get { return _message; } ...

When to use a List over an Array in Java?

In Java, when would it be preferential to use a List rather than an Array? ...

Flatten List in LINQ

I got a linq query who returns a IEnumarable<List<int>> but i need to return, only List<int> so i want to merge all my record in my IEnumerable<List<int>> to only one array. Example : IEnumerable<List<int>> iList = from number in (from no in Method() select no) select number; I want to take all my result IEnumerable<List<int>> to onl...

C# List<T> Contains test

Is this kind of if-testing necessary when removing an item? if (_items.Contains(item)) { _items.Remove(item); } And, what about this test? if (!_items.Contains(item)) { _items.Add(item); } ...