import point;
import segment;
import java.lang.Math;

class polygon
{
  point[]   vlist;  // List of vertices
  boolean[] matchE; // Which edges are matched
  
 
  public int maxsize;
  public int n = 0;   // number of vertices in this polygon
  public boolean closed = false;

  // constructor
  public polygon(int max)
  {
    vlist = new point[max];
    maxsize = max;
  }

  // addVertex(point) : add a vertex to the end of this polygonal chain
  public void addVertex(point p)
  {
    if (n < 100)
    {
    	p.index = n;
      vlist[n] = p;
      n++;
    }
  }

  public int prev(int Ind)
  {
    for (int i = Ind-1; i >= 0; i--)
    {
      if (!vlist[i].removed) { return i; }
    }
    for (int i = n-1; i > Ind; i--)
    {
      if (!vlist[i].removed) { return i; }
    }
    return -1;
  }

  public int next(int Ind)
  {
    for (int i = 1; i < n; i++)
    {
      if (!vlist[(i+Ind)%n].removed) { return ((i+Ind)%n); }
    }
    return -1;
  }

}