Code Explainers
Code explainers tagged #data-structures
go
package scheduler import ( "container/heap"
A priority job queue with Go's container/heap
priority-queue
heap
interfaces
Intermediate
9 steps
php
<?php namespace App\Queue;
A stable priority job queue in PHP
priority-queue
data-structures
closures
Intermediate
8 steps
php
final class BitmapGrid { private SplFixedArray $cells;
A flat-array bitmap grid in PHP
data-structures
row-major-order
bitmap
Intermediate
7 steps
ruby
class LRUCache def initialize(capacity) raise ArgumentError, "capacity must be positive" unless capacity.positive?
How an LRU cache works in Ruby
caching
eviction
hash-ordering
Intermediate
7 steps
ruby
class QueryParser def self.parse(query_string) new(query_string).parse end
Parsing nested query strings in Ruby
parsing
recursion
tokenization
Intermediate
9 steps
javascript
class HistoryStack { constructor(initial = '', limit = 100) { this.past = []; this.present = initial;
Building an undo/redo history stack
undo-redo
state-management
debouncing
Intermediate
7 steps
python
from collections import OrderedDict from typing import Any, Hashable, Optional
Building an LRU cache with OrderedDict
caching
eviction
data-structures
Intermediate
6 steps
php
<?php function buildTree(array $items, ?int $parentId = null): array {
Building a tree from a flat list in PHP
recursion
tree
grouping
Intermediate
6 steps
typescript
export class PriorityQueue<T> { private heap: Array<{ value: T; priority: number }> = []; get size(): number {
Building a binary-heap priority queue in TypeScript
binary-heap
priority-queue
generics
Intermediate
9 steps
go
package cache import ( "container/list"
Building a generic LRU cache in Go
lru-cache
generics
linked-list
Intermediate
8 steps
java
public class UnionFind { private final int[] parent; private final int[] rank; private int count;
How union-find with path compression works
disjoint-set
path-compression
union-by-rank
Intermediate
7 steps
javascript
class Stack { #items = []; push(value) {
Building a Stack with private fields
data-structures
encapsulation
iterators
Intermediate
7 steps
python
from collections import Counter def word_frequencies(text):
Counting things with collections.Counter
counting
multiset
data-structures
Beginner
8 steps
ruby
class LinkedList include Enumerable Node = Struct.new(:value, :next_node)
Building an enumerable linked list in Ruby
linked-list
enumerable
data-structures
Intermediate
7 steps
typescript
class LRUCache<K, V> { private readonly capacity: number; private readonly map: Map<K, V>;
Building an LRU cache on a JS Map
caching
data-structures
generics
Intermediate
8 steps