public boolean remove()

in java/src/main/java/com/epam/deltix/containers/SortedSqrtDecomposition.java [207:248]


    public boolean remove(T x) {
        boolean delete = false;
        if (needRebuild) {
            rebuildSqrt();
        }
        for (int j = 1; j < numberOfBlocks; ++j) {
            if (comparator.compare((T) dataInBegin[j], x) > 0) {
                for (int k = (len * (j - 1) << 1); k < endOfBlock[j - 1]; ++k) {
                    if (comparator.compare((T)data[k], x) == 0) {
                        if (k == (len * (j - 1) << 1)) dataInBegin[j - 1] = data[k + 1];
                        for (int l = k; l < endOfBlock[j - 1] - 1; l++) {
                            data[l] = data[l + 1];
                        }
                        endOfBlock[j - 1]--;
                        size--;
                        if (endOfBlock[j - 1] <= (len * (j - 1) << 1)) {
                            rebuildSqrt();
                        };
                        return true;
                    }
                }
                return false;
            }
        }
        if (!delete) {
            for (int k = (len * (numberOfBlocks - 1) << 1); k < endOfBlock[numberOfBlocks - 1]; k++) {
                if (comparator.compare((T) data[k], x) == 0) {
                    if (k == (len * (numberOfBlocks - 1)) << 1) dataInBegin[numberOfBlocks - 1] = data[k + 1];
                    for (int l = k; l < endOfBlock[numberOfBlocks - 1] - 1; l++) {
                        data[l] = data[l + 1];
                    }
                    endOfBlock[numberOfBlocks - 1]--;
                    size--;
                    if (endOfBlock[numberOfBlocks - 1] <= (len * (numberOfBlocks - 1) << 1)) {
                        rebuildSqrt();
                    }
                    return true;
                }
            }
        }
        return false;
    }