Example #1
0
std::set<void*> SearchTree::search(const unsigned char* const p_inputString,
                                          const std::size_t p_inputLength)
{
    assert(m_ready && p_inputString != NULL);

    std::set<void*> returnValue;
    SearchNode* currentNode = &m_rootNode;
    const unsigned char* end = p_inputString + p_inputLength;
    for (const unsigned char* start = p_inputString; start < end; ++start)
    {
        currentNode = currentNode->getNext(*start);
        if (!currentNode->getStoredData().empty())
        {
            const std::set<void*>& mergeThis(currentNode->getStoredData());
            returnValue.insert(mergeThis.begin(), mergeThis.end());
        }
    }

    return returnValue;
}
Example #2
0
std::set<const char*> SearchTree::findOffsets(const char* const p_inputString,
                                              const std::size_t p_inputLength)
{
    std::set<const char*> returnValue;
    SearchNode* currentNode = &m_rootNode;
    const char* end = p_inputString + p_inputLength;
    for (const char* start = p_inputString; start < end; ++start)
    {
        currentNode = currentNode->getNext(*start);
        if (!currentNode->getStoredData().empty())
        {
            returnValue.insert(start - 3);
        }
    }
    return returnValue;
}