liveBook · Manning

Set operation

As explained in Data-Oriented Programming in Java

A set operation is an operation that combines or compares collections according to set membership, such as intersection, union, or difference.

Set operations combine or compare collections by membership. They replace roundabout loops and branches with questions such as which items overlap, remain, or should be combined. section 9.3.4

Merging cart items

Incoming items intersecting the saved cart are promoted, active items are combined with incoming items, and saved items are reduced by difference. The result is a new cart rather than a mutation.

How Data-Oriented Programming in Java covers it

How deep it goes
Descends from algebraic visualization to Java utilities for intersecting, uniting, and excluding map entries.
Examples
Uses cart requirements, overlapping active and saved items, and Java map utilities as concrete examples.
What it assumes
Assumes familiarity with maps, loops, and immutable data while deriving set reasoning from a containment problem.
What you can do after
Build it from scratch with Java map utilities that express overlap, combination, exclusion, and immutable cart updates.
How it connects
Connects immutable data, maps, intersection, union, difference, and algebraic reasoning.

Also explained in

Compare how 3 books explain set operation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming in Java. The section links point to the parts of the book it draws on.