|
I am creating a tabbed content interface. The content panels are an unordered list created using a server-side script. I want to add tabs via jQuery to control the panels. The only requirement for the jQuery plugin to work is to have the same amount of...
Started by mikemick on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
You could do this too:
$('ul.panels li').each( function(idx, panel) { // stir in special sauce });
var count = $("ul... .
Like this?
var cnt = $('ul.panels li').length
jQuery hangs varous things off of it so you don't really need your own loop (methinks) .
|
|
Here I have a simple example to find an item in a list of strings. Normally I use for loop or anonymous delegate to do it like this:
int GetItemIndex(string search) { int found = -1; if ( _list != null ) { foreach (string item in _list) // _list is an...
Started by David.Chu.ca on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
In list where item == search select item).First(); // Null if not found var item = list.FirstOrDefault(item => item == search); // or var item = (from item in list where item ==....
|
|
How in Scala to find unique items in List?
Started by Vladimir Bezugliy on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
If you refer to the Rosetta Code: Create a Sequence of unique elements
val list = List(1,2,3,4,2,3,4,99) val l2 = list.removeDuplicates // l2: scala.List[scala.Int] = List(1,2,3,4,99)
Since List is immutable, you wont modify....
|
Ask your Facebook Friends
|
Which is faster to find an item in a hashtable or in a sorted list?
Started by LittleBoy on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
The fastest way to find an element in a sorted list is ....
Also, accordingly to other answers, and depending on your item, you must try to find—but if you're rolling your own, it's definitely something to consider.
Log n) ..
|
|
Hey. I have a very large array and I want to find the Nth largest value. Trivially I can sort the array and then take the Nth element but I'm only interested in one element so there's probably a better way than sorting the entire array...
Started by ooboo on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
The entire sequence maintaining a list of the 5 largest values you find (this will be O(n into an empty list when the largeArray item is greater than the last item of your top-N list, then drop the last item....
|
|
I have some List and TileList controls. How can I get a reference to the list item that's currently under the mouse pointer?
Started by toby on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Add an event listener to each item in your list for mouseOver then in your function it will be the event.currentTarget
There's a simple method in the List/TileList for Flex 3 to do this:
<mx:TileList id="tileList" itemRollOver....
|
|
I have a list which contains a collection of objects.
How can I search for an item in this list where object.Property == myValue
Started by JL on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
item = objects.Find(obj => obj.property==myValue);
You have a few options:
Using :
list.Find(i => i.Property == value); // C# 3.0+ list.Find(delegate(Item i) { return i.Property == value = myList.Find(item => item.property....
|
|
I have an unsorted list of strings. I can place these items in an array, List, SortedList, whatever.
I need to find the fastest way of looking up a string in this list. Am I better off dumping the list into an array, sorting it, then implementing binary...
Started by AngryHacker on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
I'mIf your goal is just to make it very fast to find the strings in a collection, put them,TValue>.Contains is also O(1)....
list, to find different items, then sort it keep the sorted list and do a binary search...
|
|
Given the following:
List<List<Option>> optionLists;
what would be a quick way to determine the subset of Option objects that appear in all N lists? Equality is determined through some string property such as option1.Value == option2.Value...
Started by JC on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Basically you would do this:
Retrieve the first item from each list Compare the items, if equal that's the fastest....
Var x-sort.
Ok, this will find the list of Option objects that have a Value appearing in every list.
|
|
I have a WinForms combo box, I wish to set the width of the column box so that any selected item can be shown in full. (I do not know what items will be in the combo box at the time of writing the software)
However when I call Combobox.PreferredSize, ...
Started by Ian Ringrose on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Private void ResizeComboBox(ComboBox comboBox = Graphics.FromHwnd(comboBox.Handle)) { foreach (var item in comboBox.Items.Cast<string>()) { var itemLength = g.MeasureString....
Details on how to find the widest item in the list.
|