Class CardArrayList
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<Card>
,Collection<Card>
,List<Card>
,CardList
An implementation of
CardList
for easy shuffling, choosing and uniqueness testing of lists of cards.-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorsConstructorDescriptionCardArrayList
(Collection<? extends Card> cards) Creates this instance from an existing list of cards. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds all the cards from the given list.Adds the card fluently.clone()
CallsCard.clone()
on every card in this list and returns a new copy of this list.boolean
Checks if the list has the specific reference to a card.get
(int index) Gets a card at the specified index.int
getCount()
Gets the size of this list.boolean
isEmpty()
Checks if the instance is empty.iterator()
Provides support for Java language features that require anIterator
Gets the first card in this instance.remove
(int index) boolean
boolean
Removes the specified card instance by reference.void
Removes all the cards from this instance.Removes the first card.boolean
Replaces a card by index.shuffle()
Deprecated.shuffle
(XORShiftRandom random) Shuffles the instance with the given random number generator.int
size()
stream()
Gets theStream
API representation of this card list.toList()
Gets aList
that references the contents of this instance.Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, removeRange, subList
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, removeAll, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.demilich.metastone.game.cards.CardList
addCard, containsCard, containsCard, filtered, getCopy, hasCardOfType, peek
Methods inherited from interface java.util.Collection
parallelStream, removeIf, toArray
Methods inherited from interface java.util.List
add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, removeAll, replaceAll, retainAll, sort, spliterator, subList, toArray, toArray
-
Constructor Details
-
CardArrayList
public CardArrayList() -
CardArrayList
Creates this instance from an existing list of cards.- Parameters:
cards
- The list of cards.
-
-
Method Details
-
add
- Specified by:
add
in interfaceCollection<Card>
- Specified by:
add
in interfaceList<Card>
- Overrides:
add
in classAbstractList<Card>
-
stream
Description copied from interface:CardList
Gets theStream
API representation of this card list.- Specified by:
stream
in interfaceCardList
- Specified by:
stream
in interfaceCollection<Card>
- Returns:
- The backing list's
Collection.stream()
.
-
addCard
Description copied from interface:CardList
Adds the card fluently. -
addAll
Description copied from interface:CardList
Adds all the cards from the given list. -
clone
Description copied from interface:CardList
CallsCard.clone()
on every card in this list and returns a new copy of this list. -
set
-
contains
Description copied from interface:CardList
Checks if the list has the specific reference to a card. Does not use the card'sEntity.id
or itsCard.getCardId()
, which may be more helpful. -
get
Description copied from interface:CardList
Gets a card at the specified index. -
getCount
public int getCount()Description copied from interface:CardList
Gets the size of this list. -
isEmpty
public boolean isEmpty()Description copied from interface:CardList
Checks if the instance is empty. -
iterator
Description copied from interface:CardList
Provides support for Java language features that require anIterator
-
size
public int size()- Specified by:
size
in interfaceCollection<Card>
- Specified by:
size
in interfaceList<Card>
- Specified by:
size
in classAbstractCollection<Card>
-
peekFirst
Description copied from interface:CardList
Gets the first card in this instance. -
remove
- Specified by:
remove
in interfaceCollection<Card>
- Specified by:
remove
in interfaceList<Card>
- Overrides:
remove
in classAbstractCollection<Card>
-
remove
Description copied from interface:CardList
Removes the specified card instance by reference. -
remove
-
removeAll
public void removeAll()Description copied from interface:CardList
Removes all the cards from this instance. -
removeFirst
Description copied from interface:CardList
Removes the first card. ImplementsPutRandomSecretIntoPlaySpell
, used by 3 Hearthstone cards.- Specified by:
removeFirst
in interfaceCardList
- Returns:
- The card that is now removed.
-
replace
Description copied from interface:CardList
Replaces a card by index. -
shuffle
Deprecated. -
shuffle
Description copied from interface:CardList
Shuffles the instance with the given random number generator.- Specified by:
shuffle
in interfaceCardList
- Parameters:
random
- AXORShiftRandom
instance.
-
toList
Description copied from interface:CardList
Gets aList
that references the contents of this instance.
-