if (x1GEx and x2GEx) or ((x1GEx or x2GEx) and
                                         (int64(y2) - int64(y)) *
                                         (int64(x2) - int64(x1)) >=
                                         (int64(y2) - int64(y1)) *
                                         (int64(x2) - int64(x))):
                    contained = not contained

        y1 = y2
        y_gt_y1 = y_gt_y2
        i += 1

    return contained


# @cc.export('all_the_same', i2(u8, u8, u2[:]))
@njit(i2(u8, u8, u2[:]), cache=True)
def all_the_same(pointer, length, id_list):
    """
    :param pointer: starting from that element the list is being checked for equality of its elements
    :param length:
    :param id_list: List mustn't be empty or Null. There has to be at least one element
    :return: returns the first encountered element if starting from the pointer all elements are the same,
     otherwise it returns -1
    """
    element = id_list[pointer]
    pointer += 1
    while pointer < length:
        if element != id_list[pointer]:
            return -1
        pointer += 1
    return element
                x1GEx = x <= x1
                x2GEx = x <= x2
                if (x1GEx and x2GEx) or ((x1GEx or x2GEx)
                                         and (int64(y2) - int64(y)) * (int64(x2) - int64(x1)) >= (
                                             int64(y2) - int64(y1)) * (int64(x2) - int64(x))):
                    contained = not contained

        y1 = y2
        y_gt_y1 = y_gt_y2
        i += 1

    return contained


# @cc.export('all_the_same', i2(u8, u8, u2[:]))
@njit(i2(u8, u8, u2[:]), cache=True)
def all_the_same(pointer, length, id_list):
    """
    :param pointer: starting from that element the list is being checked for equality of its elements
    :param length:
    :param id_list: List mustn't be empty or Null. There has to be at least one element
    :return: returns the first encountered element if starting from the pointer all elements are the same,
     otherwise it returns -1
    """
    element = id_list[pointer]
    pointer += 1
    while pointer < length:
        if element != id_list[pointer]:
            return -1
        pointer += 1
    return element
                # only crossings "right" of the point should be counted
                x1GEx = x <= x1
                x2GEx = x <= x2
                if (x1GEx and x2GEx) or ((x1GEx or x2GEx)
                                         and int64(y2 - y) * int64(x2 - x1) >=
                                         int64(y2 - y1) * int64(x2 - x)):
                    contained = not contained

        y1 = y2
        y_gt_y1 = y_gt_y2
        i += 1
    return contained


# @cc.export('all_the_same', i2(u8, u8, u2[:]))
@jit(i2(u8, u8, u2[:]), nopython=True, cache=True)
def all_the_same(pointer, length, id_list):
    """
    :param pointer: starting from that element the list is being checked for equality of its elements
    :param length:
    :param id_list: List mustn't be empty or Null. There has to be at least one element
    :return: returns the first encountered element if starting from the pointer all elements are the same,
     otherwise it returns -1
    """
    element = id_list[pointer]
    pointer += 1
    while pointer < length:
        if element != id_list[pointer]:
            return -1
        pointer += 1
    return element
Exemple #4
0
def get_s16(buf, offset, length):
    if length < 2:
        return (0, offset, length)
    msb = nb.i2(buf[offset + 1]) << 8
    lsb = nb.i2(buf[offset + 0]) << 0
    return msb | lsb, offset + 2, length - 2