View source code
							
							
						
								Display the source code in std/algorithm/setops.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								Improve this page
							
							
					
								Quickly fork, edit online, and submit a pull request for this page.
								Requires a signed-in GitHub account. This works well for small changes.
								If you'd like to make larger changes you may want to consider using
								local clone.
							
						Function std.algorithm.setops.largestPartialIntersection
Given a range of sorted forward ranges
ror, copies to tgt the elements that are common to most ranges, along with their number
of occurrences. All ranges in ror are assumed to be sorted by less. Only the most frequent tgt elements are returned.
						
				void largestPartialIntersection(alias less, RangeOfRanges, Range)
				(
				
				  RangeOfRanges ror,
				
				  Range tgt,
				
				  SortOutput sorted = No
				);
						
					
				Parameters
| Name | Description | 
|---|---|
| less | The predicate the ranges are sorted by. | 
| ror | A range of forward ranges sorted by less. | 
| tgt | The target range to copy common elements to. | 
| sorted | Whether the elements copied should be in sorted order.
The function largestPartialIntersectionis useful for
e.g. searching an inverted index for the documents most
likely to contain some terms of interest. The complexity of the search
is Ο(n * log(tgt), wherenis the sum of lengths of
all input ranges. This approach is faster than keeping an associative
array of the occurrences and then selecting its top items, and also
requires less memory (largestPartialIntersectionbuilds its
result directly intgtand requires no extra memory).
If at least one of the ranges is a multiset, then all occurences
of a duplicate element are taken into account. The result is
equivalent to merging all ranges and picking the most frequenttgtelements. | 
Warning
Because largestPartialIntersection does not allocate
extra memory, it will leave ror modified. Namely, largestPartialIntersection assumes ownership of ror and
discretionarily swaps and advances elements of it. If you want ror to preserve its contents after the call, you may want to pass a
duplicate to largestPartialIntersection (and perhaps cache the
duplicate in between calls).
Example
import stdAuthors
License
					Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.