@classmethod
def __computeFailure(cls, pattern):
    """Computes the failure function using a boot-strapping process, where the
        pattern is matched against itself.

        pattern : Pattern to search.
        Returns Failure pattern.
        """
    failure = bytearray(len(pattern))
    j = 0
    for i in range(1, len(pattern)):
        while j > 0 and pattern[j] != pattern[i]:
            j = failure[j - 1]
        if pattern[j] == pattern[i]:
            j = j + 1
        failure[i] = j
    return failure
