sortedlist

How do I perform a FindAll() on an IList<T>? (eg. SortedList.Values)

I'm working on a problem in C# 2.0/.NET 2.0 where I have a Sortedlist and want to search all the "values" (not the "keys") of this SortedList for a certain substring and count up how many occurrences there are. This is what I'm trying to do: { Sortedlist<string,string> mySortedList; // some code that instantiates mySortedList and...

SortedList not sorting on key - VB.NET

Hello I have a the need for key value pair that I wish to sort so I decided to use a SortedList instead of a HashTable. I am adding the data in the order below to my SortedList which is the order I need it in Key | Value -------------------------------- 1 "700-800" | List(Of Object) 2 "900-1000" | List(Of...

C# Data Structures Question (Which collection to use?)

I need to implement a large collection of Widget objects, each of which contain a unique file path string ("FilePath"). I need to be able to do the following: Retrieve a Widget object quickly given the file path Change the file path of a Widget without creating a new object (multiple other objects may contain references to a single Wi...

best data structure for sorted time series data that can quickly return subarrays?

I'm in need of a datastructure that is basically a list of data points, where each data point has a timestamp and a double[] of data values. I want to be able to retrieve the closest point to a given timestamp or all points within a specified range of timestamps. I'm using c#. my thinking was using a regular list would be possible, wher...

Which is faster to find an item in a hashtable or in a sorted list?

Which is faster to find an item in a hashtable or in a sorted list? ...

.NET / C# - Convert List to a SortedList

What is the best way to convert a List to SortedList? Any good way to do it without cycling through it? Any clever way to do it with an OrderBy()? WRAP UP Please read all answers and comments. ...

c# How to sort a sorted list by its value column

Hi, i have a generic sorted list "results" with key = some filename and value = boolean. I would like to sort the list by the boolean entry or value column. does anyone know how i can do this? Thanks! ...

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

What is the most efficient method for looping through a SortedList in VB 2008?

The code below shows me (I think) that the "for each" loop is about 10% faster than the "i to n" loop, but the "for each" loop creates 567k in new memory? Is this right? Which way is generally most efficient with regards to speed and memory usage? If you want to run this code in VB just add a button and 2 labels to a form. Public Class...

Cycling through a SortedList - Why is this faster?

List1 in the following example is a SortedList(Of MyClass) and contains 251 members. The first two codeblocks execute in 15.5 seconds. 1: For cnt As Integer = 1 To 1000000 For Each TempDE In List1 Dim F As String = TempDE.Key TempDE.Value.x1 = 444 Next Next 2: For cnt As Integer = 1 ...

Is there a non-unique-key sorted list generic collection in C#?

I'm a bit surprised by System.Collections.Generic.SortedList, in that It requires me to use <key, value> instead of <value>(comparer) It only allows on entry per value These seem quirky in the way I want to use it (although I'm sure they're just right for other situations). Is there another collection that doesn't have these two cha...

Query SortedList<Object1,Object2> with Linq

Hi I'm a complete begginer with Linq. And I woild like to know, if it is possible to make a query where for a given Class1.Code I get matching Class2.Value. class Class1() { public string Code; ... } class Class2() { public double Value; ... } SortedList<Class1, Class2> Thank you for your help. ...

Return first element in SortedList in C#

Hello, I have a SorterList in C# and I want to return the first element of the list. I tried using the "First" function but it didnt really work. Can someone please tell me how to do it? Thanks in advance, Greg ...

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

In C#, is there a kind of a SortedList<double> that allows fast querying (with LINQ) for the nearest value?

Hi Stackers, I am looking for a structure that holds a sorted set of double values. I want to query this set to find the closest value to a specified reference value. I have looked at the SortedList<double, double>, and it does quite well for me. However, since I do not need explicit key/value pairs. this seems to be overkill to me, an...

Does ruby have a list type that keeps contents sorted as adds/deletes occur?

I need a datastructure in Ruby that keeps its elements sorted as elements are added or deleted and allows (at least) the ability to pop the first element off the list. The closest thing I've found in the ruby docs is SortedSet. However, this doesn't seem to provide any way to access the elements by their index (or even pop the first el...

Is insertion time complexity of sorted-list implementation of priority queue O(n)?

From wikipedia: Sorted list implementation: Like a checkout line at the supermarket, but where important people get to "cut" in front of less important people. (O(n) insertion time, O(1) get-next time, O(n*log(n)) to build) I think if searching the insert position with binary search algorithm,the insertion time complexity...

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

LINQ from SortedList C#

I'm fairly new to C#, and completely new to LINQ. I have an existing object of type SortedList, which I would like to filter through using LINQ. However I appear to be having issues with this, apparently as the SortedList type is not generic. For the timebeing I've looped through the entire SortedList and manually added the objects wit...

Why is the SortedList(TKey,TValue).Keys property an IList(TKey) rather than a ReadOnlyCollection(TKey)?

The IList<T> interface includes access by index in addition to operations not supported by the SortedList<TKey, TValue>.Keys property such as Add, Remove, and Insert. A ReadOnlyCollection<T>, such as the return value of List<T>.AsReadOnly, implements IList<T> and therefore offers access by index but hides illegal operations like Add, et...