コード例 #1
0
        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]));
                    }
                }
            }
        }
コード例 #2
0
ファイル: JsonObject.cs プロジェクト: izdeveloper/IZTrigger
        /// <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 + "}");
        }
コード例 #3
0
ファイル: ConcurrentList.cs プロジェクト: saddam213/HiveFive
        public IEnumerable <T> CloneKeys()
        {
            var keys = new T[Count];

            Keys.CopyTo(keys, 0);
            return(keys);
        }
コード例 #4
0
        public List <T> CloneKeys()
        {
            var keys = new T[Count];

            Keys.CopyTo(keys, 0);
            return(keys.ToList());
        }
コード例 #5
0
        public K GetKey(int index)
        {
            var keys = new K[Keys.Count];

            Keys.CopyTo(keys, 0);
            return(keys[index]);
        }
コード例 #6
0
        public K[] GetKeys()
        {
            var keys = new K[Keys.Count];

            Keys.CopyTo(keys, 0);
            return(keys);
        }
コード例 #7
0
 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();
     }
 }
コード例 #8
0
        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);
            }
        }
コード例 #9
0
        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();
            }
        }
コード例 #10
0
        /// <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);
                }
            }
        }
コード例 #11
0
        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);
        }
コード例 #12
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);
                }
            }
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        /// <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);
                }
            }
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: Ysera86/MyDictionary
        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;
        }
コード例 #16
0
 // シリアル化(保存)前に呼ばれる.
 //  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);
     //			}
     //		}
 }
コード例 #17
0
 /// <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);
         }
     }
 }
コード例 #18
0
        /// <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;
        }
コード例 #19
0
ファイル: priority_queue.cs プロジェクト: alexsaen/klopodavka
        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);
        }
コード例 #20
0
        // 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[]));
        }
コード例 #21
0
        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);
                }
            }
        }
コード例 #22
0
        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);
                }
            }
        }
コード例 #23
0
            /// <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());
            }
コード例 #24
0
ファイル: ConsoleFramework.cs プロジェクト: kOVC/CodeJam
 public string[] GetCommandsList()
 {
     string[] res = new string[Count];
     Keys.CopyTo(res, 0);
     return(res);
 }
コード例 #25
0
 public void CopyTo(T[] array, int arrayIndex) => Keys.CopyTo(array, arrayIndex);
コード例 #26
0
 /// <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");
 }
コード例 #27
0
 internal Set <T1> keySet()
 {
     T1 [] keys = new T1[Count];
     Keys.CopyTo(keys, 0);
     return(new Set <T1>(keys));
 }