use Iterators instead of Lists where possible in manipulateCardList

This commit is contained in:
Peter F. Patel-Schneider
2019-01-16 12:06:21 -05:00
parent 3749f2a5de
commit 2f9fb96d29
9 changed files with 14 additions and 29 deletions

View File

@@ -285,7 +285,7 @@ public class GuiChoose {
return null;
}
public static List<CardView> manipulateCardList(final CMatchUI gui, final String title, final List<CardView> cards, final List<CardView> manipulable,
public static List<CardView> manipulateCardList(final CMatchUI gui, final String title, final Iterable<CardView> cards, final Iterable<CardView> manipulable,
final boolean toTop, final boolean toBottom, final boolean toAnywhere) {
final Callable<List<CardView>> callable = new Callable<List<CardView>>() {
@Override

View File

@@ -1004,7 +1004,7 @@ public final class CMatchUI
}
@Override
public List<CardView> manipulateCardList(final String title, final List<CardView> cards, final List<CardView> manipulable, final boolean toTop, final boolean toBottom, final boolean toAnywhere) {
public List<CardView> manipulateCardList(final String title, final Iterable<CardView> cards, final Iterable<CardView> manipulable, final boolean toTop, final boolean toBottom, final boolean toAnywhere) {
return GuiChoose.manipulateCardList(this, title, cards, manipulable, toTop, toBottom, toAnywhere);
}

View File

@@ -59,11 +59,12 @@ public class ListCardArea extends FloatingCardArea {
setOpaque(false);
}
public static ListCardArea show(final CMatchUI matchUI, final String title0, final List<CardView> cardList0, final List<CardView> moveableCards0, final boolean toTop0, final boolean toBottom0, final boolean toAnywhere0) {
public static ListCardArea show(final CMatchUI matchUI, final String title0, final Iterable<CardView> cardList0, final Iterable<CardView> moveableCards0, final boolean toTop0, final boolean toBottom0, final boolean toAnywhere0) {
if (storedArea==null) {
storedArea = new ListCardArea(matchUI);
}
cardList = new ArrayList<CardView>(cardList0);
cardList = new ArrayList<CardView>();
for ( CardView cv : cardList0 ) { cardList.add(cv) ; }
moveableCards = new ArrayList<CardView>(); // make sure moveable cards are in cardlist
for ( CardView card : moveableCards0 ) {
if ( cardList.contains(card) ) {