/** Adds point x, y at the beginning of the list */ public void prepend(int x, int y) { if (last-first>=2 && collinear(this.x[first+1], this.y[first+1], this.x[first], this.y[first], x , y)) { this.x[first] = x; //replace previous point this.y[first] = y; } else { needs(1, 0); //new point first--; this.x[first] = x; this.y[first] = y; } }
/** Adds point x, y at the end of the list */ public void append(int x, int y) { if (last-first>=2 && collinear(this.x[last-2], this.y[last-2], this.x[last-1], this.y[last-1], x , y)) { this.x[last-1] = x; //replace previous point this.y[last-1] = y; } else { needs(0, 1); //new point this.x[last] = x; this.y[last] = y; last++; } }
/** Adds point x, y at the end of the list */ public void append(int x, int y) { if (last-first>=2 && collinear(this.x[last-2], this.y[last-2], this.x[last-1], this.y[last-1], x , y)) { this.x[last-1] = x; //replace previous point this.y[last-1] = y; } else { needs(0, 1); //new point this.x[last] = x; this.y[last] = y; last++; } }
/** Adds point x, y at the beginning of the list */ public void prepend(int x, int y) { if (last-first>=2 && collinear(this.x[first+1], this.y[first+1], this.x[first], this.y[first], x , y)) { this.x[first] = x; //replace previous point this.y[first] = y; } else { needs(1, 0); //new point first--; this.x[first] = x; this.y[first] = y; } }