/*---------------------------------------------------------------------------- InsertHandler ----------------------------------------------------------------------------*/ void AEDispatchTree::InsertHandler(DescType handlerClass, AEGenericClass *handler, Boolean isDuplicate /* = false */) { AEDispatchHandler *newHandler = new AEDispatchHandler(handlerClass, handler, !isDuplicate); unsigned char key[5] = {0}; int result; *(DescType *)key = handlerClass; result = PatriciaInsert(mTree, nil, key, newHandler, nil); if (result == kDuplicateKeyError || result == 1) { ThrowIfOSErr(kDuplicateKeyError); } else if (result != 0) { ThrowIfOSErr(result); } }
/*---------------------------------------------------------------------------- InsertNode Insert a node. Call the class's replace function by default. Returns true if replaced ----------------------------------------------------------------------------*/ Boolean CPatriciaTree::InsertNode(TPatriciaKey key, CPatriciaNode* nodeData) { int result = PatriciaInsert(mTree, NodeReplaceCallback, key, (void *)nodeData, (void *)this); return (result == 1); }