This file contains 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
open System.Diagnostics | |
let time f = | |
let proc = Process.GetCurrentProcess() | |
let cpu_time_stamp = proc.TotalProcessorTime | |
let timer = new Stopwatch() | |
timer.Start() | |
try | |
f() | |
finally |
This file contains 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
public HashSet<T> BFS<T>(Graph<T> graph, T start) { | |
var visited = new HashSet<T>(); | |
if (!graph.AdjacencyList.ContainsKey(start)) | |
return visited; | |
var queue = new Queue<T>(); | |
queue.Enqueue(start); | |
while (queue.Count > 0) { |
This file contains 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
class MergeSort | |
{ | |
public static void MergeSort(int[] input, int low, int high) | |
{ | |
if (low < high) | |
{ | |
int middle = (low + high) / 2; | |
MergeSort(input, low, middle); | |
MergeSort(input, middle + 1, high); | |
Merge(input, low, middle, high); |
This file contains 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
private void ReCalculateDown() | |
{ | |
int index = 0; | |
while (HasLeftChild(index)) | |
{ | |
var biggerIndex = GetLeftChildIndex(index); | |
if (HasRightChild(index) && GetRightChild(index) > GetLeftChild(index)) | |
{ | |
biggerIndex = GetRightChildIndex(index); | |
} |
This file contains 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
public class MinHeap | |
{ | |
private readonly int[] _elements; | |
private int _size; | |
public MinHeap(int size) | |
{ | |
_elements = new int[size]; | |
} |
This file contains 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
public static void quickSort(int[] A, int left, int right) | |
{ | |
if(left > right || left <0 || right <0) return; | |
int index = partition(A, left, right); | |
if (index != -1) | |
{ | |
quickSort(A, left, index - 1); | |
quickSort(A, index + 1, right); |
This file contains 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
function initComponent<TValue, TComponent extends FieldEditorComponent<TValue>>(c: { new (...args: any[]): TComponent }, | |
wellKnownField: WellKnownField, | |
criteriaValue: any, | |
valueChangeHandler: (e: FieldEditorValueChangeEvent<TValue>) => void | |
): TestCtx<TComponent> { | |
let testCtx = createTestContext(c); | |
tick(); | |
let field = (<MatterContext>TestBed.get(MatterContext)).matterDefinition!.fieldsDefinition.getWellKnownField(wellKnownField); | |
let fc = FieldCriteriaFactory.buildCriteria(field, SearchFieldOperator.EQ, criteriaValue); | |
(<any>testCtx.component).value = fc.value; |
This file contains 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
module Array = | |
open System.Collections.Generic | |
let toMap<'TItem when 'TItem : equality> array = | |
let map = array |> Seq.fold (fun (map: Dictionary<'TItem, int>) ch -> | |
if map.ContainsKey(ch) then | |
map.[ch] <- map.[ch] + 1 | |
else | |
map.Add(ch, 1) |
This file contains 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
... | |
frameworks: [ | |
'parallel', | |
'jasmine' | |
], | |
plugins: [ | |
"karma-jasmine", | |
"karma-chrome-launcher", | |
"karma-junit-reporter", | |
"karma-spec-reporter", |
This file contains 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
describe('#productions Production wizard bates settings', () => { | |
configureTestSuite(); | |
beforeAll(done => (async () => { | |
TestBed.configureTestingModule({ | |
imports: modules, | |
providers: [defaultGlobalProvidersForTests] | |
}); |
NewerOlder