void LR0ItemCollectionFamily::build()
{
    set<int> unhandled;
    {
        LR0ItemCollection col;
        col.insert(LR0Item(0, 0));
        int ID;
        insertCollection(col, ID);
        unhandled.insert(ID);
    }
    while (!unhandled.empty()) {
        int ID = *unhandled.begin();
        unhandled.erase(unhandled.begin());
        for (auto sym : g_symolList) {
            LR0ItemCollection newCol;
            auto& col = ID2Collection[ID];
            for (auto item : col) {
                auto &body = getProductBody(item.productID);
                if (item.pos < body.size() && body[item.pos] == sym) {
                    newCol.insert(LR0Item(item.productID, item.pos + 1));
                }
            }
            if (newCol.empty()) continue;
            int newID;
            if (insertCollection(newCol, newID)) {
                unhandled.insert(newID);
            }
            transMap[ID][sym] = newID;
        }
    }
    removeCore();
}
Exemple #2
0
 bool BTree::remove(const Key& key) {
     std::vector<int> tr;
     bool found;
     PageDB::Location loc;
     trace(key, &tr, found, loc);
     if (!found)
         return false;
     auto me = BTreeConstIterator(pgdb, file, loc);
     auto next = BTreeIterator(pgdb, file, me.Info().next);
     auto prev = BTreeIterator(pgdb, file, me.Info().prev);
     prev.Info().next = next.loc;
     next.Info().prev = prev.loc;
     removeCore(key, tr);
     return true;
 }