Skip to content

Instantly share code, notes, and snippets.

@zorgiepoo
Created September 17, 2013 04:21
Show Gist options
  • Save zorgiepoo/6590044 to your computer and use it in GitHub Desktop.
Save zorgiepoo/6590044 to your computer and use it in GitHub Desktop.
template <typename T, typename P>
void ZGSearchWithFunctionHelperDirect(T *searchValue, bool (*comparisonFunction)(ZGSearchData *, T *, T *), ZGSearchData * __unsafe_unretained searchData, ZGMemorySize dataIndex, ZGMemorySize dataSize, ZGMemorySize dataAlignment, ZGMemorySize endLimit, P pointerSize, NSMutableData * __unsafe_unretained resultSet, ZGMemoryAddress address, void *bytes)
{
//dataIndex is 'position' in the data, endLimit is (region_size) - (datatype_size)
//dataAlignment is amount to advance dataIndex for each iteration
while (dataIndex <= endLimit)
{
if (comparisonFunction(searchData, (T *)((int8_t *)bytes + dataIndex), searchValue))
{
P memoryAddress = (P)(address + dataIndex);
[resultSet appendBytes:&memoryAddress length:pointerSize];
}
dataIndex += dataAlignment;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment