@Test public void iteratorArrayTest() { IteratorArray iteratorArray = new IteratorArray(10, 1); Assert.assertEquals(iteratorArray.getPoint(), 1); Assert.assertTrue(iteratorArray.hasPrevious()); Assert.assertTrue(iteratorArray.hasNext()); iteratorArray.retreat(); Assert.assertFalse(iteratorArray.hasPrevious()); Assert.assertEquals(iteratorArray.getPoint(), 0); iteratorArray = new IteratorArray(10, 9); Assert.assertFalse(iteratorArray.hasNext()); }
IteratorArray(int length, int point) { Preconditions.checkArgument(length > 0, "length must be positive!"); Preconditions.checkArgument(point < length && point >= 0, "point out of range!"); this.prevIndex = new int[length]; this.nextIndex = new int[length]; for (int i = 0; i < length; i++) { this.prevIndex[i] = i - 1; this.nextIndex[i] = i + 1; } this.nextIndex[length - 1] = -1; this.point = point; }
IteratorArray { IteratorArray(int length, int point) { Preconditions.checkArgument(length > 0, "length must be positive!"); Preconditions.checkArgument(point < length && point >= 0, "point out of range!"); this.prevIndex = new int[length]; this.nextIndex = new int[length]; for (int i = 0; i < length; i++) { this.prevIndex[i] = i - 1; this.nextIndex[i] = i + 1; } this.nextIndex[length - 1] = -1; this.point = point; } }
IteratorArray { IteratorArray(int length, int point) { Preconditions.checkArgument(length > 0, "length must be positive!"); Preconditions.checkArgument(point < length && point >= 0, "point out of range!"); this.prevIndex = new int[length]; this.nextIndex = new int[length]; for (int i = 0; i < length; i++) { this.prevIndex[i] = i - 1; this.nextIndex[i] = i + 1; } this.nextIndex[length - 1] = -1; this.point = point; } IteratorArray(int length, int point); }
IteratorArray { IteratorArray(int length, int point) { Preconditions.checkArgument(length > 0, "length must be positive!"); Preconditions.checkArgument(point < length && point >= 0, "point out of range!"); this.prevIndex = new int[length]; this.nextIndex = new int[length]; for (int i = 0; i < length; i++) { this.prevIndex[i] = i - 1; this.nextIndex[i] = i + 1; } this.nextIndex[length - 1] = -1; this.point = point; } IteratorArray(int length, int point);  }
IteratorArray { IteratorArray(int length, int point) { Preconditions.checkArgument(length > 0, "length must be positive!"); Preconditions.checkArgument(point < length && point >= 0, "point out of range!"); this.prevIndex = new int[length]; this.nextIndex = new int[length]; for (int i = 0; i < length; i++) { this.prevIndex[i] = i - 1; this.nextIndex[i] = i + 1; } this.nextIndex[length - 1] = -1; this.point = point; } IteratorArray(int length, int point);   }