This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
/// <summary> | |
/// Special dictionary for aggregating values | |
/// </summary> | |
public class Aggregator<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>> | |
{ | |
private Dictionary<TKey, TValue> _values = new Dictionary<TKey, TValue>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The code posted at https://blogs.msdn.microsoft.com/xmlteam/2007/03/24/streaming-with-linq-to-xml-part-2/ | |
// will skip every other element with compressed XML. This occurs because the reader after ReadFrom | |
// is already positioned on the next node and then the reader.Read() will move it to the node afterwards. | |
// The logic in this snippet fixes the problem. | |
internal static IEnumerable<XElement> StreamElements(Stream stream, XName matchName) | |
{ | |
using (var reader = XmlReader.Create(stream)) | |
{ | |
reader.MoveToContent(); | |
var continueNoRead = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
public static class FormatExtensions | |
{ | |
public static string ToPrecision(this int value, int digits, string format = "") | |
{ | |
return SigFigFormatProvider.Instance.Format("s" + digits.ToString() + format, value, null); | |
} | |
public static string ToPrecision(this double value, int digits, string format = "") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ternary Search Tree Implementation for C# | |
// | |
// Rewritten by Eric Domke | |
// | |
// Code adapted from implementation by Jonathan de Halleux | |
// at http://www.codeproject.com/Articles/5819/Ternary-Search-Tree-Dictionary-in-C-Faster-String | |
// | |
// Rewrite focused on | |
// - removing fields from the TstDictionaryEntry class to reduce memory usage | |
// - decreasing the number of nodes to reduce memory usage (used some of the |
NewerOlder