sortedlist

Re-ordering collection C#

Hi - I have a problem which I cant seem to find answer to through searches (either that or I am searching for the completely wrong thing!). I have a list of items called "Top 10" in a sortedlist item that is populated from my DB (SortedList where int is position and string is item). I want to be able to move items up & down the list or...

Is there a sorted java collection which handles duplicates?

I need a collection that behaves something like C++ multimap, but I also need to be able to get elements by a range of keys. ...

Need sorted dictionary designed to find values with keys less or greater than search value

Hi I need to have objects sorted by price (decimal) value for fast access. I need to be able to find all objects with price more then A or less than B. I was thinkg about SortedList, but it does not provide a way to find ascending or descending enumerator starting from given key value (say give me all objects with price less than $120)....

An Efficient data structure for Sorted List

I want to save my objects according to a key in the attributes of my object in a sorted fashion. Later on I'll access these objects sequentially from max key to min key. I'll do some search tasks as well. I consider to use either AVL tree or RB Tree. As far as i know they are nearly equivalent in theory(Both have O(logn)). But in practi...

LINQ into SortedList

I'm a complete LINQ newbie, so I don't know if my LINQ is incorrect for what I need to do or if my expectations of performance are too high. I've got a SortedList of objects, keyed by int; SortedList as opposed to SortedDictionary because I'll be populating the collection with pre-sorted data. My task is to find either the exact key or...

Item duplication problem

Hi friends, My goal is to add a insert new value to a column where my column values are as follows 100 * 100 150 * 150 200 * 200 200 * 200 I get the following error: Item has already been added. Key in dictionary: '200 x 200' Key being added: '200 x 200' For next code: SortedList sortedList = new SortedList(); foreach (ListI...

Meh, C# SortedList has no .Find

Silly if you ask me. But this message is here because I will assume (probably correctly) that I am the silly one, not Microsoft. So... is there something I'm missing? Why didn't they include a "Find" method to this baby? The find could work on the Values, which are objects, so then I could do this: someObject = SortedList.Values.Find(or...

Why is there no SortedList<T> in .NET?

Why is there only a SortedList<TKey, TValue> which looks more like a dictionary, but no SortedList<T> that is actually just a list that is always sorted? According to the MSDN documentation on SortedList, it is actually internally implemented as a dynamically-sized array of KeyValuePair<TKey, TValue> that is always sorted by the key. Wo...

SortedList - VS - List - VS - LinkedList

In my mind it was always there that List is basically implemented using LinkedList, while normal Array is implemented as Contiguous blocks. I always tried to use List because of it is made using Generic and also might have the power of Dynamic Memory Allocation. But I was wrong. Yesterday I saw the implementation of List using Reflector...

C# sort Listbox, add to a sorted list

Hi, I want to sort the elements in C# listbox by some field in the object element. Is there a method in C# that perform this task? Maybe a function that receives a comparison function as a parameter or something like that? another thing, when the listbox is sorted I want to add an element to a sorted list. is there such a method? than...

Javascript: I need a good data structure to keep a sorted list

This would probably be implemented as a tree or something? My point is it needs to be efficient. I don't know where to find good implementations of data structures for Javascript for something like this, though. I don't want to have to roll my own if I can avoid it. Help appreciated. ...

C# faster sorting than SortedList<>

Hi we have a SortedList<Resource, Resource> resources = new SortedList<Resource, Resource>(new ResourceIdle()); that we use in our simulation. This list of resources is initialised in this way because we want to pass different comparers at any point in time. First problem we have is that the SortedList<> requires an extra compar...

Comparing arraylist c#

Hi, in c# if i have an arraylist populated like (ID, ITEMQUANTITY), and i would like to compare them by ID, how would i do that? I mean, i need to customize it so that i can compare it by the first value only, so if i want to insert another item i can check if the id is already in the list.... I know how to do it by looping through all ...

Finding duplicates in sorted, linked list.

Hello! I've created a sorted linked list and now I'm trying to figure out how to remove duplicates. I wanted to add code that would do this in the Add method I created but I can't seem to figure it out. I feel like this should be relatively easy but I'm a bit brain dead right now. In my add method I check the index to see where an item ...