org.jcae.mesh.amibe.ds
Class Triangle.List

java.lang.Object
  extended by org.jcae.mesh.amibe.ds.Triangle.List
Enclosing class:
Triangle

public static class Triangle.List
extends java.lang.Object

Singly linked list of triangles. We sometimes need to process lists of triangles before mesh connectivity has been set up. This can be achieved efficiently with a singly linked list, but there are few caveats.

Here is an example:

   //  Begin a new list
   Triangle.List tList = new Triangle.List();
   ...
   //  In a loop, add triangles to this list.
     tList.add(org.jcae.mesh.amibe.ds.Triangle)(tri);
   //  Check whether a triangle is contained in this list.
   //  This is very fast because it tests if its link pointer
   //  is null or not.
     if (tList.contains(org.jcae.mesh.amibe.ds.Triangle)(tri)) {
        ...
     }
   //  Loop over collected triangles.
   for (Iterator it = tList.iterator(); it.hasNext(); )
   {
     Triangle t = it.next();
     ...
   }
   //  When finished, remove all links between triangles
   tList.clear();
   

New elements are added at the end of the list so that add(org.jcae.mesh.amibe.ds.Triangle) can be called while iterator() is in action.


Constructor Summary
Triangle.List()
          Initialize a triangle linked list.
 
Method Summary
 void add(Triangle o)
          Add the current triangle to the end of the list.
 void addAllowDuplicates(Triangle o)
          Add the current triangle to the end of the list.
 void clear()
          Unmark triangles.
 boolean contains(Triangle o)
          Check whether this element appears in the list.
 java.util.Iterator<Triangle> iterator()
          Create an iterator over linked triangles.
 int size()
          Return list size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Triangle.List

public Triangle.List()
Initialize a triangle linked list.

Method Detail

clear

public void clear()
Unmark triangles. This method must be called before freeing the list.


add

public final void add(Triangle o)
Add the current triangle to the end of the list.

Throws:
java.util.ConcurrentModificationException - if this element is already linked.

addAllowDuplicates

public final void addAllowDuplicates(Triangle o)
Add the current triangle to the end of the list. This method does nothing if this element is already linked.


contains

public boolean contains(Triangle o)
Check whether this element appears in the list.


size

public int size()
Return list size.


iterator

public java.util.Iterator<Triangle> iterator()
Create an iterator over linked triangles. Note that the list can be extended while iterating over elements.