📄 wuliutility.cc
字号:
/** * Copyright (c) 2006 Michele Mastrogiovanni. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include "WuliUtility.h"static class WuliUtilityClass : public TclClass {public: WuliUtilityClass() : TclClass("Utility/WULI") {} TclObject* create(int , const char*const* ) { return(new WuliUtility()); }} class_wuli_utility;void WuliUtility::setNeighbors(NodeAddress node, NodeList nn, NodeAddress CH) { neighbors[node] = nn; clusterHead[node] = CH;}/*voidWuliUtility::dump(){ map<NodeAddress, NodeList> newNeighbors; for (map<NodeAddress, NodeList>::iterator n = neighbors.begin(); n != neighbors.end(); n++) { // ClusterHead if (clusterHead[n->first] == (n->first)) { for (NodeList::iterator nn = (n->second).begin(); nn != (n->second).end(); nn++) if (clusterHead[*nn] == (*nn)) newNeighbors[n->first].insert(*nn); } // Gateway. else { newNeighbors[n->first].clear(); NodeAddress CH = -1; for (NodeList::iterator nn = (n->second).begin(); nn != (n->second).end(); nn++) if (clusterHead[*nn] == (*nn)) if ((*nn) > CH) CH = (*nn); if (CH != -1) { newNeighbors[n->first].insert(CH); newNeighbors[CH].insert(n->first); } else { newNeighbors[n->first] = (n->second); } } } for (map<NodeAddress, NodeList>::iterator n = newNeighbors.begin(); n != newNeighbors.end(); n++) { cout << (n->first) << " "; cout << (n->second).size() << " "; for (NodeList::iterator nn = (n->second).begin(); nn != (n->second).end(); nn++) cout << (*nn) << " "; }}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -