Aller au contenu
Bienvenue sur la nouvelle documentation de CppUtils !

Namespace: CppUtils::Container::Sequence

enum class Difference {
None = 0,
Added,
Removed,
Edited
};
template <Type::SizedRandomAccessRange Range0, Type::SizedRandomAccessRange Range1, class Comparator = std::ranges::equal_to, class FirstProjection = std::identity, class SecondProjection = std::identity>
constexpr auto getDifferences(const Range0& list0, const Range1& list1, Comparator comparator={}, FirstProjection firstProjection={}, SecondProjection secondProjection={}) -> std::vector<Difference>;

Computes element-wise differences between two random-access ranges.

Supports any random-access sized ranges (e.g. std::string, std::string_view, std::vector, std::span), optional custom element comparator, and projections for both ranges.

Voir aussi : Longest common subsequence

Paramètre templateDescription
Range0Type of the first range (must satisfy Type::SizedRandomAccessRange).
Range1Type of the second range (must satisfy Type::SizedRandomAccessRange).
ComparatorBinary predicate comparing elements.
FirstProjectionProjection applied to elements of the first range.
SecondProjectionProjection applied to elements of the second range.
ParamètreDescription
list0First range to compare.
list1Second range to compare.
comparatorCustom comparison predicate (defaults to std::ranges::equal_to).
firstProjectionProjection callable for list0 (defaults to std::identity).
secondProjectionProjection callable for list1 (defaults to std::identity).

Retourne : Vector of Difference values detailing added, removed, or identical elements.