/** * produces a set of ids (keys) that are evenly distributed around the id ring. One invocation * produces the i-th member of a set of size num. The set is evenly distributed around the ring, * with an offset given by this Id. The set is useful for constructing, for instance, Scribe trees * with disjoint sets of interior nodes. * * @param num the number of Ids in the set (must be <= 2^b) * @param b the routing base (as a power of 2) * @param i the index of the requested member of the set (0<=i<num; the 0-th member is this) * @return the resulting set member, or null in case of illegal arguments */ public Id getAlternateId(int num, int b, int i) { if (num > (1 << b) || i < 0 || i >= num) { return null; } Id res = new Id(Id); int digit = res.getDigit(numDigits(b) - 1, b) + ((1 << b) / num) * i; res.setDigit(numDigits(b) - 1, digit, b); return build(res.Id); }