sorteddictionary

SortedDictionary (C#)- change value...

In a SortedDictionary is it possible to change the value of an item ? ...

How do I use Eval() to reference values in a SortedDictionary in an asp Repeater?

I thought I was clever to switch from the memory intensive DataView to SortedDictionary as a memory efficient sortable data structure. Now I have no idea how get the key and value out of the datasource in the <%# or Eval() expressions. SortedDictionary<int, string> data = RetrieveNames(); rCurrentTeam.DataSource = data; rCurrentTeam.Da...

Synchronization of SortedDictionary.iteri using readlock and writelock

let info = new SortedDictionary<string, string> ... Thread A -------- info.Add("abc", "def") Thread B -------- info |> Seq.iteri (fun i value -> ... Where do I place the readLock when I use the iteri function? ...

When to use a SortedList<TKey, TValue> over a SortedDictionary<TKey, TValue>?

This may appear to be a duplicate of this question, which asks "What’s the difference between SortedList and SortedDictionary?" Unfortunately, the answers do nothing more than quote the MSDN documentation (which clearly states that there are performance and memory use differences between the two) but don't actually answer the question. ...

Setting the i-th value of a SortedDictionary

I need to set the value of an element in my sortedDictionary, accessed by index. I.e. sortedDictionary.Values[index] = value; // compile error Note that the following is incorrect because it's accessed by key, not index. sortedDictionary[index] = value; // incorrect I came up with the following solution, but intuition tells me it'...

Get last element in a SortedDictionary

I see this question. How can I get the last element in a SortedDictionary in .Net 3.5. ...

SortedDictionary behavior

Hello everyone, I'm using a SortedDictonary(Of String, String) in my application, and I experience a strange sorting behavior. Consider the following code example: Dim Dic As New SortedDictionary(Of String, String) Dic.Add("'A", "") Dic.Add("A", "") Dic.Add("'B", "") Dic.Add("B", "") Dic.Add("'C", "") Dic.Add("C", "") I would expect ...

SortedList vs. SortedDictionary

This is a continuation of questions like this one. Is there known guidlines for tweek the performance. I don't mean gains in big-O, just saving some linear time. For example, how much does pre-sorting save on either SortedList or SortedDictionary? Say I have a person-class with 3 properties to sort on, one of them is age in years. Sh...

I have a sorted list of key/value pairs, and want to find the values adjacent to a new key

I have a list of key/value pairs (probably will be using a SortedList) and I won't be adding new values. Instead I will be using new keys to get bounding values. For example if I have the following key/value pairs: (0,100) (6, 200), (9, 150), (15, 100), (20, 300) and I have the new key of 7, I want it to return 200 and 150, beca...

vb.net using SortedDictionary as combobox datasource

I have a combobox which i am binding to a sortedDictionary list, so it displays in ascending order. My question is, I need to display "--Select--" as the first option. Is there any way to either: 1) add another item besides for the datasource or 2) add an unsorted item to the top of the sortedDictionary any other ideas welcome as well :...

SortedDictionary add one SortedDictionary into another

I have a requirement where I already have an existing SortedDictionary<string, int>. Now I am creating a different SortedDictionary and like to add this in the first one . How to do it? ...

.NET SortedDictionary But Sorted By Values

I need a data structure that acts like a SortedDictionary<int, double> but is sorted based on the values rather than the keys. I need it to take about 1-2 microseconds to add and remove items when we have about 3000 items in the dictionary. My first thought was simply to switch the keys and values in my code. This very nearly works. ...

How to use custom IComparer for SortedDictionary?

I am having difficulties to use my custom IComparer for my SortedDictionary<>. The goal is to put email addresses in a specific format ([email protected]) as the key, and sort by last name. When I do something like this: public class Program { public static void Main(string[] args) { SortedDictionary<string, string> l...

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...

What's the easiest way to fill gaps in a list of numbers?

Dear reader, I'm having some trouble explaining the question in a single line for the title, but hopefully this description will provide you with enough insight to fully understand my question: I have a few variables in a Word document. Every variable has a Value which is a number (starting from 0 up to the number of variables). A Sort...

How do I divide a list into groups and store the indices?

Dear reader, I have a list box which holds, say, 6 values. Using buttons it's possible to insert new items into the list box. I can move all of these items up and down using other buttons I've added. For the purpose of understanding we'll call the newly created items (which I want to act as groups/dividers) "groups". What I want to acco...

How to create sortedDictionary on class shape ?

Hi i need to write class named "Canvass" that holds a collection of Shapes that together form a drawing base the collection on SortedList class. this collection needs some kind of identification of the object it holds. for that purpose add a ShapeId field of type string to each Shape object. the Shape id value will be defined automatic...

Most Efficient way to find the index of an item in a SortedDictionary

I am using a sorted dictionary to maintain a list of items, of which I regularly need to monitor the state of the top x items. Every time I update an item, I'd like a quick way of figuring out what index the item I'm referring to is using. I understand I can enumerate the entire list and count out my position, but I am looking for someth...