RoutingNode.java (1805B)
1 package osm.routing; 2 3 import java.util.Comparator; 4 5 import osm.geo.Point; 6 7 /** 8 * Represents a node in a routing graph that implements the {@link Point} 9 * interface. 10 * 11 * @param <N> The type of the node. 12 */ 13 public interface RoutingNode<N> extends Point { 14 15 /** 16 * Gets the score associated with the node. 17 * 18 * @return The score value. 19 */ 20 long getScore(); 21 22 /** 23 * Sets the score value for the node. 24 * 25 * @param value The score value to set. 26 */ 27 void setScore(long value); 28 29 /** 30 * Gets the heuristic score associated with the node. 31 * 32 * @return The heuristic score value. 33 */ 34 long getHeuristicScore(); 35 36 /** 37 * Sets the heuristic score for the node. 38 * 39 * @param total The total heuristic score to set. 40 */ 41 void setHeuristicScore(long total); 42 43 /** 44 * Checks if the node has a parent. 45 * 46 * @return True if the node has a parent, false otherwise. 47 */ 48 boolean hasParent(); 49 50 /** 51 * Gets the parent node. 52 * 53 * @return The parent node. 54 */ 55 N getParent(); 56 57 /** 58 * Sets the parent node for this node. 59 * 60 * @param parent The parent node to set. 61 */ 62 void setParent(N parent); 63 64 /** 65 * Creates a comparator based on the heuristic score for sorting nodes. 66 * 67 * @return A comparator for heuristic score sorting. 68 */ 69 static Comparator<RoutingNode<?>> heuristicComparator() { 70 return Comparator.comparingLong(RoutingNode::getHeuristicScore); 71 } 72 73 /** 74 * Creates a comparator based on the score for sorting nodes. 75 * 76 * @return A comparator for score sorting. 77 */ 78 static Comparator<RoutingNode<?>> scoreComparator() { 79 return Comparator.comparingLong(RoutingNode::getScore); 80 } 81 }