MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / intersect

Function intersect

include/stringzilla/stringzilla.hpp:4810–4826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4808 */
4809template <typename first_type_, typename second_type_, typename first_extractor_, typename second_extractor_>
4810intersect_result_t intersect(first_type_ const &first, second_type_ const &second,
4811 first_extractor_ const &first_extractor, second_extractor_ const &second_extractor,
4812 std::uint64_t seed = 0) noexcept(false) {
4813
4814 std::size_t const max_count = (std::min)(first.size(), second.size());
4815 std::vector<sorted_idx_t> first_positions(max_count);
4816 std::vector<sorted_idx_t> second_positions(max_count);
4817 std::size_t count = 0;
4818 status_t status = try_intersect( //
4819 first, first_extractor, //
4820 second, second_extractor, //
4821 seed, &count, first_positions.data(), second_positions.data());
4822 raise(status);
4823 first_positions.resize(count);
4824 second_positions.resize(count);
4825 return {std::move(first_positions), std::move(second_positions)};
4826}
4827
4828/**
4829 * @brief Locates identical elements in two arrays.

Callers 1

Calls 5

try_intersectFunction · 0.85
raiseFunction · 0.85
resizeMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…