path.hh

来自「COPE the first practical network coding 」· HH 代码 · 共 74 行

HH
74
字号
#ifndef CLICK_PATH_HH#define CLICK_PATH_HH#include <click/straccum.hh>CLICK_DECLStypedef Vector<IPAddress> Path;inline unsignedhashcode(const Path &p){  unsigned h = 0;  for (int x = 0; x < p.size(); x++) {    h = h ^ hashcode(p[x]);  }  return h;}inline booloperator==(const Path &p1, const Path &p2){  if (p1.size() != p2.size()) {    return false;  }  for (int x = 0; x < p1.size(); x++) {    if (p1[x] != p2[x]) {      return false;    }  }  return true;}inline booloperator!=(const Path &p1, const Path &p2){  return (!(p1 == p2));}inline String path_to_string(const Path &p) {  StringAccum sa;  for(int x = 0; x < p.size(); x++) {    sa << p[x].s().cc();    if (x != p.size() - 1) {      sa << " ";    }  }  return sa.take_string();}inline Path reverse_path (const Path &p) {  Path rev;  for (int x = p.size() - 1; x >= 0; x--) {    rev.push_back(p[x]);  }  return rev;}inline int index_of(Path p, IPAddress ip) {  for (int x = 0;  x < p.size(); x++) {    if (p[x] == ip) {      return x;    }  }  return -1;}CLICK_ENDDECLS#endif /* CLICK_PATH_HH */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?