📄 clustering-header.h
字号:
/** * 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. * *///// Definizioni di alcune funzioni di utilita' e tipi di dato// comuni a tutti gli algoritmi di clustering.//#ifndef _CLUSTERING_COMMON_HEADER_#define _CLUSTERING_COMMON_HEADER_#include "config.h"#include "scheduler.h"#include <set>#include <map>#include <vector>#include <list>using namespace std;/////////////////////// ID di un nodo //////////////////////typedef nsaddr_t NodeAddress;/////////////////////// Lista di nodi //////////////////////typedef set<NodeAddress> NodeList;///////////////// Timeout ////////////////struct Timeout { Event * timeout; int num;};///////////////////////////////////////////////// Struttura di mantenimento di un timeout ////////////////////////////////////////////////struct TimeoutFrom { NodeAddress from; Event * timeout; int num;};////////////////////////// Mappa di timeout /////////////////////////typedef map<NodeAddress, struct Timeout> TimeoutMap;typedef map<NodeAddress, struct TimeoutFrom> TimeoutFromMap;/////////////////////////////// Print a list of nodes //////////////////////////////staticvoidprintNodeList(NodeList & list){ for (NodeList::iterator i = list.begin(); i != list.end(); i++) printf("%d ", *i);}//// Mappa dei vicini: WULI//typedef map<NodeAddress, NodeList> NodeNeighbors;//// Colore del nodo//typedef enum { NO_COLOR = 0x0, // Nessun colore COLOR_WHITE = 0x1, // Colore BIANCO COLOR_BLACK = 0x2, // Colore NERO COLOR_GRAY = 0x3 // Colore GRIGIO} Color;//// Mappa dei colori dei vicini.//typedef map<NodeAddress, Color> NodeColor;struct ReachPath { int length; NodeAddress node1_ID; int node1_WT; NodeAddress node2_ID; int node2_WT; public: ReachPath() { length = -1; node1_ID = -1; node1_WT = -1; node2_ID = -1; node2_WT = -1; }};// Mappa che indica, per ogni nodo il percorso per raggiungerlo.typedef map<NodeAddress, struct ReachPath> Reachbility;//// Percorso verso un nodo clusterHead memorizzato da un clusterHead.//struct Percorsi { NodeAddress black_node; struct ReachPath path;};// Combinazioni di liste di nodi.typedef vector<NodeList> Combinations;typedef pair<NodeAddress, NodeAddress> Arc;typedef set<Arc> Arcs;#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -