/// <summary>
        ///
        /// </summary>
        /// <param name="methodInnerFor"></param>
        /// <param name="leftToRight"> i ;lt llista.Count or i ;gt= 0 </llista.Count> </param>
        public void For(ForMethodLlistaOrdenada <TKey, TValue> methodInnerFor, bool leftToRight = true)
        {
            if (methodInnerFor == null)
            {
                throw new ArgumentNullException("methodInnerFor");
            }
            ForContinue nextStep = new ForContinue();

            try {
                Monitor.Enter(llista);
                Monitor.Enter(llistaOrdenada);
                if (leftToRight)
                {
                    for (int i = 0; i < llista.Count && !nextStep.Finished; i += nextStep.IncrementOrDecrement)
                    {
                        nextStep = methodInnerFor(i, llista[i], llistaOrdenada[llista[i]]);
                    }
                }
                else
                {
                    for (int i = llista.Count - 1; i >= 0 && !nextStep.Finished; i -= nextStep.IncrementOrDecrement)
                    {
                        nextStep = methodInnerFor(i, llista[i], llistaOrdenada[llista[i]]);
                    }
                }
            } catch {
                throw;
            } finally {
                Monitor.Exit(llista);
                Monitor.Exit(llistaOrdenada);
            }
        }
Example #2
0
        private void CopyTo(KeyValuePair <TwoKeys <TKey1, TKey2>, TValue>[] array, int arrayIndex = 0)
        {
            ForContinue nextStep = new ForContinue();

            For((i, tkey1, tkey2, tvalue) =>
            {
                array[arrayIndex++] = new KeyValuePair <TwoKeys <TKey1, TKey2>, TValue>(new TwoKeys <TKey1, TKey2>(tkey1, tkey2), tvalue);
                return(nextStep);
            });
        }
Example #3
0
        public IEnumerator <KeyValuePair <TwoKeys <TKey1, TKey2>, TValue> > GetEnumerator()
        {
            KeyValuePair <TwoKeys <TKey1, TKey2>, TValue>[] enumerator = new KeyValuePair <TwoKeys <TKey1, TKey2>, TValue> [llista1.Count];
            ForContinue nextStep = new ForContinue();

            For((i, tkey1, tkey2, tvalue) =>
            {
                enumerator[i] = new KeyValuePair <TwoKeys <TKey1, TKey2>, TValue>(new TwoKeys <TKey1, TKey2>(tkey1, tkey2), tvalue);
                return(nextStep);
            });
            return(enumerator.ObtieneEnumerador());
        }