private void TryAddEnvironment(AkEnvironment env) { if (env != null) { var index = activeEnvironmentsFromPortals.BinarySearch(env, AkEnvironment.s_compareByPriority); if (index < 0) { activeEnvironmentsFromPortals.Insert(~index, env); index = activeEnvironments.BinarySearch(env, AkEnvironment.s_compareBySelectionAlgorithm); if (index < 0) { activeEnvironments.Insert(~index, env); } isDirty = true; } } }
// METHODS public string Decrypt(string text) { System.Text.StringBuilder sb = new System.Text.StringBuilder(text.Length); System.Collections.Generic.List <char> letters = new System.Collections.Generic.List <char>(alphabet.Letters); for (int i = 0; i < text.Length; ++i) { int index = letters.BinarySearch(text[i]); if (index != -1) { sb.Append(letters[(int)((index + (letters.Count - Z[i])) % letters.Count)]); } else { sb.Append(text[i]); } } return(sb.ToString()); }
private void TryAddEnvironment(AkEnvironment env) { if (env == null) { return; } var index = activeEnvironmentsFromPortals.BinarySearch(env, AkEnvironment.s_compareByPriority); if (index >= 0) { return; } activeEnvironmentsFromPortals.Insert(~index, env); index = activeEnvironments.BinarySearch(env, AkEnvironment.s_compareBySelectionAlgorithm); if (index < 0) { activeEnvironments.Insert(~index, env); } hasEnvironmentListChanged = true; }
private void generateBtn_Click(object sender, System.EventArgs e) { try { int keyLength = int.Parse(keyLengthTb.Text); if (!MathNet.Numerics.Euclid.IsPerfectSquare(keyLength)) { Service.DialogService.ErrorMessage("Should be perfect square"); return; } // generating System.Random random = new System.Random(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); Models.Math.Matrix matrix; int det; do { sb.Clear(); for (int i = 0; i < keyLength; ++i) { sb.Append((char)random.Next('a', 'z')); } var l = new System.Collections.Generic.List <char>(Cipher.Alphabet.Letters); int key = (int)System.Math.Sqrt(keyLength); matrix = new Models.Math.Matrix(key, key, System.Linq.Enumerable.Select(sb.ToString(), c => l.BinarySearch(c))); det = System.Convert.ToInt32(matrix.Determinant()); } while (det == 0 || Models.Math.Algorithms.GCD(det, Cipher.Alphabet.Lenght) != 1); keyTb.Text = sb.ToString(); } catch (System.Exception ex) { Service.DialogService.ErrorMessage(ex.Message); } }
private void UpdateFiles() { m_totWwuCnt = m_WwuToProcess.Count; var iBasePathLen = s_wwiseProjectPath.Length + 1; var iUnprocessed = 0; while (m_WwuToProcess.Count - iUnprocessed > 0) { System.Collections.IEnumerator e = m_WwuToProcess.GetEnumerator(); for (var i = 0; i < iUnprocessed + 1; i++) { e.MoveNext(); } var fullPath = e.Current as string; var relPath = fullPath.Substring(iBasePathLen); var typeStr = relPath.Remove(relPath.IndexOf(System.IO.Path.DirectorySeparatorChar)); if (!CreateWorkUnit(relPath, typeStr, fullPath)) { iUnprocessed++; } } //Add the unprocessed directly. This can happen if we don't find the parent WorkUnit. //Normally, it should never happen, this is just a safe guard. while (m_WwuToProcess.Count > 0) { System.Collections.IEnumerator e = m_WwuToProcess.GetEnumerator(); e.MoveNext(); var fullPath = e.Current as string; var relPath = fullPath.Substring(iBasePathLen); var typeStr = relPath.Remove(relPath.IndexOf(System.IO.Path.DirectorySeparatorChar)); UpdateWorkUnit(fullPath, typeStr, relPath); } foreach (var pair in _WwiseObjectsToAdd) { System.Collections.Generic.List <AkWwiseProjectData.AkBaseInformation> removeList = null; if (!_WwiseObjectsToRemove.TryGetValue(pair.Key, out removeList)) { continue; } removeList.Sort(AkWwiseProjectData.AkBaseInformation.CompareByGuid); foreach (var info in pair.Value) { var index = removeList.BinarySearch(info, AkWwiseProjectData.AkBaseInformation.CompareByGuid); if (index >= 0) { removeList.RemoveAt(index); } } } foreach (var pair in _WwiseObjectsToRemove) { var type = pair.Key; var childType = type == WwiseObjectType.StateGroup ? WwiseObjectType.State : WwiseObjectType.Switch; foreach (var info in pair.Value) { var groupValue = info as AkWwiseProjectData.GroupValue; if (groupValue != null) { foreach (var value in groupValue.values) { WwiseObjectReference.DeleteWwiseObject(childType, value.Guid); } } WwiseObjectReference.DeleteWwiseObject(type, info.Guid); } } UnityEditor.EditorUtility.SetDirty(AkWwiseProjectInfo.GetData()); UnityEditor.EditorUtility.ClearProgressBar(); }
public int BinarySearch(AkRoom room) { return(room ? rooms.BinarySearch(room, s_compareByPriority) : -1); }
public virtual void test() { System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>(); list.BinarySearch(string.Empty); }
public int IndexOf(char letter) { return(letters.BinarySearch(letter)); }