Laurent grumly57

View BinarySearch.cs
1 2 3 4 5 6 7 8 9 10
namespace System.Collections.Generic
{
public static class ListExtensions
{
/// <summary>
/// Do a binary search in a generic list
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="U"></typeparam>
/// <param name="tf">list</param>
View BiDictionary.cs
1 2 3 4 5 6 7 8 9 10
/// Source: http://stackoverflow.com/questions/268321/bidirectional-1-to-1-dictionary-in-c-sharp
 
/// <summary>
/// This is a dictionary guaranteed to have only one of each value and key.
/// It may be searched either by TFirst or by TSecond, giving a unique answer because it is 1 to 1.
/// </summary>
/// <typeparam name="TFirst">The type of the "key"</typeparam>
/// <typeparam name="TSecond">The type of the "value"</typeparam>
using System.Collections.Generic;
using System;
View TeaFileBinarySearch.cs
1 2 3 4 5 6 7 8 9 10
public static int BinarySearch<T, U>(this TeaFile<T> tf, U target, Func<T, U> indexer) where T : struct
{
var lo = 0;
var hi = (int)tf.Count - 1;
var comp = Comparer<U>.Default;
 
while(lo <= hi)
{
var median = lo + (hi - lo >> 1);
var num = comp.Compare(indexer(tf.Items[median]), target);
View TreeViewExtensions.cs
1 2 3 4 5 6 7 8 9 10
using System.Collections.Generic;
using System.Linq;
 
namespace System.Windows.Forms
{
internal static class TreeViewExtensions
{
internal static List<string> GetExpansionState(this TreeNodeCollection nodes)
{
return nodes.Descendants()
View ZedGraphExtensions.cs
1 2 3 4 5 6 7 8 9 10
public static class ZedGraphExtensions
{
/// <summary>
/// Change the Y axes order
/// </summary>
/// <param name="list">YAxisList</param>
/// <param name="pane">GraphPane</param>
/// <param name="index">index</param>
/// <param name="relativePos">relative position</param>
/// <returns>new index</returns>
View GetUniqueKey.cs
1 2 3 4 5 6 7 8 9 10
public static class Extensions
{
public static string GetUniqueKey(this IEnumerable<string> keys, string prefix, StringComparison comparisonType = StringComparison.InvariantCultureIgnoreCase)
{
int count = 0;
while (keys.FirstOrDefault(k => k.StartsWith(prefix + count, comparisonType)) != null)
count++;
return prefix + count;
}
View MultiSelectTreeView.cs
1 2 3 4 5 6 7 8 9 10
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
 
namespace Graph.UI.Tools
{
public class MultiSelectTreeview : TreeView
{
#region Selected Node(s) Properties
View specialtimer.cs
1 2 3 4 5 6 7 8 9 10
public class SpecialTimer : IDisposable
{
public event Action<object> Elapsed;
 
object timerLock = new object();
 
System.Threading.Timer internalTimer;
 
public SpecialTimer()
{
View ini.cs
1 2 3 4 5 6 7 8 9 10
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
 
public class Ini
{
Dictionary<string, Dictionary<string, string>> ini = new Dictionary<string, Dictionary<string, string>>(StringComparer.InvariantCultureIgnoreCase);
string file;
View MyWebClient.cs
1 2 3 4 5 6 7 8 9 10
public class MyWebClient : WebClient
{
public int Timeout;
 
public MyWebClient()
{
Timeout = 5000;
}
 
public MyWebClient(int timeout)
Something went wrong with that request. Please try again.