JavaCAD
VertexList.java
Go to the documentation of this file.
1 package eu.mihosoft.vrl.v3d.ext.quickhull3d;
2 
3 // TODO: Auto-generated Javadoc
7 class VertexList
8 {
9 
11  private Vertex head;
12 
14  private Vertex tail;
15 
19  public void clear()
20  {
21  head = tail = null;
22  }
23 
29  public void add (Vertex vtx)
30  {
31  if (head == null)
32  { head = vtx;
33  }
34  else
35  { tail.next = vtx;
36  }
37  vtx.prev = tail;
38  vtx.next = null;
39  tail = vtx;
40  }
41 
47  public void addAll (Vertex vtx)
48  {
49  if (head == null)
50  { head = vtx;
51  }
52  else
53  { tail.next = vtx;
54  }
55  vtx.prev = tail;
56  while (vtx.next != null)
57  { vtx = vtx.next;
58  }
59  tail = vtx;
60  }
61 
67  public void delete (Vertex vtx)
68  {
69  if (vtx.prev == null)
70  { head = vtx.next;
71  }
72  else
73  { vtx.prev.next = vtx.next;
74  }
75  if (vtx.next == null)
76  { tail = vtx.prev;
77  }
78  else
79  { vtx.next.prev = vtx.prev;
80  }
81  }
82 
89  public void delete (Vertex vtx1, Vertex vtx2)
90  {
91  if (vtx1.prev == null)
92  { head = vtx2.next;
93  }
94  else
95  { vtx1.prev.next = vtx2.next;
96  }
97  if (vtx2.next == null)
98  { tail = vtx1.prev;
99  }
100  else
101  { vtx2.next.prev = vtx1.prev;
102  }
103  }
104 
112  public void insertBefore (Vertex vtx, Vertex next)
113  {
114  vtx.prev = next.prev;
115  if (next.prev == null)
116  { head = vtx;
117  }
118  else
119  { next.prev.next = vtx;
120  }
121  vtx.next = next;
122  next.prev = vtx;
123  }
124 
130  public Vertex first()
131  {
132  return head;
133  }
134 
140  public boolean isEmpty()
141  {
142  return head == null;
143  }
144 }