Recipe 1.4. Creating a (sub-)sequence of symbols from sequence
Problem
You want to create a sequence of specific symbols from another sequence instance.
Solution
You will use the same builder with the instance of the source sequence as only parameter and defines an interval [from, to[:
// 5 cards
SymbolSequenceImpl<Integer> openCards =
new SymbolSequenceImpl.Builder<Integer>("AKK23", CardRankSymbol
.getSymbolType()).build();
// a simple copy
SymbolSequenceImpl<Integer> openCardsCopy =
new SymbolSequenceImpl.Builder<Integer>(openCards).build();
Assert.assertEquals("AKK23", openCards.toString());
// a sub sequence
SymbolSequenceImpl<Integer> flop =
new SymbolSequenceImpl.Builder<Integer>(openCards).from(0).to(3)
.build();
Assert.assertEquals("J2R", flop.toString());
Discussion
See Also


