public void CheckAliases() { FieldTranslationEntry entry1, entry2; DbField [] keys = new DbField [Keys.Count]; Keys.CopyTo(keys, 0); for (int i = 0; i < keys.Length; i++) { entry1 = base [keys [i]]; string ent1Name = useAltNames ? entry1.AltName : entry1.Name; for (int j = i + 1; j < keys.Length; j++) { entry2 = base [keys [j]]; string ent2Name = useAltNames ? entry2.AltName : entry2.Name; if (ent1Name != ent2Name) { continue; } if (entry1.Alias == entry2.Alias) { throw new Exception(string.Format("Matching keys({0} and {1}) with same aliases found.", keys [i], keys [j])); } } } }
/// <summary> /// Convert the object to its JSON representation. /// </summary> /// <returns>A string containing the JSON representation of the object.</returns> public override string ToString() { string result = ""; string[] keys = new string[Count]; object[] values = new object[Count]; Keys.CopyTo(keys, 0); Values.CopyTo(values, 0); for (int i = 0; i < Count; i++) { if (result.Length > 0) { result += ", "; } string value = ""; using (Json js = new Json()) { value = js.ToJson(values[i]); if (value == null) { continue; } } result += "\"" + keys[i] + "\""; result += ": "; result += value; } return("{" + result + "}"); }
public IEnumerable <T> CloneKeys() { var keys = new T[Count]; Keys.CopyTo(keys, 0); return(keys); }
public List <T> CloneKeys() { var keys = new T[Count]; Keys.CopyTo(keys, 0); return(keys.ToList()); }
public K GetKey(int index) { var keys = new K[Keys.Count]; Keys.CopyTo(keys, 0); return(keys[index]); }
public K[] GetKeys() { var keys = new K[Keys.Count]; Keys.CopyTo(keys, 0); return(keys); }
public SerializableDictionary(SerializableDictionary copyfrom) : base(copyfrom) { string[] keyscopy = new string[Keys.Count]; Keys.CopyTo(keyscopy, 0); foreach (string key in keyscopy) { this[key] = this[key].clone(); } }
public override void Clear() { Debug.Assert(Keys != null); var keys = new string[Keys.Count]; Keys.CopyTo(keys, 0); foreach (var k in keys) { Remove(k); } }
public CustomProperties(CustomProperties copy) : base(copy, StringComparer.InvariantCultureIgnoreCase) { var keyscopy = new string[Keys.Count]; Keys.CopyTo(keyscopy, 0); foreach (string key in keyscopy) { this[key] = this[key].Clone(); } }
/// <summary> /// Filter blobs by label. /// Delete all blobs except those with label l. /// </summary> /// <param name="label">Label to leave.</param> public void FilterByLabel(int label) { int[] keys = new int[Count]; Keys.CopyTo(keys, 0); foreach (int key in keys) { if (this[key].Label != label) { Remove(key); } } }
void RefreshArrays() { if (Count != KeyArray.Length) { KeyArray = new TKey[Count]; } if (Count != ValueArray.Length) { ValueArray = new TValue[Count]; } Keys.CopyTo(KeyArray, 0); Values.CopyTo(ValueArray, 0); }
/// <summary> /// Filter blobs by area. /// Those blobs whose areas are not in range will be erased from the input list of blobs. (cvFilterByArea) /// </summary> /// <param name="minArea">Minimun area.</param> /// <param name="maxArea">Maximun area.</param> public void FilterByArea(int minArea, int maxArea) { int[] keys = new int[Count]; Keys.CopyTo(keys, 0); foreach (int key in keys) { int area = this[key].Area; if (area < minArea || area > maxArea) { Remove(key); } } }
public virtual void Set(K key) { var keys = new K[Keys.Count]; Keys.CopyTo(keys, 0); var index = keys.ToList().IndexOf(key); if (index == -1) { return; } Index = index; Set(Index); }
/// <summary> /// When implemented by a class, copies the elements of /// the <see cref="T:System.Collections.ICollection"/> to an <see cref="T:System.Array"/>, starting at a particular <see cref="T:System.Array"/> index. /// </summary> /// <param name="array">The one-dimensional <see cref="T:System.Array"/> that is the destination of the elements copied from <see cref="T:System.Collections.ICollection"/>. The <see cref="T:System.Array"/> must have zero-based indexing.</param> /// <param name="index">The zero-based index in <paramref name="array"/> at which copying begins.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="array"/> is <see langword="null"/>.</exception> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// <paramref name="index"/> is less than zero.</exception> /// <exception cref="T:System.ArgumentException"> /// <para> /// <paramref name="array"/> is multidimensional.</para> /// <para>-or-</para> /// <para> /// <paramref name="index"/> is equal to or greater than the length of <paramref name="array"/>.</para> /// <para>-or-</para> /// <para>The number of elements in the source <see cref="T:System.Collections.ICollection"/> is greater than the available space from <paramref name="index"/> to the end of the destination <paramref name="array"/>.</para> /// </exception> /// <exception cref="T:System.InvalidCastException">The type of the source <see cref="T:System.Collections.ICollection"/> cannot be cast automatically to the type of the destination <paramref name="array"/>.</exception> public virtual void CopyTo(Array array, int index) { TKey[] keys = new TKey[Count]; TValue[] values = new TValue[Count]; Keys.CopyTo(keys, index); Values.CopyTo(values, index); for (int i = index; i < Count; i++) { if (!Equals(keys[i], default(TKey)) || !Equals(values[i], default(TValue))) { array.SetValue(new DictionaryEntry(keys[i], values[i]), i); } } }
public void Add(KeyType key, ValueType value) { int count = Keys.Length + 1; KeyType[] keyTemp = new KeyType[count]; ValueType[] valueTemp = new ValueType[count]; Keys.CopyTo(keyTemp, 0); Values.CopyTo(valueTemp, 0); keyTemp[count - 1] = key; valueTemp[count - 1] = value; Keys = keyTemp; Values = valueTemp; }
// シリアル化(保存)前に呼ばれる. // DictionaryをSerializeFieldに設定し、この関数終了後、SerializeFieldが保存される. public void OnBeforeSerialize() { // キーを配列にコピーする. keyArray = new TKey[Keys.Count]; Keys.CopyTo(keyArray, 0); // 値を配列にコピーする. valArray = new TValue[Values.Count]; Values.CopyTo(valArray, 0); // if (this.Count > 0) // { // itemList = new SerializableList<KeyValuePair<TKey, TValue>>(); // foreach (KeyValuePair<TKey, TValue> kv in this) // { // itemList.Add(kv); // } // } }
/// <summary> /// When implemented by a class, copies the elements of /// the <see cref="T:System.Collections.ICollection"/> to an <see cref="T:System.Array"/>, starting at a particular <see cref="T:System.Array"/> index. /// </summary> /// <param name="array">The one-dimensional <see cref="T:System.Array"/> that is the destination of the elements copied from <see cref="T:System.Collections.ICollection"/>. The <see cref="T:System.Array"/> must have zero-based indexing.</param> /// <param name="index">The zero-based index in <paramref name="array"/> at which copying begins.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="array"/> is <see langword="null"/>.</exception> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// <paramref name="index"/> is less than zero.</exception> /// <exception cref="T:System.ArgumentException"> /// <para> /// <paramref name="array"/> is multidimensional.</para> /// <para>-or-</para> /// <para> /// <paramref name="index"/> is equal to or greater than the length of <paramref name="array"/>.</para> /// <para>-or-</para> /// <para>The number of elements in the source <see cref="T:System.Collections.ICollection"/> is greater than the available space from <paramref name="index"/> to the end of the destination <paramref name="array"/>.</para> /// </exception> /// <exception cref="T:System.InvalidCastException">The type of the source <see cref="T:System.Collections.ICollection"/> cannot be cast automatically to the type of the destination <paramref name="array"/>.</exception> public virtual void CopyTo(Array array, int index) { object[] keys = new object[Count]; object[] values = new object[Count]; if (Keys != null) { Keys.CopyTo(keys, index); } if (Values != null) { Values.CopyTo(values, index); } for (int i = index; i < Count; i++) { if (keys[i] != null || values[i] != null) { array.SetValue(new DictionaryEntry(keys[i], values[i]), i); } } }
/// <summary> /// Remove any element thats not marked to be kept. /// This method is automatically called by the framework after the controller is processed. /// </summary> public void Sweep() { if (hasSwept) { object[] keys = new object[Keys.Count]; Keys.CopyTo(keys, 0); if (keys.Length != 0) { keep.AddRange(keys); } } if (keep.Count == 0) { Clear(); } else { object[] keys = new object[Keys.Count]; Keys.CopyTo(keys, 0); for (int i = 0; i < keys.Length; i++) { if (!keep.Contains(keys[i])) { Remove(keys[i]); } else if (!hasItemsToKeep) { hasItemsToKeep = true; } } keep.Clear(); } hasSwept = true; }
public Node Pop1() //0.06 ms //Get lowest element { Node[] ar = new Node[Keys.Count]; Keys.CopyTo(ar, 0); int m = 0; double d = ar[m].fval; for (int i = 1; i < ar.Length; i++) { if (ar[i].fval < d) { m = i; d = ar[m].fval; } } Node ret = ar[m]; Remove(ar[m]); return(ret); }
// Get the serialization data for this object. public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { if (info == null) { throw new ArgumentNullException("info"); } info.AddValue("LoadFactor", loadFactor); info.AddValue("Version", generation); info.AddValue("Comparer", comparer, typeof(IComparer)); info.AddValue("HashCodeProvider", hcp, typeof(IHashCodeProvider)); info.AddValue("HashSize", (table == null ? 0 : table.Length)); Object[] keyTemp = new Object [num]; Keys.CopyTo(keyTemp, 0); info.AddValue("Keys", keyTemp, typeof(Object[])); Object[] valTemp = new Object [num]; Values.CopyTo(valTemp, 0); info.AddValue("Values", valTemp, typeof(Object[])); }
void ICollection <KeyValuePair <TKey, TValue> > .CopyTo(KeyValuePair <TKey, TValue>[] array, int arrayIndex) { int c = Count; TKey[] keys = new TKey[c]; TValue[] values = new TValue[c]; if (Keys != null) { Keys.CopyTo(keys, arrayIndex); } if (Values != null) { Values.CopyTo(values, arrayIndex); } for (int i = arrayIndex; i < c; i++) { if (keys[i] != null || values[i] != null) { array.SetValue(new KeyValuePair <TKey, TValue>(keys[i], values[i]), i); } } }
public void CopyTo(KeyValuePair <TKey, TValue>[] array, int arrayIndex) { int c = Count; var keys = new TKey[c]; var values = new TValue[c]; if (Keys != null) { Keys.CopyTo(keys, arrayIndex); } if (Values != null) { Values.CopyTo(values, arrayIndex); } for (int i = arrayIndex; i < c; i++) { if (keys[i] != null || values[i] != null) { array.SetValue(new KeyValuePair <TKey, TValue>(keys[i], values[i]), i); } } }
/// <summary> /// Returns a <see cref="System.String"/> representation of this instance. /// </summary> public override string ToString() { int count = Count; if (count == 0) { return(""); } StringBuilder sb = new StringBuilder(); string[] keys = new string[Keys.Count]; Keys.CopyTo(keys, 0); for (int i = 0; i < count; i++) { sb.AppendFormat("{0}={1}&", keys[i], this[keys[i]]); } if (sb.Length > 0) { sb.Length--; } return(sb.ToString()); }
public string[] GetCommandsList() { string[] res = new string[Count]; Keys.CopyTo(res, 0); return(res); }
public void CopyTo(T[] array, int arrayIndex) => Keys.CopyTo(array, arrayIndex);
/// <summary> /// Used for loading in custom key controls when restoring a saved game /// </summary> /// <param name="loadableKeys">A Keys[] representation of the key controls</param> public static void loadKeyControls(Keys[] loadableKeys) { nullCheck(); if (loadableKeys.Length == keyTypes.Length) loadableKeys.CopyTo(keyTypes, 0); else System.Diagnostics.Debug.WriteLine("Invalid array input; size must be same"); }
internal Set <T1> keySet() { T1 [] keys = new T1[Count]; Keys.CopyTo(keys, 0); return(new Set <T1>(keys)); }