Skip to content

Commit

Permalink
Closes #895: Implement subList() on IntInterval
Browse files Browse the repository at this point in the history
Signed-off-by: vmzakharov <zakharov.vladimir.m@gmail.com>
  • Loading branch information
vmzakharov committed May 25, 2020
1 parent ab2a954 commit f059eeb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ public ImmutableIntList distinct()
@Override
public ImmutableIntList subList(int fromIndex, int toIndex)
{
throw new UnsupportedOperationException("subList not yet implemented!");
return IntInterval.fromToBy(this.get(fromIndex), this.get(toIndex - 1), this.step);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,11 @@ public void size()
Verify.assertSize(200_000_001, IntInterval.fromTo(1_000_000_000, -1_000_000_000).by(-10));
}

@Test(expected = UnsupportedOperationException.class)
@Test
public void subList()
{
this.intInterval.subList(0, 1);
IntInterval interval = IntInterval.fromToBy(1, 10, 2);
Assert.assertEquals(IntLists.immutable.with(3, 5, 7), interval.subList(1, 4));
}

@Test
Expand Down

0 comments on commit f059eeb

Please sign in to comment.