[PATCH] D40427: [ADT] Introduce Disjoint Set Union structure

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 24 04:41:33 PST 2017


mkazantsev created this revision.
Herald added a subscriber: mgorny.

This patch introduces a data structure - Disjoint Set Union - that allows to perform
operations on disjoint sets of elements:

1. Check whether two elements `X` and `Y` belong to one set;
2. Merge sets containing `X` and `Y` into one set.

If we have a transitive symmetrical equivalence function `F`, and we proved that `F(X, Y)`
and `F(Y,Z)` is `true`, then adding these two pairs to DSU will also allow us to prove that
`F(Z, X)` is `true` for cheap. One possible application of that is using it as cache for
comparators: if we proved that `X compareTo Y == 0` and `Y compareTo Z == 0`, then
DSU can easily prove that `X compareTo Z == 0`.


https://reviews.llvm.org/D40427

Files:
  include/llvm/ADT/DisjointSetUnion.h
  unittests/ADT/CMakeLists.txt
  unittests/ADT/DisjointSetUnionTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40427.124161.patch
Type: text/x-patch
Size: 7723 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171124/20e46142/attachment.bin>


More information about the llvm-commits mailing list