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

Function try_intersect

include/stringzilla/stringzilla.hpp:4707–4734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4705 */
4706template <typename first_container_, typename second_container_, typename first_extractor_, typename second_extractor_>
4707status_t try_intersect( //
4708 first_container_ const &first_container, first_extractor_ const &first_extractor, //
4709 second_container_ const &second_container, second_extractor_ const &second_extractor, //
4710 std::uint64_t seed, std::size_t *intersection_size_ptr, //
4711 sorted_idx_t *first_positions, sorted_idx_t *second_positions) noexcept {
4712
4713 // Pack the arguments into a single structure to reference it from the callback.
4714 using first_t = sequence_args_<first_container_, first_extractor_>;
4715 using second_t = sequence_args_<second_container_, second_extractor_>;
4716 first_t first_args {first_container, first_extractor};
4717 second_t second_args {second_container, second_extractor};
4718
4719 sz_sequence_t first_sequence, second_sequence;
4720 first_sequence.count = first_container.size(), second_sequence.count = second_container.size();
4721 first_sequence.handle = &first_args, second_sequence.handle = &second_args;
4722 first_sequence.get_start = call_sequence_member_start_<first_container_, first_extractor_>;
4723 first_sequence.get_length = call_sequence_member_length_<first_container_, first_extractor_>;
4724 second_sequence.get_start = call_sequence_member_start_<second_container_, second_extractor_>;
4725 second_sequence.get_length = call_sequence_member_length_<second_container_, second_extractor_>;
4726
4727 using sz_alloc_type = sz_memory_allocator_t;
4728 return _with_alloc<std::allocator<sz_u8_t>>([&](sz_alloc_type &alloc) {
4729 static_assert(sizeof(sz_size_t) == sizeof(std::size_t), "sz_size_t must be the same size as std::size_t.");
4730 return sz_sequence_intersect(&first_sequence, &second_sequence, &alloc, static_cast<sz_u64_t>(seed),
4731 reinterpret_cast<sz_size_t *>(intersection_size_ptr), first_positions,
4732 second_positions);
4733 });
4734}
4735
4736#if !SZ_AVOID_STL
4737#if _SZ_DEPRECATED_FINGERPRINTS

Callers 1

intersectFunction · 0.85

Calls 2

sz_sequence_intersectFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…