@Test public void testConcat() { seq.append("a"); seq.append("b"); seq.append("c"); Sequence<String> seq2 = new CircularArraySequence<String>(10); seq2.append("x"); seq2.append("y"); Sequence<String> seq3 = seq.concat(seq2); assertEquals(5, seq3.length()); assertEquals("a", seq3.peekHead()); assertEquals("y", seq3.peekLast()); }
@Override public Sequence<T> concat(Sequence seq) { CircularArraySequence<T> sequence1 = new CircularArraySequence<T>(this); CircularArraySequence<T> sequence2 = new CircularArraySequence<T>((CircularArraySequence<T>)seq); boolean halt = false; int index = sequence2.front; while (halt == false){ if (index == backingArray.length){ index = 0; } if (index == sequence2.rear){ halt = true; } else{ sequence1.append(sequence2.backingArray[index]); index += 1; } } return sequence1; }
CircularArraySequence implements Sequence { @Override public Sequence<T> concat(Sequence seq) { CircularArraySequence<T> sequence1 = new CircularArraySequence<T>(this); CircularArraySequence<T> sequence2 = new CircularArraySequence<T>((CircularArraySequence<T>)seq); boolean halt = false; int index = sequence2.front; while (halt == false){ if (index == backingArray.length){ index = 0; } if (index == sequence2.rear){ halt = true; } else{ sequence1.append(sequence2.backingArray[index]); index += 1; } } return sequence1; } }
CircularArraySequence implements Sequence { @Override public Sequence<T> concat(Sequence seq) { CircularArraySequence<T> sequence1 = new CircularArraySequence<T>(this); CircularArraySequence<T> sequence2 = new CircularArraySequence<T>((CircularArraySequence<T>)seq); boolean halt = false; int index = sequence2.front; while (halt == false){ if (index == backingArray.length){ index = 0; } if (index == sequence2.rear){ halt = true; } else{ sequence1.append(sequence2.backingArray[index]); index += 1; } } return sequence1; } CircularArraySequence(int size);  CircularArraySequence(CircularArraySequence<T> seq); }
CircularArraySequence implements Sequence { @Override public Sequence<T> concat(Sequence seq) { CircularArraySequence<T> sequence1 = new CircularArraySequence<T>(this); CircularArraySequence<T> sequence2 = new CircularArraySequence<T>((CircularArraySequence<T>)seq); boolean halt = false; int index = sequence2.front; while (halt == false){ if (index == backingArray.length){ index = 0; } if (index == sequence2.rear){ halt = true; } else{ sequence1.append(sequence2.backingArray[index]); index += 1; } } return sequence1; } CircularArraySequence(int size);  CircularArraySequence(CircularArraySequence<T> seq); @Override Object head(); @Override Object last(); @Override Sequence front(); @Override Sequence tail(); @Override Sequence<T> concat(Sequence seq); @Override boolean contains(Sequence subseq); @Override boolean contains(Object element); @Override void append(Object element); @Override void prepend(Object element); @Override boolean isEmpty(); @Override Object peekHead(); @Override Object peekLast(); @Override boolean equals(Sequence seq); @Override int length(); @Override Iterator<T> iterator(); String toString(); }
CircularArraySequence implements Sequence { @Override public Sequence<T> concat(Sequence seq) { CircularArraySequence<T> sequence1 = new CircularArraySequence<T>(this); CircularArraySequence<T> sequence2 = new CircularArraySequence<T>((CircularArraySequence<T>)seq); boolean halt = false; int index = sequence2.front; while (halt == false){ if (index == backingArray.length){ index = 0; } if (index == sequence2.rear){ halt = true; } else{ sequence1.append(sequence2.backingArray[index]); index += 1; } } return sequence1; } CircularArraySequence(int size);  CircularArraySequence(CircularArraySequence<T> seq); @Override Object head(); @Override Object last(); @Override Sequence front(); @Override Sequence tail(); @Override Sequence<T> concat(Sequence seq); @Override boolean contains(Sequence subseq); @Override boolean contains(Object element); @Override void append(Object element); @Override void prepend(Object element); @Override boolean isEmpty(); @Override Object peekHead(); @Override Object peekLast(); @Override boolean equals(Sequence seq); @Override int length(); @Override Iterator<T> iterator(); String toString();  }