for (int j=0; j<4; j++) { int v = r.nextInt(16); if (v < 10) {
sb.append(Integer.toString(v));
} else { char c = (char) ('A' + v - 10);
sb.append(c);
}
}
}
int iterations = 10000; if (args.length > 0) {
iterations = Integer.parseInt(args[0]);
}
int MIN_SHORT = (int)Short.MIN_VALUE; int MAX_SHORT = (int)Short.MAX_VALUE;
/* *Iteratethrough10khashcodesandcountthenumber *intheMIN_SHORT-MAX_SHORTrange.
*/ int narrow = 0; for (int i=0; i<iterations; i++) { int hc = randomIPv6Adress().hashCode(); if (hc >= MIN_SHORT && hc <= MAX_SHORT) {
narrow++;
}
}
/* *If>85%ofhashcodesintherangethenfail.
*/ double percent = (double)narrow / (double)iterations * 100.0; if (percent > 85.0) { thrownew RuntimeException(percent + " of hash codes were in " +
MIN_SHORT + " to " + MAX_SHORT + " range.");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.