Skip to content

Augment basic data structure [mp]

Micro pattern

Description

Store extra metadata or combine structures so ordinary operations also maintain information needed for faster queries.

Problems

Store aggregate state with each item

Attach a summary of the processed state to each stored item.

Store traversal state with each node

Pair a node with contextual state needed when it is processed.

Combine complementary structures

Use structures with different strengths together to support efficient operations.

Encode multiple states in one value

Reserve separate bits or fields for states that must coexist during an update.