Exemplo n.º 1
0
pBtree SpecialInsert(pBtree root,int key)
{
	if(root->Sum==(MAX<<1)-1)
	{
		root=SplitRoot(root);
	}
	NormalInsert(root,key);
	return root;
}
Exemplo n.º 2
0
void InsertTree(char *Key, TEXTPTR TextOffset) {
    struct upKey *MiddleKey;
    KEYLEN keyLen;

    /* Print an error message if the key is too long */
    keyLen = strlen(Key);
    if ((keyLen > MAXWORDSIZE) ||
        (keyLen > (PAGESIZE - sizeof(struct PageHdr) - sizeof(POSTINGSPTR) -
                   sizeof(KEYLEN)))) {
        printf("ERROR: key is too long-operation aborted\n");
        printf("offending key:\"%s\"\n", Key);
        return;
    }

    /* insert key */
    MiddleKey = PropagatedInsertion(ROOT, Key, TextOffset);

    /* The Root Must be Split */
    if (MiddleKey != NULL)
        SplitRoot(ROOT, MiddleKey);

    iCount++;
}