@Test public void testRegrow() { for(int i=0; i < 15 ; i++) seq.append("a"); seq.prepend("e"); seq.append("x"); assertEquals("Error on regrow", 17, seq.length()); assertEquals("Head wrong after regrow", "e", seq.peekHead()); assertEquals("Last wrong after regrow", "x" , seq.peekLast()); assertEquals("String rep wrong on regrow", "eaaaaaaaaaaaaaaax", seq.toString()); }
private void regrow(){ T[] tempArray = (T[])new Object[backingArray.length*2]; for (int i=0;i<backingArray.length;i++){ tempArray[i] = backingArray[i]; } int tempfillCount = fillCount; int index = front; int newIndex = 0; while (tempfillCount!=0){ if (index == backingArray.length){ index = 0; } tempArray[newIndex]=backingArray[index]; index += 1; tempfillCount-=1; } front = 0; rear = fillCount; backingArray = tempArray; }
CircularArraySequence implements Sequence { private void regrow(){ T[] tempArray = (T[])new Object[backingArray.length*2]; for (int i=0;i<backingArray.length;i++){ tempArray[i] = backingArray[i]; } int tempfillCount = fillCount; int index = front; int newIndex = 0; while (tempfillCount!=0){ if (index == backingArray.length){ index = 0; } tempArray[newIndex]=backingArray[index]; index += 1; tempfillCount-=1; } front = 0; rear = fillCount; backingArray = tempArray; } }
CircularArraySequence implements Sequence { private void regrow(){ T[] tempArray = (T[])new Object[backingArray.length*2]; for (int i=0;i<backingArray.length;i++){ tempArray[i] = backingArray[i]; } int tempfillCount = fillCount; int index = front; int newIndex = 0; while (tempfillCount!=0){ if (index == backingArray.length){ index = 0; } tempArray[newIndex]=backingArray[index]; index += 1; tempfillCount-=1; } front = 0; rear = fillCount; backingArray = tempArray; } CircularArraySequence(int size);  CircularArraySequence(CircularArraySequence<T> seq); }
CircularArraySequence implements Sequence { private void regrow(){ T[] tempArray = (T[])new Object[backingArray.length*2]; for (int i=0;i<backingArray.length;i++){ tempArray[i] = backingArray[i]; } int tempfillCount = fillCount; int index = front; int newIndex = 0; while (tempfillCount!=0){ if (index == backingArray.length){ index = 0; } tempArray[newIndex]=backingArray[index]; index += 1; tempfillCount-=1; } front = 0; rear = fillCount; backingArray = tempArray; } 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 { private void regrow(){ T[] tempArray = (T[])new Object[backingArray.length*2]; for (int i=0;i<backingArray.length;i++){ tempArray[i] = backingArray[i]; } int tempfillCount = fillCount; int index = front; int newIndex = 0; while (tempfillCount!=0){ if (index == backingArray.length){ index = 0; } tempArray[newIndex]=backingArray[index]; index += 1; tempfillCount-=1; } front = 0; rear = fillCount; backingArray = tempArray; } 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();  }