list

Creating a Generic Dictionary From a Generic List

I am trying to do the following but I think I must be missing something...(fairly new to generics) (Need to target .NET 2.0 BTW) interface IHasKey { string LookupKey { get; set; } } ... public static Dictionary<string, T> ConvertToDictionary(IList<T> myList) where T : IHasKey { Dictionary<string, T> dict = new Dictionary<stri...

Modifying a list from order A to order B using only push and remove operations

Is there any well-known algorithm (or obvious solution) for transforming a list from order A to order B using only push and remove operations? For instance, from a b c d to b c a d could be done using the following operations: remove(a) remove(d) push(a) push(d) Or, from c b a to a b would be remove(c) remove(b) push(b) Or, from a ...

Problem with list and map in GWT

I have a problem with map and list in GWT. I need to put a map in to a list but GWT does not support ArrayList and HashMap since they are not serialized types. Exactly I want to create following list with out using ArrayList and HashMap ArrayList<HashMap<String, Object>> map = new ArrayList<HashMap<String,Object>>(); Thank you for new...

Sorting list with jQuery

Hi I've got a small problem I'm struggling to solve. Let's say I've got an unordered list, like: <ul> <li> //first <div id="div1> text </div> </li> <li> //second <div id="div2> text </div> </li> <li> //third <div id="div3> text </div> </li> </ul> Is there an easy approach to change the ...

How to list all class names in the current package with Java ?

In my Java project I need to list all class names in the current package, I usually run my app in two different modes : <1> From NetBeans, <2> From an executable jar file packaged by the NetBeans. My question is : How to write my program so that no matter which mode it is running, it can list all the class names in my app. Because when ...

Using Http Post to AddList() in Sharepoint

On a remote client, I'm trying to create a new list in a sharepoint site. Right now, I'm building a CAML string and sending it via http post to my sharepoint site. I've used this method to update list items and create dws folders, but I can't seem to get AddList to work. I get an error "Remove server returned error:NotFound." here is my...

Scheme: Detecting duplicate elements in a list

Does R6RS or Chez Scheme v7.9.4 have a library function to check if a list contains duplicate elements? Alternatively, do either have any built in functionality for sets (which dis-allow duplicate elements)? So far, I've only been able to find an example here. The problem with that is that it doesn't appear to actually be part of the ...

MFC Virtual List Control using Database

Hi, Does anyone know of a good MFC example of how to create and use a virtual list control with a database that has 100K records? I don't want to load in all the records at once because it takes too much time. I want all updates to the list control to be fast based on user interaction. Thanks, Mike ...

Can't create a list of elements linked by a "Parent".

I'm trying to create a method (using the A* algorithm) that solves a puzzle and returns the steps to that solution. The solution it's easy.. but I can't return the path to that. I used a list of Nodes and then every time a push back a new Node I set the parent pointing to the Node which new came; list<Node> opened; list<Node> closed; ...

Writing a remove name loop for a list

Hi everyone, I'm looking to try to make an efficient delete method to work on a list. This situation is as follows: Say for e.g. I have a (potentially) massive list of names: Alex Smith Anna Hobb Bertie Blackman Bill Clinton David Smith David Warner George Jung George Washington William Wobbits Lets say that this is a List<Person> w...

Prolog problem help.

I am trying to learn prolog and have come across a problem that I can't figure out. The problem is to write a prolog predicate that takes all the numbers of a list that are less than a given number and put them into a list that will be returned. For example: input: findNum(5, [5, 3, 5, 6, 4, 5], Y) output: Y = [3, 4] Everything I've t...

Sort with two criteria, string ascending, int ascending

How can I perform a sort on two different criteria? For example, I have person objects like: Person with properties FirstName (string), LastName, and Rank (int). Example data like so: Xavier Smith 1 Alexander Smith 2 Alexander Smith 1 Bob Hawke 2 It should sort on FirstName alphabetically, then on rank, e.g. resulting: Al...

How do I intersect two lists in OCaml?

When I have two lists in OCaml, for example e1 = [3; 4; 5; 6; 7] and e2 = [1; 3; 5; 7; 9] Is there an efficient way to get the intersection of those two lists? I.e.: [3; 5; 7] Because I don't like scanning every element in list e2 for every element in list e1, thus creating a big Oh of order n^2. ...

List without nil in Lisp

Hi! Allknowing that in lisp list must contain nil, but expression like (print (cons 1 (cons 3 2))) dont throw any errors and prints (1 3 . 2) Is it correct? I use GNU Clisp. Help me please ...

How create select/options tag from find('threaded') in CakePHP

How to create select/option html tag from find('threaded') data in CakePHP? Function find() return results like this: Array ( [0] => Array ( [Forum] => Array ( [id] => 1 [name] => Forum ) [children] => Array ( ...

Prolog homework: how to parse a list of 'bits' representing a numeric value into a decimal representation?

Okay, so I have another question on a prolog homework problem I am struggling with. The problem goes as follows: Write a Prolog program that will take a list representing the bits of a binary number, and return the decimal value of the integer that the list represents. Example: valueof([1,1,0,1],X). X = 13 So here's what I hav...

Bind list from FormView to model in ASP.net webforms

For a large fillin form I use the asp.net FormView for the magic databinding to my model. In this model I've a property called Rides (shown below), which exposes a list, which I obviously not want to be replaced entirely. So I made it readonly. However, this way I can't use the databinding features anymore. Is there a common solution fo...

Filter a list of objects using LINQ

I have a list of custom objects. These objects have 2 datetime properties on them. I need to get a list of unique (ignore the time part) datetime objects from the two objects properties. Example I have 2 objects with 2 datetime properties: object1.date1 = "01/01/2001 12:54" object2.date1 = "01/02/2001 12:51" object3.date1 = "01/01/20...

Weird top padding on horizontal list items

I have a horizontal list on which I have placed borders on the li tags in order to separate them. Its all working well but I have some mysterious padding on the top of the li which is making the borders taller than the text: http://img641.imageshack.us/img641/3706/picture13y.png I have played around with the padding and margins but I c...

How can I write simulations in Erlang?

Hi guys, I want to do some numerical stuff in Erlang like this: You've got an array with the following values: [2,3,4] In each iteration, you calculate 0.1 * [n-1] + 0.7 *[n] + 0.2 * [n+1] This becomes the new [n]. If n == 0 then [n-1] = 0. If [n] == length of array then [n] = 0. So I try an example: [2,3,4] calculations:...