在分布式系统中希望能够生成一个随时间增长的唯一 ID,这时可以用 Snow Flake(雪花算法)实现。
Go 单例模式 sync.Once
Posted on
Go 的单例可以用 sync.Once 简单实现:
Java LongAdder
Posted on
jdk8 新增了原子操作类 LongAdder,它对标 AtomicLong,提高了多 CPU 并发下的效率,在这里记录一下。
Binary Search, Lower Bound, Upper Bound
Posted on
“Although the basic idea of binary search is comparatively straightforward, the details can be surprisingly tricky.”
– Donald Knuth
Algorithm Random
Posted on
记录 Random 的算法实现
Algorithm Reservoir Sampling(蓄水池抽样)
Posted on
Reservoir Sampling(蓄水池抽样)可以简单的从大量流式数据中随机抽取指定数量的样本,并且保证样本被取到的概率相同,适合大数据分析场景。
Algorithm Sort
Posted on
记录 Sort 的算法实现
Algorithm Segment Tree
Posted on
记录 Segment Tree 的算法实现
Algorithm Minimax
Posted on
记录 Minimax 的算法实现
Algorithm Line Sweep
Posted on
记录 Line Sweep 的算法实现