Conjuntos is a library I started in 2014 to represent mathematical sets in C++. The idea was to make operations resemble their mathematical definitions while applying them to different element types through templates.

One interface for different data#

The Conjunto<P> class can be constructed from arrays or vectors. It supports adding elements, checking membership and naming a set. Before adding an element, it checks whether that element is already present: uniqueness is part of the representation.

The implementation preserves union, intersection, difference and symmetric difference methods, together with equality, subset and proper-subset checks. Operator overloads provide a more compact notation for parts of the interface.

From a definition to an implementation#

An intersection cannot simply concatenate two collections: it needs membership checks and a rule for deciding which elements to keep. A difference changes that condition; a symmetric difference combines exclusions from both sides. The library makes those decisions inspectable in a relatively small amount of code.

The repository also contains work on complements and Cartesian products. It is an early archive, with parts that need review before reuse. It is not a finished general-purpose library.