Skip to content

Instantly share code, notes, and snippets.

View AlgorithmsAreCool's full-sized avatar
💭
🐢

AlgorithmsAreCool

💭
🐢
  • Dallas, Tx
View GitHub Profile
@ReubenBond
ReubenBond / FrequencyFilter.cs
Created April 13, 2024 23:07
Filtered Space-Saving
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Orleans.Runtime.Placement.Rebalancing;
// Implementation of "Filtered Space-Saving" from "Finding top-k elements in data streams"
// by Nuno Homem & Joao Paulo Carvalho (https://www.hlt.inesc-id.pt/~fmmb/references/misnis.ref0a.pdf).
internal abstract class FrequencyFilter<TKey>(int capacity) where TKey : notnull
{
@GrabYourPitchforks
GrabYourPitchforks / memory_docs_samples.md
Last active January 20, 2024 13:29
Memory<T> API documentation and samples

Memory<T> API documentation and samples

This document describes the APIs of Memory<T>, IMemoryOwner<T>, and MemoryManager<T> and their relationships to each other.

See also the Memory<T> usage guidelines document for background information.

First, a brief summary of the basic types

  • Memory<T> is the basic type that represents a contiguous buffer. This type is a struct, which means that developers cannot subclass it and override the implementation. The basic implementation of the type is aware of contigious memory buffers backed by T[] and System.String (in the case of ReadOnlyMemory<char>).
@devhawk
devhawk / colorconsole.fs
Created August 4, 2016 17:19
F# Color Console Functions
open System
// helper function to set the console collor and automatically set it back when disposed
let consoleColor (fc : ConsoleColor) =
let current = Console.ForegroundColor
Console.ForegroundColor <- fc
{ new IDisposable with
member x.Dispose() = Console.ForegroundColor <- current }
// printf statements that allow user to specify output color