示例#1
0
static BSNode* _findNode(BSNode* node, int key)
{
	if (node) {
		int i = 1;
		for(; i <= node->keyNum; ++i) {
			if (key == node->keys[i])
				return node;
			else if (key < node->keys[i])
				return _findNode(node->children[i-1], key);
		}
		return _findNode(node->children[i-1], key);
	}
	return NULL;
}
示例#2
0
void* BinaryTree_find(BinaryTree* self, void* item)
{
    smug_assert(_invariant(self));
    BinaryTreeNode* node;
    _findNode(self, item, &node);
    return node == NULL ? NULL : node->item;
}
示例#3
0
//进库
void _importItem(const pItemNode head)
{
	_insertNodeFromStdin(head);
	//查看是否为已有的货物
	int countNode = -1;
	if ((countNode = _findNode(head, &__compFuncImport, __bottomNode(head)->item)) != 0)
	{
		//排除新添加的货物
		if (__isNodeExist(head, countNode) != __bottomNode(head))
		{
			__bottomNode(head)->item.itemNumber += _impleFunction(head, &__returnItemNumber, countNode);
			_deleteNode(head, countNode);
		}
	}
	printf("Successfully import.\n");
}
示例#4
0
bool Config::_cmdDestroyNode( co::Command& command ) 
{
    const ConfigDestroyNodePacket* packet =
        command.get<ConfigDestroyNodePacket>();
    EQVERB << "Handle destroy node " << packet << std::endl;

    Node* node = _findNode( packet->nodeID );
    EQASSERT( node );
    if( !node )
        return true;

    NodeConfigExitReplyPacket reply( packet->nodeID, node->isStopped( ));

    EQASSERT( node->getPipes().empty( ));
    unmapObject( node );
    Global::getNodeFactory()->releaseNode( node );

    getServer()->send( reply );
    return true;
}
示例#5
0
//出库
void _exportItem(const pItemNode head)
{
	int countNode;
	_item tempItem = __getInfoFrom2TempNode();
	if (countNode = _findNode(head, &__compFuncExport, tempItem))
	{
		//正常出库
		if ((__isNodeExist(head, countNode)->item.itemNumber -= tempItem.itemNumber) == 0)
		{
			//如果货物数量为0 删除记录
			_deleteNode(head, countNode);
		}
		printf("Export successed!\n");
	}
	else
	{
		//不能出库的情况
		printf("ERROR : The item isn't exist or the number is not enough.\n");
	}
}
示例#6
0
BSNode* findNode(BSTree* tree, int key)
{
	return _findNode(tree->root, key);
}