list

comparing two arrays

I have two lists: A = [0,0,0,1,0,1] B = [0,0,1,1,1,1] I want to find the number of 1s in the same position in both lists. The answer for these arrays would be 2. ...

Long check list ui pattern for web

I have a data entry page where the user is required so make some selections from a list. Currently it is just a check list with about 10 items they can tick, but is will expand soon to about 230. What is a good UI paradigm for dealing with a large number of selectable items? I am considering dual list type control. ...

Modelbinding lists

I got a controller action like public class Question { public int Id { get;set; } public string Question { get;set; } public string Answer { get;set; } } public ActionResult Questions() { return View(GetQuestions()); } public ActionResult SaveAnswers(List<Question> answers) { ... } the view> looks like: <%...

How can I add a list item in order using jQuery?

Does anyone know how to add an item to a list but do it so it's ordered alphabetically using jQuery? I've got the following code that just adds an item from a dropdown to the end of the list: $("#projectList").append( "<li>" + $("#Projects :selected").text() + " <span class='removeProject' projectId='" + $("#Projects").val()...

How do I make an item editor in a flex list component commit it's changes?

I have a list component and I have an item editor for the items in the list. I would like to have a button that the user clicks once they are done with their changes because I am having them edit multiple pieces of data in the editor and I would also like to validate the data before closing the editor as well. I just don't know what to d...

How do you calculate the greatest number of repetitions in a list?

If I have a list in Python like [1, 2, 2, 2, 2, 1, 1, 1, 2, 2, 1, 1] how do I calculate the greatest number of repeats for any element? In this case 2 is repeated a maximum of 4 times and 1 is repeated a maximum of 3 times. Is there a way to do this but also record the index at which the longest run began? ...

Array/list questions

I have a method which returns a document list consisting of all these attributes: private String activitySource, activitySystemStatus, regionCode, channel, creatorUserId, displayOnAccessIndicator, documentLocationCode, extraDetails, keywordList, lastUserId, summaryText, textTypeIndicator; H...

Efficient data structure for fast random access, search, insertion and deletion

I'm looking for a data structure (or structures) that would allow me keep me an ordered list of integers, no duplicates, with indexes and values in the same range. I need four main operations to be efficient, in rough order of importance: taking the value from a given index finding the index of a given value inserting a value at a giv...

hibernate OneToMany List ordering persisting but reversing?!

so I have a persistent entity that has a @OneToMany list of another entity and I need the list order to be able to be edited by the user, which works wonderfully, I can completely re-order the java List in memory and when I save() the object, the order of links in the linking table DOES change... however, it changes to the reverse order ...

How can I remove everything except listed files with the Find-command?

I have a list of hidden files in a file "list_files" that should not be removed in the current directory. How can remove everything except them with a Find-command? I tried, but it clearly does not work: find . -iname ".*" \! -iname 'list_files' ...

Can reading a list from a disk be better than loading a dictionary?

I am building an application where I am trying to allow users to submit a list of company and date pairs and find out whether or not there was a news event on that date. The news events are stored in a dictionary with a company identifier and a date as a key. newsDict('identifier','MM/DD/YYYY')=[list of news events for that date] ...

Union, Intersection and Exclude with the FIND-command?

I need to manage lists with find-command. Suppose the lists have random names in non-distinct lists (ie their intersection is not empty set). How can I do: A \ B find files in the list A except the files in the list B A intersection B find files common to the lists A and B Please, consult here. A union B find all files ...

DataTables vs List(Of Object)

I'm having a debate with another programmer I work with. Are there any significant memory usage or performance differences, or other cons which should make someone avoid using the DataTable and favour lists(of object)... or vice versa I prefer using the lists because they are more lightweight, strong typing to the object when accessing...

C#: Inheritance Problem with List<T>

Let's assume this class in C#: public class LimitedList<T> : List<T> { private int _maxitems = 500; public void Add(T value) /* Adding a new Value to the buffer */ { base.Add(value); TrimData(); /* Delete old data if lenght too long */ } private void TrimData() { int num = Math.Max(0, ba...

In Python how do I sort a list of dictionaries by a certain value of the dictionary + alphabetically?

Ok, here's what I'm trying to do... I know that itemgetter() sort could to alphabetical sort easy, but if I have something like this: [{'Name':'TOTAL', 'Rank':100}, {'Name':'Woo Company', 'Rank':15}, {'Name':'ABC Company', 'Rank':20}] And I want it sorted alphabetically (by Name) + include the condition that the one with Name:'...

Python: Joining Multiple Lists to one single Sentence

Howdy, I've got multiple lists. For example: [u'This/ABC'] [u'is/ABC'] [u'not/ABC'] [u'even/ABC'] [u'close/ABC'] [u'to/ABC'] [u'funny/ABC'] [u'./ABC'] [u'O/ABC'] [u'noez/ABC'] [u'!/ABC'] I need to join this List to This/ABC is/ABC not/ABC even/ABC close/ABC to/ABC funny/ABC ./ABC O/ABC noez/ABC !/ABC How do I do that please? Yes,...

How to print list using hierarchical data structure?

When I run this code: foreach ($tree as $node) { echo str_repeat(' ', $node->tree_depth * 4) . $node->id . PHP_EOL; } I get well formatted text like: Food Fruit Red Cherry Strawberry Cool Not cool Yellow Banana Meat Beef Pork But I want to create a list with <ul><li>......

Modeling question: Lists that depends on each other, but can be specialized entries?

Hi all Trust me, I've put a lot of thought into this problem before asking here, and I think I got a solution, but I'd like to see what you guys can come up with before settling for my own :) SCENARIO: In the domain we got 3 entities: A treatment, a beautyshop and an employee. A beautyshop can hire 0 to many employees. Now, a beautysa...

ASP.NET / C# How to access list item of unordered list with runat=server ?

Hi, I have a ul list with a number of list items like: <ul> <li runat="server" id="liOne">one</li> <li runat="server" id="liTwo">two</li> <li runat="server" id="liThree">three</li> </ul> On page load, I need to set these list items visible or not visible. For some reason I cannot access these in the C# code behind. Nor are the list...

Organizing lists in HTML/CSS

I have a list and I need two sections in each item. I also need the first section to be of fixed width. How should I code it? I've tried using definition lists: <dl> <dt style="width: 2em;">foo</dt><dd>bar</dd> ... </dl> ... and user lists with span: <ul> <li><span style="width: 2em;">foo<span>bar</li> ...