vanetsim.routing.A_Star
Class A_Star_LookupTableFactory

java.lang.Object
  extended by vanetsim.routing.A_Star.A_Star_LookupTableFactory

public final class A_Star_LookupTableFactory
extends java.lang.Object

A factory for creating LookupTables (mapping between Nodes and A_Star_Nodes)for the A* algorithm. It's extremely efficient to recycle old LookupTables, because the A* algorithm creates lots of new A_Star_Nodes which is relatively costly because of the huge amount of objects and necessary garbage collection. This factory takes correctly care of multithreading so you may concurrently calculate routes. However, this may take some memory as every concurrent LookupTable is completely independent and will be stored for the whole program life!


Constructor Summary
A_Star_LookupTableFactory()
           
 
Method Summary
static void clear()
          Clear the cached versions.
static A_Star_LookupTable<Node,A_Star_Node> getTable(int[] counter)
          Gets a LookupTable.
static void putTable(int counter, A_Star_LookupTable<Node,A_Star_Node> table)
          Put back a LookupTable so that it can be reused.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

A_Star_LookupTableFactory

public A_Star_LookupTableFactory()
Method Detail

getTable

public static A_Star_LookupTable<Node,A_Star_Node> getTable(int[] counter)
Gets a LookupTable. Don't forget to put the LookupTable back if you don't need it anymore!

Parameters:
counter - an array used to return a new counter value in counter[0]
Returns:
the LookupTable

putTable

public static void putTable(int counter,
                            A_Star_LookupTable<Node,A_Star_Node> table)
Put back a LookupTable so that it can be reused.

Parameters:
counter - the counter value
table - the LookupTable

clear

public static void clear()
Clear the cached versions. This should be done on map reload to free otherwise unnecessarily wasted memory.