コード例 #1
0
CubantCore::VectorImpl
CubantCore::VectorImpl::
farEdge(const VectorImpl& lhs, const VectorImpl& rhs) {
        if (lhs.size()!=rhs.size()) {
        throw cubant_exception("Can't far-egde different-sized cubants");
    }
    unsigned int size=lhs.size();
    VectorImpl result(size);
    for (unsigned int i=0;i<size;++i) {
        if (CubantType::Nothing==lhs[i].getType() ||
            CubantType::Nothing==rhs[i].getType()) {
            throw cubant_exception("Can't far-egde pseudo cubants");
        }
        if (CubantType::NoShift==lhs[i].getType()) {
            result[i].setType(CubantType::NoShift);
        } else if (CubantType::Shift==lhs[i].getType()) {
            result[i].setType(CubantType::Shift);
        } else if (CubantType::Spread==lhs[i].getType()) {
            if (CubantType::NoShift==rhs[i].getType()) {
                result[i].setType(CubantType::Shift);
            } else if (CubantType::Shift==rhs[i].getType()) {
                result[i].setType(CubantType::NoShift);
            } else {
                result[i].setType(CubantType::Spread);
            }
        }
        //result[i].setType(lhs[i].getType()&rhs[i].getType());
    }
    return result;
}
コード例 #2
0
ssize_t VectorImpl::insertVectorAt(const VectorImpl& vector, size_t index)
{
    if (index > size())
        return BAD_INDEX;
    void* where = _grow(index, vector.size());
    if (where) {
        _do_copy(where, vector.arrayImpl(), vector.size());
    }
    return where ? index : (ssize_t)NO_MEMORY;
}
コード例 #3
0
// FIXME must be template
CubantCore::VectorImpl
CubantCore::VectorImpl::
intersect(const VectorImpl& lhs, const VectorImpl& rhs) {
    if (lhs.size()!=rhs.size()) {
        throw cubant_exception("Can't intersect different-sized cubants");
    }
    unsigned int size=lhs.size();
    VectorImpl result(size);
    for (unsigned int i=0;i<size;++i) {
        // we use binary
        result[i].setType(lhs[i].getType()&rhs[i].getType());
    }
    return result;
}
コード例 #4
0
ssize_t SortedVectorImpl::merge(const VectorImpl& vector)
{
    // naive merge...
    if (!vector.isEmpty()) {
        const void* buffer = vector.arrayImpl();
        const size_t is = itemSize();
        size_t s = vector.size();
        for (size_t i=0 ; i<s ; i++) {
            ssize_t err = add( reinterpret_cast<const char*>(buffer) + i*is );
            if (err<0) {
                return err;
            }
        }
    }
    return NO_ERROR;
}
コード例 #5
0
ssize_t VectorImpl::insertVectorAt(const VectorImpl& vector, size_t index)
{
    return insertArrayAt(vector.arrayImpl(), index, vector.size());
}