Last active
December 23, 2015 05:49
-
-
Save ChadSki/6590170 to your computer and use it in GitHub Desktop.
Zorgiepoo
This file contains hidden or 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
| 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) | |
| { | |
| ZGMemorySize maxSteps = 4096; | |
| ZGMemorySize numSteps = (endLimit - dataIndex) / dataAlignment; | |
| assert(numSteps < maxSteps); | |
| P memoryAddresses[maxSteps]; | |
| ZGMemorySize numberOfVariablesFound = 0; | |
| while (numSteps--) | |
| { | |
| if (comparisonFunction(searchData, (T *)((int8_t *)bytes + dataIndex), searchValue)) | |
| { | |
| memoryAddresses[numberOfVariablesFound] = (P)(address + dataIndex); | |
| numberOfVariablesFound++; | |
| } | |
| dataIndex += dataAlignment; | |
| } | |
| [resultSet appendBytes:&memoryAddress length:pointerSize]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment