Created
March 5, 2014 22:39
-
-
Save lemire/9378174 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size_t | |
compute_intersection (const uint32_t * rare, | |
const size_t nrare, const uint32_t * freq, const size_t nfreq, uint32_t * out) { | |
UINT4 goal; | |
const UINT4 *stop_rare; | |
UINT4 *init_out; | |
long j; | |
long nfreqleft = static_cast<int>(nfreq);// possibly unsafe if nfreq exceeds the range of longs | |
init_out = out; | |
stop_rare = &(rare[nrare]); | |
while (rare < stop_rare) { | |
goal = *rare++; | |
j = FINDFUNCTION(goal,freq,nfreqleft); | |
if (j >= nfreqleft) { | |
return (out - init_out); | |
} else if (freq[j] == goal) { | |
*out++ = goal; | |
} | |
freq += j; | |
nfreqleft -= j; | |
} | |
return (out - init_out); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment