123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- //------------------------------------------------------------
- // Game Framework
- // Copyright © 2013-2021 loyalsoft. All rights reserved.
- // Homepage: http://www.game7000.com/
- // Feedback: http://www.game7000.com/
- //------------------------------------------------------------
- using System.Collections.Generic;
- namespace UnityGameFramework.Runtime
- {
- /// <summary>
- /// 内置版本资源列表序列化器。
- /// </summary>
- public static partial class BuiltinVersionListSerializer
- {
- private const string DefaultExtension = "dat";
- private const int CachedHashBytesLength = 4;
- private static readonly byte[] s_CachedHashBytes = new byte[CachedHashBytesLength];
- private static int AssetNameToDependencyAssetNamesComparer(KeyValuePair<string, string[]> a, KeyValuePair<string, string[]> b)
- {
- return a.Key.CompareTo(b.Key);
- }
- private static int GetAssetNameIndex(List<KeyValuePair<string, string[]>> assetNameToDependencyAssetNames, string assetName)
- {
- return GetAssetNameIndexWithBinarySearch(assetNameToDependencyAssetNames, assetName, 0, assetNameToDependencyAssetNames.Count - 1);
- }
- private static int GetAssetNameIndexWithBinarySearch(List<KeyValuePair<string, string[]>> assetNameToDependencyAssetNames, string assetName, int leftIndex, int rightIndex)
- {
- if (leftIndex > rightIndex)
- {
- return -1;
- }
- int middleIndex = (leftIndex + rightIndex) / 2;
- if (assetNameToDependencyAssetNames[middleIndex].Key == assetName)
- {
- return middleIndex;
- }
- if (assetNameToDependencyAssetNames[middleIndex].Key.CompareTo(assetName) > 0)
- {
- return GetAssetNameIndexWithBinarySearch(assetNameToDependencyAssetNames, assetName, leftIndex, middleIndex - 1);
- }
- else
- {
- return GetAssetNameIndexWithBinarySearch(assetNameToDependencyAssetNames, assetName, middleIndex + 1, rightIndex);
- }
- }
- }
- }
|