From 8722a9920c1f6119bf6e769cba270e63097f8e25 Mon Sep 17 00:00:00 2001
From: chai <215380520@qq.com>
Date: Thu, 23 May 2024 10:08:29 +0800
Subject: + astar project
---
.../Utilities/AstarChecksum.cs | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Utilities/AstarChecksum.cs
(limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Utilities/AstarChecksum.cs')
diff --git a/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Utilities/AstarChecksum.cs b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Utilities/AstarChecksum.cs
new file mode 100644
index 0000000..b492542
--- /dev/null
+++ b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Utilities/AstarChecksum.cs
@@ -0,0 +1,21 @@
+using System;
+namespace Pathfinding.Util {
+ /// Calculates checksums of byte arrays
+ public class Checksum {
+ ///
+ /// Calculate checksum for the byte array starting from a previous values.
+ /// Useful if data is split up between several byte arrays
+ ///
+ public static uint GetChecksum (byte[] arr, uint hash) {
+ // Sort of implements the Fowler–Noll–Vo hash function
+ const int prime = 16777619;
+
+ hash ^= 2166136261U;
+
+ for (int i = 0; i < arr.Length; i++)
+ hash = (hash ^ arr[i]) * prime;
+
+ return hash;
+ }
+ }
+}
--
cgit v1.1-26-g67d0