void deleteEdge(Graph* graph, int src, int dest) { if(src < 0 || src > graph->V || dest < 0 || dest > graph-> V) return; _deleteNode(graph->array[src], dest); _deleteNode(graph->array[dest], src); }
bool Trie::_deleteNode(TrieNode* node) { for(TrieNodeMap::iterator it = node->hmap.begin(); it != node->hmap.end(); it++) { TrieNode* next = it->second; _deleteNode(next); } delete node; return true; }
//进库 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"); }
bool Trie::dispose() { if(!_getInitFlag()) { return false; } bool ret = _deleteNode(_root); if(!ret) { LogFatal("_deleteNode failed!"); return false; } _root = NULL; _nodeInfoVec.clear(); _setInitFlag(false); return ret; }
//出库 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"); } }