@Test public void testNoExclusions() { TwoExclusionRange range = new TwoExclusionRange(0, 99, 120); for (int i = 0; i < 200; i++) { assertEquals(range.draw(i, 100), i % 100); } }
public int draw(int hash, int exclusionCandidate) { Integer tempA = exclusionA; Integer tempB = null; int tempExcl = exclusions; if (exclusionCandidate >= lowerBoundIncl && exclusionCandidate <= upperBoundIncl) { if (tempExcl == 0) { tempExcl++; tempA = exclusionCandidate; } else { tempExcl++; tempB = Math.max(tempA, exclusionCandidate); tempA = Math.min(tempA, exclusionCandidate); } } int result = this.lowerBoundIncl + hash % (this.range - tempExcl); if (tempExcl == 1) { if (result >= tempA) { result = result + 1; } } else if (tempExcl == 2) { if (result >= tempA) { result++; if (result >= tempB) { result++; } } } return result; }
TwoExclusionRange { public int draw(int hash, int exclusionCandidate) { Integer tempA = exclusionA; Integer tempB = null; int tempExcl = exclusions; if (exclusionCandidate >= lowerBoundIncl && exclusionCandidate <= upperBoundIncl) { if (tempExcl == 0) { tempExcl++; tempA = exclusionCandidate; } else { tempExcl++; tempB = Math.max(tempA, exclusionCandidate); tempA = Math.min(tempA, exclusionCandidate); } } int result = this.lowerBoundIncl + hash % (this.range - tempExcl); if (tempExcl == 1) { if (result >= tempA) { result = result + 1; } } else if (tempExcl == 2) { if (result >= tempA) { result++; if (result >= tempB) { result++; } } } return result; } }
TwoExclusionRange { public int draw(int hash, int exclusionCandidate) { Integer tempA = exclusionA; Integer tempB = null; int tempExcl = exclusions; if (exclusionCandidate >= lowerBoundIncl && exclusionCandidate <= upperBoundIncl) { if (tempExcl == 0) { tempExcl++; tempA = exclusionCandidate; } else { tempExcl++; tempB = Math.max(tempA, exclusionCandidate); tempA = Math.min(tempA, exclusionCandidate); } } int result = this.lowerBoundIncl + hash % (this.range - tempExcl); if (tempExcl == 1) { if (result >= tempA) { result = result + 1; } } else if (tempExcl == 2) { if (result >= tempA) { result++; if (result >= tempB) { result++; } } } return result; } TwoExclusionRange(int lowerBoundIncl, int upperBoundIncl, int exclusionCandidate); }
TwoExclusionRange { public int draw(int hash, int exclusionCandidate) { Integer tempA = exclusionA; Integer tempB = null; int tempExcl = exclusions; if (exclusionCandidate >= lowerBoundIncl && exclusionCandidate <= upperBoundIncl) { if (tempExcl == 0) { tempExcl++; tempA = exclusionCandidate; } else { tempExcl++; tempB = Math.max(tempA, exclusionCandidate); tempA = Math.min(tempA, exclusionCandidate); } } int result = this.lowerBoundIncl + hash % (this.range - tempExcl); if (tempExcl == 1) { if (result >= tempA) { result = result + 1; } } else if (tempExcl == 2) { if (result >= tempA) { result++; if (result >= tempB) { result++; } } } return result; } TwoExclusionRange(int lowerBoundIncl, int upperBoundIncl, int exclusionCandidate); int draw(int hash, int exclusionCandidate); }
TwoExclusionRange { public int draw(int hash, int exclusionCandidate) { Integer tempA = exclusionA; Integer tempB = null; int tempExcl = exclusions; if (exclusionCandidate >= lowerBoundIncl && exclusionCandidate <= upperBoundIncl) { if (tempExcl == 0) { tempExcl++; tempA = exclusionCandidate; } else { tempExcl++; tempB = Math.max(tempA, exclusionCandidate); tempA = Math.min(tempA, exclusionCandidate); } } int result = this.lowerBoundIncl + hash % (this.range - tempExcl); if (tempExcl == 1) { if (result >= tempA) { result = result + 1; } } else if (tempExcl == 2) { if (result >= tempA) { result++; if (result >= tempB) { result++; } } } return result; } TwoExclusionRange(int lowerBoundIncl, int upperBoundIncl, int exclusionCandidate); int draw(int hash, int exclusionCandidate);  }