Record Class StratConPathfinder.Pathing

java.lang.Object
java.lang.Record
mekhq.campaign.digitalGM.stratCon.sectorGeneration.StratConPathfinder.Pathing
Record Components:
distance - the least cost to each hex reached; a source costs nothing
previous - the hex each hex was reached from; a source has none
Enclosing class:
StratConPathfinder

public static record StratConPathfinder.Pathing(Map<StratConCoords,Integer> distance, Map<StratConCoords,StratConCoords> previous) extends Record
The result of a sweep: the least cost to each hex reached, and the hex each was reached from.
Since:
0.51.01
  • Constructor Details

  • Method Details

    • reaches

      public boolean reaches(StratConCoords target)
      Parameters:
      target - a hex
      Returns:
      true if the sweep reached the hex
    • nearest

      @Nullable public StratConCoords nearest(Iterable<StratConCoords> candidates)
      Parameters:
      candidates - the hexes to choose between
      Returns:
      the candidate cheapest to reach, the first one met winning a tie; null if none was reached
    • pathTo

      public List<StratConCoords> pathTo(StratConCoords target)
      Rebuilds the hex path between target and the sweep's source by following the previous-hex links; includes both endpoints.

      The list runs from target back to the source, because that is the direction the links point.

      Parameters:
      target - a hex
      Returns:
      the path, or an empty list if the sweep did not reach the hex
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • distance

      public Map<StratConCoords,Integer> distance()
      Returns the value of the distance record component.
      Returns:
      the value of the distance record component
    • previous

      public Map<StratConCoords,StratConCoords> previous()
      Returns the value of the previous record component.
      Returns:
      the value of the previous record component