Example #1
0
        public void MultiThreaded()
        {
            var all = new List <my>();
            var set = new FiniteSetLookup <int, my>(k => { var v = new my {
                                                               Tag = k
                                                           }; all.Add(v); return(v); });

            Parallel.For(0, 1000, i =>
            {
                var key = i % 7;
                var got = set[key];
                Aver.AreEqual(key, got.Tag);
            });

            Aver.AreEqual(7, all.Count);
            Aver.AreEqual(7, set.Count);

            var deleted = 0;

            Parallel.For(0, 1000, i =>
            {
                var key = i % 5;
                if (set.Remove(key))
                {
                    Interlocked.Increment(ref deleted);
                }
            });

            Aver.AreEqual(2, set.Count);
            Aver.AreEqual(5, deleted);
        }
Example #2
0
        public void SingleThreaded()
        {
            var all = new List <my>();
            var set = new FiniteSetLookup <int, my>(k => { var v = new my {
                                                               Tag = k
                                                           }; all.Add(v); return(v); });

            for (var i = 0; i < 1000; i++)
            {
                var key = i % 7;
                var got = set[key];
                Aver.AreEqual(key, got.Tag);
            }

            Aver.AreEqual(7, all.Count);
            Aver.AreEqual(7, set.Count);


            var deleted = 0;

            for (var i = 0; i < 1000; i++)
            {
                var key = i % 5;
                if (set.Remove(key))
                {
                    deleted++;
                }
            }
            Aver.AreEqual(2, set.Count);
            Aver.AreEqual(5, deleted);
        }
Example #3
0
    public static Exchange ExchangeHandler(my args)
    {
        Exchange oExchange = new ExchangeA();     // Could also be ExchangeB or ExchangeC being instantiated here

        iRet = oExchange.retrieve(szLevel, szCurrencyBase, oExchange.instrumentDataProcess);

        if (iRet == 0)
        {
            return(nil);
        }
        return(oExchange);
    }
Example #4
0
        static void Main(string[] args)
        {
            my a = new my();

            a.print();
            Console.WriteLine();

            my b = new my(1);

            b.print();
            Console.WriteLine();

            my c = new my(10, 20);

            c.print();
            Console.WriteLine();
        }
Example #5
0
 private static int distance_between(my.utils.Diff.Item change, my.utils.Diff.Item nextChange)
 {
     return nextChange.StartB - change.StartB + change.insertedB;
 }