FindCount(string suffix, FindModeEnum findMode = FindModeEnum.IgnoreCase) { suffix = CorrectFindSuffix(suffix, findMode); var findCount = 0; var tuple = new tuple_t() { Suffix = suffix }; var bpt_tuples = _BPT.GetValues(tuple, StartsWithStringComparer.Inst); foreach (var bpt_tuple in bpt_tuples) { foreach (var data in bpt_tuple.Data) { var word = _StringValueGetter.GetStringValue(_Objects[data.ObjIndex]); var endIndex = data.SuffixIndex + suffix.Length; if (endIndex <= word.Length) { findCount++; } } } return(findCount); }
Find(string suffix, int maxCount, out int findTotalCount, FindModeEnum findMode = FindModeEnum.IgnoreCase) { findTotalCount = 0; suffix = CorrectFindSuffix(suffix, findMode); var tuple = new tuple_t() { Suffix = suffix }; var bpt_tuples = _BPT.GetValues(tuple, StartsWithStringComparer.Inst); var frs = new LinkedList <find_result_t>(); foreach (var bpt_tuple in bpt_tuples) { foreach (var data in bpt_tuple.Data) { var word = _StringValueGetter.GetStringValue(_Objects[data.ObjIndex]); var endIndex = data.SuffixIndex + suffix.Length; if (endIndex <= word.Length) { if (++findTotalCount <= maxCount) { frs.AddFirst(find_result_t.Create(data.ObjIndex, word, data.SuffixIndex, suffix.Length)); } } } } return(frs.Any() ? frs.ToArray() : find_result_t.EMPTY); }
Find(string suffix, int maxCount, out int findTotalCount, FindModeEnum findMode = FindModeEnum.IgnoreCase) { suffix = CorrectFindSuffix(suffix, findMode); findTotalCount = 0; var index = InternalBinarySearch(suffix); if (0 <= index) { var frs = new LinkedList <find_result_t>(); //up for (int i = index; 0 <= i; i--) { var t = _Array[i]; if (!t.Suffix.StartsWith(suffix)) { break; } foreach (var data in t.Data) { var word = _StringValueGetter.GetStringValue(_Objects[data.ObjIndex]); var endIndex = data.SuffixIndex + suffix.Length; if (endIndex <= word.Length) { if (++findTotalCount <= maxCount) { frs.AddFirst(find_result_t.Create(data.ObjIndex, word, data.SuffixIndex, suffix.Length)); } } } } //down for (int i = index + 1, arrayLength = _Array.Length; i < arrayLength; i++) { var t = _Array[i]; if (!t.Suffix.StartsWith(suffix)) { break; } foreach (var data in t.Data) { var word = _StringValueGetter.GetStringValue(_Objects[data.ObjIndex]); var endIndex = data.SuffixIndex + suffix.Length; if (endIndex <= word.Length) { if (++findTotalCount <= maxCount) { frs.AddLast(find_result_t.Create(data.ObjIndex, word, data.SuffixIndex, suffix.Length)); } } } } return(frs.ToArray()); } return(find_result_t.EMPTY); }
ContainsKey(string suffix, FindModeEnum findMode = FindModeEnum.IgnoreCase) { suffix = CorrectFindSuffix(suffix, findMode); int n = InternalBinarySearch(suffix); return(n >= 0); }
private static string CorrectFindSuffix(string suffix, FindModeEnum findMode) { suffix = suffix.Replace('ё', 'е').Replace('Ё', 'Е'); if (findMode == FindModeEnum.IgnoreCase) { suffix = suffix.ToUpperInvariant(); } return(suffix); }
ContainsKey(string suffix, FindModeEnum findMode = FindModeEnum.IgnoreCase) { suffix = CorrectFindSuffix(suffix, findMode); var tuple = new tuple_t() { Suffix = suffix }; var bpt_tuples = _BPT.GetValues(tuple, StartsWithStringComparer.Inst); return(bpt_tuples.Any()); }
public SearchTarget(Object target, FindModeEnum findMode, string sceneOrStagePath = null) { Asr.IsNotNull(target, "Asset you're trying to search is corrupted"); Target = target; var path = sceneOrStagePath ?? AssetDatabase.GetAssetPath(Target); switch (findMode) { case FindModeEnum.File: Asr.IsTrue(string.IsNullOrEmpty(sceneOrStagePath)); Root = AssetDatabase.LoadMainAssetAtPath(path); Nested = AufUtils.LoadAllAssetsAtPath(path); break; case FindModeEnum.Scene: case FindModeEnum.Stage: Root = Target; if (Target is GameObject go) { Nested = go.GetComponents <Component>().OfType <Object>().ToArray(); Stage = PrefabStageUtility.GetCurrentPrefabStage(); if (findMode == FindModeEnum.Scene) { if (string.IsNullOrEmpty(sceneOrStagePath)) { sceneOrStagePath = go.scene.path; } Scene = SceneManager.GetSceneByPath(sceneOrStagePath); } } else if (Target is Component c) { Nested = default; if (findMode == FindModeEnum.Scene) { if (string.IsNullOrEmpty(sceneOrStagePath)) { sceneOrStagePath = c.gameObject.scene.path; } Scene = SceneManager.GetSceneByPath(sceneOrStagePath); } } else { Nested = default; } break; } }
FindCount(string suffix, FindModeEnum findMode = FindModeEnum.IgnoreCase) { suffix = CorrectFindSuffix(suffix, findMode); var index = InternalBinarySearch(suffix); var findCount = 0; if (0 <= index) { //up for (var i = index; 0 <= i; i--) { var t = _Array[i]; if (!t.Suffix.StartsWith(suffix)) { break; } foreach (var data in t.Data) { var word = _StringValueGetter.GetStringValue(_Objects[data.ObjIndex]); var endIndex = data.SuffixIndex + suffix.Length; if (endIndex <= word.Length) { findCount++; } } } //down for (int i = index + 1, arrayLength = _Array.Length; i < arrayLength; i++) { var t = _Array[i]; if (!t.Suffix.StartsWith(suffix)) { break; } foreach (var data in t.Data) { var word = _StringValueGetter.GetStringValue(_Objects[data.ObjIndex]); var endIndex = data.SuffixIndex + suffix.Length; if (endIndex <= word.Length) { findCount++; } } } } return(findCount); }
public static string GetContentByFindMode(FindModeEnum findMode) { switch (findMode) { case FindModeEnum.File: return("In Project Files"); case FindModeEnum.Scene: return("In Current Scene"); case FindModeEnum.Stage: return("In Current Stage"); default: return("Unknown Content!"); } }
public static string GetWindowTitleByFindMode(FindModeEnum findMode) { switch (findMode) { case FindModeEnum.File: return("Usages in Project"); case FindModeEnum.Scene: return("Usages in Scene"); case FindModeEnum.Stage: return("Usages in Stage"); default: return("Unknown Title!"); } }
public SearchTarget(Object target, FindModeEnum findMode, string sceneOrStagePath = null) { Asr.IsNotNull(target, "Asset you're trying to search is corrupted"); Target = target; var path = sceneOrStagePath ?? AssetDatabase.GetAssetPath(Target); PrefabProperties properties = null; if (target.GetType() == typeof(GameObject)) { properties = PrefabUtilities.GetPrefabProperties(target as GameObject); } if (string.IsNullOrEmpty(sceneOrStagePath) && AssetDatabase.IsSubAsset(Target)) { Root = AssetDatabase.LoadMainAssetAtPath(path); Nested = AufUtils.LoadAllAssetsAtPath(path); //Nested = new[] { Target }; } else if (!string.IsNullOrEmpty(sceneOrStagePath) && Target is GameObject && findMode == FindModeEnum.Stage) { // object in Stage var gg = (GameObject)Target; Nested = gg.GetComponents <Component>().OfType <Object>().ToArray(); Stage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage(); } else if (properties != null && (properties.IsRootOfAnyPrefab || properties.IsAssetRoot)) { Root = AssetDatabase.LoadMainAssetAtPath(path); Nested = AufUtils.LoadAllAssetsAtPath(path); } else if (properties != null && (properties.IsPartOfAnyPrefab || properties.IsPartOfPrefabAsset)) { if (target is GameObject go) { Nested = new[] { Target, } }
public abstract int FindCount(string suffix, FindModeEnum findMode = FindModeEnum.IgnoreCase);
public abstract find_result_t[] Find(string suffix, int maxCount, out int findTotalCount, FindModeEnum findMode = FindModeEnum.IgnoreCase);
public abstract IEnumerable <find_result_t> Find(string suffix, FindModeEnum findMode = FindModeEnum.IgnoreCase);
public abstract bool ContainsKey(string suffix, FindModeEnum findMode = FindModeEnum.IgnoreCase);
public void Reset() { Target = default; Scene = default; From = default; }