Example #1
0
bool StructureSet::isSubsetOf(const StructureSet& other) const
{
    if (isThin()) {
        if (!singleStructure())
            return true;
        return other.contains(singleStructure());
    }

    if (other.isThin()) {
        if (!other.singleStructure())
            return false;
        OutOfLineList* list = structureList();
        if (list->m_length >= 2)
            return false;
        if (list->list()[0] == other.singleStructure())
            return true;
        return false;
    }

    OutOfLineList* list = structureList();
    for (unsigned i = 0; i < list->m_length; ++i) {
        if (!other.containsOutOfLine(list->list()[i]))
            return false;
    }
    return true;
}
Example #2
0
void StructureSet::exclude(const StructureSet& other)
{
    if (other.isThin()) {
        if (other.singleStructure())
            remove(other.singleStructure());
        return;
    }

    if (isThin()) {
        if (!singleStructure())
            return;
        if (other.contains(singleStructure()))
            clear();
        return;
    }

    OutOfLineList* list = structureList();
    for (unsigned i = 0; i < list->m_length; ++i) {
        if (!other.containsOutOfLine(list->list()[i]))
            continue;
        list->list()[i--] = list->list()[--list->m_length];
    }
    if (!list->m_length)
        clear();
}