@Test public void testPrepend() { seq.append("x"); seq.prepend("a"); assertEquals("Prepend did not put new item in front", "a", seq.peekHead()); assertEquals("Length of sequence wrong after prepend", 2, seq.length()); seq.prepend("b"); assertEquals("Prepend did not put new item in front on second call", "b", seq.peekHead()); seq.prepend("c"); assertEquals("Prepend did not put new item in front on third call", "c", seq.peekHead()); assertEquals("Length of prepend sequence incorrect", 4, seq.length()); assertEquals("ToString value of sequence incorrect after prepends", "cbax" , seq.toString()); }
@Override public void prepend(Object element) { if (backingArray[front] != null && front == 0){ backingArray[backingArray.length-1] = (T)element; front = backingArray.length-1; fillCount+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[front] == null){ backingArray[front] = (T)element; fillCount +=1; rear+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[front] != null){ backingArray[front-1] = (T)element; front-=1; fillCount+=1; if (fullCheck()==true){ regrow(); } } }
CircularArraySequence implements Sequence { @Override public void prepend(Object element) { if (backingArray[front] != null && front == 0){ backingArray[backingArray.length-1] = (T)element; front = backingArray.length-1; fillCount+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[front] == null){ backingArray[front] = (T)element; fillCount +=1; rear+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[front] != null){ backingArray[front-1] = (T)element; front-=1; fillCount+=1; if (fullCheck()==true){ regrow(); } } } }
CircularArraySequence implements Sequence { @Override public void prepend(Object element) { if (backingArray[front] != null && front == 0){ backingArray[backingArray.length-1] = (T)element; front = backingArray.length-1; fillCount+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[front] == null){ backingArray[front] = (T)element; fillCount +=1; rear+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[front] != null){ backingArray[front-1] = (T)element; front-=1; fillCount+=1; if (fullCheck()==true){ regrow(); } } } CircularArraySequence(int size);  CircularArraySequence(CircularArraySequence<T> seq); }
CircularArraySequence implements Sequence { @Override public void prepend(Object element) { if (backingArray[front] != null && front == 0){ backingArray[backingArray.length-1] = (T)element; front = backingArray.length-1; fillCount+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[front] == null){ backingArray[front] = (T)element; fillCount +=1; rear+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[front] != null){ backingArray[front-1] = (T)element; front-=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 prepend(Object element) { if (backingArray[front] != null && front == 0){ backingArray[backingArray.length-1] = (T)element; front = backingArray.length-1; fillCount+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[front] == null){ backingArray[front] = (T)element; fillCount +=1; rear+=1; if (fullCheck()==true){ regrow(); } } else if(backingArray[front] != null){ backingArray[front-1] = (T)element; front-=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();  }