-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add IPathfinder * docs: add documentation
- Loading branch information
1 parent
27525ac
commit c51b832
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.1</TargetFramework> | ||
<LangVersion>9</LangVersion> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Aplib.Core\Aplib.Core.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
|
||
namespace Aplib.Extensions | ||
{ | ||
/// <summary> | ||
/// Defines a pathfinding algorithm used to find a path from a starting point to an end point. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the elements in the path.</typeparam> | ||
public interface IPathfinder<T> | ||
{ | ||
/// <summary> | ||
/// Finds a path from the specified starting point to the specified end point. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the elements in the path.</typeparam> | ||
/// <param name="begin">The starting point of the path.</param> | ||
/// <param name="end">The end point of the path.</param> | ||
/// <returns>A read-only span of elements representing the path from the starting point to the end point.</returns> | ||
public ReadOnlySpan<T> FindPath(T begin, T end); | ||
|
||
/// <summary> | ||
/// Gets the next step towards the specified end point from the current point in the path. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the elements in the path.</typeparam> | ||
/// <param name="current">The current point in the path.</param> | ||
/// <param name="end">The end point of the path.</param> | ||
/// <returns>The next step towards the end point.</returns> | ||
public T GetNextStep(T current, T end); | ||
|
||
/// <summary> | ||
/// Tries to get the next step towards the specified end point from the current point in the path. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the elements in the path.</typeparam> | ||
/// <param name="current">The current point in the path.</param> | ||
/// <param name="end">The end point of the path.</param> | ||
/// <param name="nextStep">When this method returns, contains the next step towards the end point if it exists, or the default value of type T if there is no next step.</param> | ||
/// <returns>true if the next step towards the end point is obtained successfully; otherwise, false.</returns> | ||
public bool TryGetNextStep(T current, T end, out T nextStep); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters