public Iterator getInNeighbors(Node src) {
GraphNode src_c = (GraphNode) src;
// return Collections.unmodifiableCollection(src_c.getInNeighbors());
- return src_c.getInNeighborsCopy();
+ return src_c.getInNeighborsCopy().iterator();
}
public int getInNeighborsSize(Node node) {
public Iterator getOutNeighbors(Node src) {
GraphNode src_c = (GraphNode) src;
// return Collections.unmodifiableCollection(src_c.getOutNeighbors());
- return src_c.getOutNeighborsCopy();
+ return src_c.getOutNeighborsCopy().iterator();
}
public int getOutNeighborsSize(Node node) {
protected void removeConnectingEdges(GraphNode n) {
GraphNode g;
- for (Iterator iterator1 = n.getOutNeighborsCopy(); iterator1.hasNext(); removeNeighbor(n, g)) {
+
+ for (Iterator iterator1 = n.getOutNeighborsCopy().iterator(); iterator1.hasNext(); removeNeighbor(n, g)) {
g = (GraphNode) iterator1.next();
}
-
- for (Iterator iterator2 = n.getInNeighborsCopy(); iterator2.hasNext(); removeNeighbor(g, n)) {
+
+ for (Iterator iterator2 = n.getInNeighborsCopy().iterator(); iterator2.hasNext(); removeNeighbor(g, n)) {
g = (GraphNode) iterator2.next();
}
protected Object data;
// protected List inNeighbors;
// protected List outNeighbors;
- protected LinkedList inNeighbors;
- protected LinkedList outNeighbors;
+ protected Vector inNeighbors;
+ protected Vector outNeighbors;
protected GraphNode() {
super();
public GraphNode(Object n) {
super();
data = n;
- inNeighbors = new LinkedList();
- outNeighbors = new LinkedList();
+ inNeighbors = new Vector();
+ outNeighbors = new Vector();
}
// public Object getData() {
if (inNeighbors.contains(n)) {
return false;
} else {
- inNeighbors.addLast(n);
+ inNeighbors.addElement(n);
return true;
}
}
return inNeighbors.contains(n);
}
- public final Iterator getInNeighbors() {
- return inNeighbors.iterator();
+ public final Vector getInNeighbors() {
+ return inNeighbors;
}
- public final Iterator getInNeighborsCopy() {
- LinkedList l = new LinkedList();
- Iterator o = inNeighbors.iterator();
- while (o.hasNext()) {
- l.addLast(o);
- }
- return l.iterator();
+ public final Vector getInNeighborsCopy() {
+ return inNeighbors.clone();
}
public final boolean addOutNeighbor(GraphNode n) {
if (outNeighbors.contains(n)) {
return false;
} else {
- outNeighbors.addLast(n);
+ outNeighbors.addElement(n);
return true;
}
}
public final boolean removeOutNeighbor(GraphNode n) {
return outNeighbors.remove(n);
}
-
public final boolean hasOutNeighbor(GraphNode n) {
return outNeighbors.contains(n);
}
- public final Iterator getOutNeighbors() {
- return outNeighbors.iterator();
+ public final Vector getOutNeighbors() {
+ return outNeighbors;
}
- public final Iterator getOutNeighborsCopy() {
- LinkedList l = new LinkedList();
- Iterator o = outNeighbors.iterator();
- while (o.hasNext()) {
- l.addLast(o);
- }
- return l.iterator();
+ public final Vector getOutNeighborsCopy() {
+ return outNeighbors.clone();
}
}
\ No newline at end of file
if (!found.contains(node)) {
found.add(node);
Node neighbor;
- for (Iterator iterator1 = mesh.getOutNeighbors(node); iterator1.hasNext(); remaining
- .push(neighbor))
+
+
+ for (Iterator iterator1 = mesh.getOutNeighbors(node); iterator1.hasNext(); remaining.push(neighbor))
neighbor = (Node) iterator1.next();
}
if (runtime < mintime) {
mintime = runtime;
}
+ System.gc();
}
System.out.println("minimum runtime: " + mintime + " ms");
}
System.gc();
- System.out.println("Done with GC");
// long id = Time.getNewTimeId();
long startTime = System.currentTimeMillis();
-./SerialDelaunayRefinements.bin ./input/large.2 true
+./SerialDelaunayRefinements.bin ./input/massive.2 true
this.size=0;
array=new Object[size];
}
+
+ //used for internal cloning
+ private Vector(int size, int capacityIncrement, Object[] array) {
+ this.size = size;
+ this.capacityIncrement = capacityIncrement;
+ this.array = new Object[array.length];
+ System.arraycopy(array, 0, this.array, 0, size);
+ }
+
+ public Vector clone() {
+ return new Vector(size,capacityIncrement, array);
+ }
public boolean isEmpty() {
return size==0;
return indexOf(e)!=-1;
}
- public void remove(Object o) {
+ public boolean remove(Object o) {
int in=indexOf(o);
- if (in!=-1)
+ if (in!=-1) {
removeElementAt(in);
+ return true;
+ }
+
+ return false;
}
public Object elementAt(int index) {
--- /dev/null
+public class VectorIterator extends Iterator {
+ private int pos;
+ private int size;
+ private Vector list;
+
+ public VectorIterator(Vector v) {
+ this.list = v;
+ this.pos = 0;
+ this.size = this.list.size();
+ }
+
+ /**
+ * Tests to see if there are any more objects to
+ * return.
+ *
+ * @return True if the end of the list has not yet been
+ * reached.
+ */
+ public boolean hasNext()
+ {
+ return pos < size;
+ }
+
+ /**
+ * Retrieves the next object from the list.
+ *
+ * @return The next object.
+ */
+ public Object next()
+ {
+ if (pos == size) {
+ return null; //since we can't throw anything...
+ }
+ return this.list.get(pos++);
+ }
+}
\ No newline at end of file