@Test public void testAppend() { assertTrue("Your sequence was not empty when created", seq.isEmpty()); seq.append("a"); assertFalse("Your sequence claims its empty after appending something", seq.isEmpty()); assertEquals("The head of your sequence was not the thing appended on first append", "a", seq.peekHead()); seq.append("b"); assertEquals("The last of your sequence was not the thing appended on second append", "b", seq.peekLast()); assertEquals("The head of your sequence modified on the second append", "a", seq.peekHead()); seq.append("c"); seq.append("d"); assertEquals("The head of your sequence modified after multiple appends", "a", seq.peekHead()); assertEquals("The last of your sequence was not the last thing appended", "d", seq.peekLast()); }
@Override public void append(Object element) { if (backingArray[rear] != null && rear!=backingArray.length-1){ backingArray[rear+1] = (T)element; rear+=1; fillCount +=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[rear] !=null && rear==backingArray.length-1){ rear = 0; backingArray[rear] = (T)element; fillCount+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[rear] == null){ backingArray[rear] = (T)element; rear+=1; fillCount+=1; if (fullCheck()==true){ regrow(); } } }
CircularArraySequence implements Sequence { @Override public void append(Object element) { if (backingArray[rear] != null && rear!=backingArray.length-1){ backingArray[rear+1] = (T)element; rear+=1; fillCount +=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[rear] !=null && rear==backingArray.length-1){ rear = 0; backingArray[rear] = (T)element; fillCount+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[rear] == null){ backingArray[rear] = (T)element; rear+=1; fillCount+=1; if (fullCheck()==true){ regrow(); } } } }
CircularArraySequence implements Sequence { @Override public void append(Object element) { if (backingArray[rear] != null && rear!=backingArray.length-1){ backingArray[rear+1] = (T)element; rear+=1; fillCount +=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[rear] !=null && rear==backingArray.length-1){ rear = 0; backingArray[rear] = (T)element; fillCount+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[rear] == null){ backingArray[rear] = (T)element; rear+=1; fillCount+=1; if (fullCheck()==true){ regrow(); } } } CircularArraySequence(int size);  CircularArraySequence(CircularArraySequence<T> seq); }
CircularArraySequence implements Sequence { @Override public void append(Object element) { if (backingArray[rear] != null && rear!=backingArray.length-1){ backingArray[rear+1] = (T)element; rear+=1; fillCount +=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[rear] !=null && rear==backingArray.length-1){ rear = 0; backingArray[rear] = (T)element; fillCount+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[rear] == null){ backingArray[rear] = (T)element; rear+=1; fillCount+=1; if (fullCheck()==true){ regrow(); } } } 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 void append(Object element) { if (backingArray[rear] != null && rear!=backingArray.length-1){ backingArray[rear+1] = (T)element; rear+=1; fillCount +=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[rear] !=null && rear==backingArray.length-1){ rear = 0; backingArray[rear] = (T)element; fillCount+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[rear] == null){ backingArray[rear] = (T)element; rear+=1; fillCount+=1; if (fullCheck()==true){ regrow(); } } } 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();  }