Skip to content

Instantly share code, notes, and snippets.

View hesic73's full-sized avatar

Sicheng He hesic73

View GitHub Profile
@gmamaladze
gmamaladze / A_README.md
Last active August 30, 2024 10:12
HashSet that preserves insertion order or .NET implementation of LinkedHashSet

HashSet that preserves insertion order or .NET implementation of LinkedHashSet

Many people naively assume an ordinary .NET HashSet preserves insertion order. Indeed HashSet accidentally preserves insertion order until you remove and re-add some elements. There is such a data structure in Java - LinkedHashSet which respects order and has O(1) RW times.

No, I did not find a (working) corresponding implementation in .NET. That's I wrote this one.

The implementation uses linked list in combination with dictionary to define the iteration, ordering and at the same time allow O(1) removal.

The order is not affected if an element is re-inserted into the set it retains it's old position.

@JcBernack
JcBernack / BigDecimal.cs
Last active September 14, 2024 17:18
BigDecimal
using System;
using System.Numerics;
namespace Common
{
/// <summary>
/// Arbitrary precision decimal.
/// All operations are exact, except for division. Division never determines more digits than the given precision.
/// Source: https://gist.github.com/JcBernack/0b4eef59ca97ee931a2f45542b9ff06d
/// Based on https://stackoverflow.com/a/4524254
@JeanElsner
JeanElsner / mujoco_qt.py
Last active April 10, 2024 01:40
MuJoCo scene rendered in QT (PySide6) with mouse navigation
#!/usr/bin/env python3
from collections import deque
import time
import mujoco
import numpy as np
from PySide6.QtWidgets import (QApplication, QWidget, QMainWindow,
QVBoxLayout, QCheckBox, QGroupBox, QHBoxLayout)
from PySide6.QtCore import QTimer, Qt
from PySide6.QtOpenGLWidgets import QOpenGLWidget
from PySide6.QtOpenGL import QOpenGLWindow