Implemented new StoneSet split behavior

git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@87 72836036-5685-4462-b002-a69064685172
This commit is contained in:
Jannis Harder 2011-05-03 19:06:14 +02:00
parent a39b31d893
commit 1bed4a77a5

View file

@ -132,9 +132,10 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
* @return A pair of StoneSets, one for each split part * @return A pair of StoneSets, one for each split part
*/ */
public Pair<StoneSet, StoneSet> splitAt(int position) { public Pair<StoneSet, StoneSet> splitAt(int position) {
// Exception in case of wrong index if (position == 0) {
if (position == 0 || position == stones.size()) { return new Pair<StoneSet, StoneSet>(null, this);
throw new IndexOutOfBoundsException(); } else if (position == stones.size()) {
return new Pair<StoneSet, StoneSet>(this, null);
} }
StoneSet firstSet = new StoneSet(stones.subList(0, position)); StoneSet firstSet = new StoneSet(stones.subList(0, position));
StoneSet secondSet = new StoneSet(stones.subList(position, StoneSet secondSet = new StoneSet(stones.subList(position,