Exemplo n.º 1
0
        public void Find_ReturnsIndexesWithExpectedOrdering()
        {
            SortedTable <int> table = new SortedTable <int>();

            table.Add(1);
            table.Add(2);
            table.Add(3);

            SortedTable <int> .Index index1 = table.Find(1);
            SortedTable <int> .Index index2 = table.Find(2);
            SortedTable <int> .Index index3 = table.Find(3);

            Assert.True(index1.CompareTo(index1) == 0);
            Assert.True(index1.Equals(index1));
            Assert.False(index1.Equals(index2));
            Assert.True(index1.CompareTo(index2) < 0);
            Assert.True(index1.CompareTo(index3) < 0);

            Assert.True(index2.CompareTo(index1) > 0);
            Assert.True(index2.CompareTo(index2) == 0);
            Assert.True(index2.Equals(index2));
            Assert.False(index2.Equals(index3));
            Assert.True(index2.CompareTo(index3) < 0);

            Assert.True(index3.CompareTo(index1) > 0);
            Assert.True(index3.CompareTo(index2) > 0);
            Assert.True(index3.CompareTo(index3) == 0);
            Assert.True(index3.Equals(index3));
            Assert.False(index3.Equals(index1));
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        protected override RidList FindAllRowsUnsorted(MDTable tableSource, int keyColIndex, uint key)
        {
            if (tableSource == null)
            {
                return(RidList.Empty);
            }
            if (tablesStream.IsSorted(tableSource))
            {
                return(FindAllRows(tableSource, keyColIndex, key));
            }
            SortedTable sortedTable;

#if THREAD_SAFE
            theLock.EnterWriteLock(); try {
#endif
            if (!sortedTables.TryGetValue(tableSource.Table, out sortedTable))
            {
                sortedTables[tableSource.Table] = sortedTable = new SortedTable(tableSource, keyColIndex);
            }
#if THREAD_SAFE
        }

        finally { theLock.ExitWriteLock(); }
#endif
            return(sortedTable.FindAllRows(key));
        }
        public FxClientSyncfusionViewModel(IFxDataService dataService)
        {
            _dataService = dataService;
            var ratesTable = dataService.FxRates;

            _sortedRates = new SortedTable(ratesTable);
            _sortedRates.SortBy(FxTableDefinitions.FxRates.CcyPairId, Comparer <string> .Default);
            SetTable(_sortedRates);

            _columnTypes = new Dictionary <string, Type>
            {
                { FxTableDefinitions.FxRates.CcyPairId, typeof(string) },
                { FxTableDefinitions.FxRates.Bid, typeof(double) },
                { FxTableDefinitions.FxRates.Ask, typeof(double) },
                { FxTableDefinitions.FxRates.Open, typeof(double) },
                { FxTableDefinitions.FxRates.Close, typeof(double) },
                { FxTableDefinitions.FxRates.Change, typeof(double) },
                { FxTableDefinitions.FxRates.YearRangeStart, typeof(double) },
                { FxTableDefinitions.FxRates.YearRangeEnd, typeof(double) },
                { FxTableDefinitions.FxRates.Time, typeof(DateTime) },
                { FxTableDefinitions.FxRates.Ticks, typeof(double) },
            };
            Columns = new ObservableCollection <string>(_columnTypes.Keys);

            dataService.Start(Application.Current.Dispatcher);
        }
Exemplo n.º 4
0
        private int Add(string NameC, int Code)
        {
            int i = MainTable.Count;

            MainTable.Add(new SymbolTableItem(NameC, Code));
            SortedTable.Add(NameC, i);
            return(i);
        }
Exemplo n.º 5
0
        }         // GetEnabledStatus

        public QuickOfferConfiguration(AConnection oDB, ASafeLog oLog)
        {
            m_oDB              = oDB;
            m_oLog             = new SafeLog(oLog);
            m_bIsLoaded        = false;
            m_oOfferAmountPct  = new List <Tuple <int, decimal> >();
            m_oPriceCalculator = new SortedTable <int, int, decimal>();
        }         // constructor
Exemplo n.º 6
0
 public LoadEsignatures(int?nCustomerID, bool bPollStatus)
 {
     m_bPollStatus = bPollStatus;
     Result        = new SortedTable <int, long, Esignature>();
     m_oSp         = new LoadCustomerEsignatures(DB, Log)
     {
         CustomerID = nCustomerID,
     };
     m_nCustomerID = nCustomerID;
 }         // constructor
Exemplo n.º 7
0
		/// <inheritdoc/>
		protected override RidList FindAllRowsUnsorted(MDTable tableSource, int keyColIndex, uint key) {
			if (tableSource == null)
				return ContiguousRidList.Empty;
			if (tablesStream.IsSorted(tableSource))
				return FindAllRows(tableSource, keyColIndex, key);
			SortedTable sortedTable;
			if (!sortedTables.TryGetValue(tableSource.Table, out sortedTable))
				sortedTables[tableSource.Table] = sortedTable = new SortedTable(tableSource, keyColIndex);
			return sortedTable.FindAllRows(key);
		}
Exemplo n.º 8
0
        public void Find_Empty_AlwaysReturnsInvalidIndex()
        {
            SortedTable <int> table = new SortedTable <int>();

            SortedTable <int> .Index index = table.Find(1);
            Assert.False(index.IsValid);

            index = table.Find(2);
            Assert.False(index.IsValid);
        }
Exemplo n.º 9
0
        public void Find_NotEmptyButNotPresent_ReturnsInvalidIndex()
        {
            SortedTable <int> table = new SortedTable <int>();

            table.Add(1);
            table.Add(2);

            SortedTable <int> .Index index = table.Find(3);

            Assert.False(index.IsValid);
        }
Exemplo n.º 10
0
        }         // Main

        private Program()
        {
            m_oLog = new ConsoleLog(new FileLog("UiEventAddressFixer"));

            var env = new Ezbob.Context.Environment(m_oLog);

            m_oDB = new SqlConnection(env, m_oLog);

            m_oEvents    = new SortedTable <int, long, EventInfo>();
            m_oLastKnown = new SortedSet <string>();
        }         // constructor
Exemplo n.º 11
0
        public FileManager(string filePath, int blockSize, bool resetFile = true)
        {
            _fileStream = new FileStream(filePath, FileMode.OpenOrCreate);
            if (resetFile)
            {
                _fileStream.Seek(0, SeekOrigin.Begin);
                _fileStream.SetLength(0);
            }

            _freeAddresses = new SortedTable <int, int>();
            _blockSize     = blockSize;
        }
Exemplo n.º 12
0
        public void Add_UpdatesCount()
        {
            SortedTable <int> table = new SortedTable <int>();

            Assert.Equal(0, table.Count);

            table.Add(1);
            Assert.Equal(1, table.Count);

            table.Add(2);
            Assert.Equal(2, table.Count);
        }
Exemplo n.º 13
0
        private static void CheckValuesAreSorted(int count, SortedTable table)
        {
            Assert.AreEqual(count, table.RowCount);
            for (var i = 0; i < table.RowCount; i++)
            {
                var id = table.GetValue <int>(TestTableColumns.IdColumn, i);
                var s  = table.GetValue <string>(TestTableColumns.StringColumn, i);

                Assert.AreEqual(i, id);
                Assert.AreEqual($"Item #{i.ToString("0000")}", s);
            }
        }
Exemplo n.º 14
0
        public void TestFillingTable()
        {
            var       sourceTable = TestTableHelper.CreateReactiveTable();
            const int count       = 100;

            var table = new SortedTable(sourceTable);

            table.SortBy(TestTableColumns.StringColumn, Comparer <string> .Default);

            AddValuesInReverseOrder(count, sourceTable);
            CheckValuesAreSorted(count, table);
        }
Exemplo n.º 15
0
        public void Enumerator_Empty_YieldsNothing()
        {
            SortedTable <int> table = new SortedTable <int>();

            int count = 0;

            foreach (int item in table)
            {
                ++count;
            }

            Assert.Equal(0, count);
        }
Exemplo n.º 16
0
        public UiReportExt(AConnection oDB, DateTime oDateStart, DateTime oDateEnd, ASafeLog log) : base(log)
        {
            VerboseLogging = false;

            m_oDB        = oDB;
            m_oDateStart = oDateStart;
            m_oDateEnd   = oDateEnd;

            m_oControls        = new SortedDictionary <int, UiControlData>();
            m_oCustomers       = new SortedDictionary <int, CustomerData>();
            m_oCustomerControl = new SortedTable <int, int, bool>();

            m_oCurHandler = null;
        }         // constructor
Exemplo n.º 17
0
        public void Find_NotEmptyAndPresent_ReturnsValidIndex()
        {
            SortedTable <int> table = new SortedTable <int>();

            table.Add(1);
            table.Add(2);
            table.Add(3);

            SortedTable <int> .Index index = table.Find(3);
            Assert.True(index.IsValid);

            index = table.Find(1);
            Assert.True(index.IsValid);
        }
Exemplo n.º 18
0
        public void Add_ReturnsTrueIfAddedFalseIfAlreadyPresent()
        {
            SortedTable <int> table = new SortedTable <int>();

            Assert.True(table.Add(1));
            Assert.Equal(1, table.Count);

            Assert.False(table.Add(1));
            Assert.Equal(1, table.Count);

            Assert.True(table.Add(2));
            Assert.Equal(2, table.Count);

            Assert.False(table.Add(2));
            Assert.Equal(2, table.Count);
        }
Exemplo n.º 19
0
        private void _InitContainers(int size)
        {
            _typeArray = TestTools.EnumerateTypes().Take(size).ToArray();

            _sortedTable = new SortedTable <Type, object>(size, TypeComparer.Instance);
            _dict        = new Dictionary <Type, object>(size);
            _hashtable   = new Hashtable(size);

            for (int i = 0; i < size; ++i)
            {
                var type = _typeArray[i];
                _sortedTable[type] = type;
                _dict[type]        = type;
                _hashtable[type]   = type;
            }
        }
Exemplo n.º 20
0
        public void Crunch_ColumnsLessThanRows_ReturnsColumnIndexesFirst()
        {
            Word2Grid           grid  = new Word2Grid(new Word2("zb"), new Word2("ae"));
            SortedTable <Word2> table = new SortedTable <Word2>();

            table.Add(new Word2("ae"));
            table.Add(new Word2("be"));
            table.Add(new Word2("za"));
            table.Add(new Word2("zb"));

            Word2GridCruncher cruncher     = new Word2GridCruncher(table);
            CrunchedWord2Grid crunchedGrid = cruncher.Crunch(grid);

            CrunchedWord2Grid expectedGrid = new CrunchedWord2Grid(Idx(3), Idx(2), Idx(4), Idx(1));

            Assert.Equal(expectedGrid, crunchedGrid);
        }
Exemplo n.º 21
0
        public void Enumerator_YieldsInOrder()
        {
            SortedTable <int> table = new SortedTable <int>();

            table.Add(4);
            table.Add(2);
            table.Add(3);
            table.Add(1);

            List <int> items = new List <int>();

            foreach (int item in table)
            {
                items.Add(item);
            }

            Assert.Equal(new int[] { 1, 2, 3, 4 }, items.ToArray());
        }
Exemplo n.º 22
0
 /// <summary>
 /// Find Symbol in Symbol table if exist return Symbol code or add in Symbol table
 /// </summary>
 /// <param name="SymbolName"></param>
 /// <param name="SymbolCode"></param>
 /// <returns></returns>
 public int FindSymbolInSymbolTable(string SymbolName, int SymbolCode)
 {
     if (MainTable.Count != 0)
     {
         if (!SortedTable.ContainsKey(SymbolName))
         {
             return(Add(SymbolName, SymbolCode));
         }
         else
         {
             return(SortedTable[SymbolName]);
         }
     }
     else
     {
         return(Add(SymbolName, SymbolCode));
     }
 }
Exemplo n.º 23
0
        public void Crunch_FirstColumnAndRowEqualButSecondColumnGreater_ReturnsRowIndexesFirst()
        {
            Word3Grid           grid  = new Word3Grid(new Word3("abc"), new Word3("baa"), new Word3("cza"));
            SortedTable <Word3> table = new SortedTable <Word3>();

            table.Add(new Word3("abc"));
            table.Add(new Word3("baa"));
            table.Add(new Word3("baz"));
            table.Add(new Word3("caa"));
            table.Add(new Word3("cza"));

            Word3GridCruncher cruncher     = new Word3GridCruncher(table);
            CrunchedWord3Grid crunchedGrid = cruncher.Crunch(grid);

            CrunchedWord3Grid expectedGrid = new CrunchedWord3Grid(Idx(1), Idx(2), Idx(5), Idx(1), Idx(3), Idx(4));

            Assert.Equal(expectedGrid, crunchedGrid);
        }
Exemplo n.º 24
0
        }         // GetItem

        public virtual string ToFormattedString()
        {
            var tbl = new SortedTable <string, string, string>();

            foreach (var pair in this.data)
            {
                string key = pair.Key.ToString();

                foreach (var pp in pair.Value)
                {
                    tbl[key, pp.Key.ToString()] = pp.Value == null
                                                ? "- null -"
                                                : pp.Value.Value.ToString("N6", CultureInfo.InvariantCulture);
                }         // for each column
            }             // for each

            return(tbl.ToFormattedString());
        }         // ToFormattedString
Exemplo n.º 25
0
        public void Crunch_FirstAndSecondColumnAndRowEqualButThirdRowGreater_ReturnsColumnIndexesFirst()
        {
            Word4Grid           grid  = new Word4Grid(new Word4("abcd"), new Word4("bcde"), new Word4("cdaz"), new Word4("deaa"));
            SortedTable <Word4> table = new SortedTable <Word4>();

            table.Add(new Word4("abcd"));
            table.Add(new Word4("bcde"));
            table.Add(new Word4("cdaa"));
            table.Add(new Word4("cdaz"));
            table.Add(new Word4("deaa"));
            table.Add(new Word4("deza"));

            Word4GridCruncher cruncher     = new Word4GridCruncher(table);
            CrunchedWord4Grid crunchedGrid = cruncher.Crunch(grid);

            CrunchedWord4Grid expectedGrid = new CrunchedWord4Grid(Idx(1), Idx(2), Idx(3), Idx(6), Idx(1), Idx(2), Idx(4), Idx(5));

            Assert.Equal(expectedGrid, crunchedGrid);
        }
Exemplo n.º 26
0
        public void Crunch_ColumnsLessThanRows_ReturnsColumnIndexesFirst()
        {
            Word3Grid           grid  = new Word3Grid(new Word3("zbc"), new Word3("aef"), new Word3("ahi"));
            SortedTable <Word3> table = new SortedTable <Word3>();

            table.Add(new Word3("aef"));
            table.Add(new Word3("ahi"));
            table.Add(new Word3("beh"));
            table.Add(new Word3("cfi"));
            table.Add(new Word3("zaa"));
            table.Add(new Word3("zbc"));

            Word3GridCruncher cruncher     = new Word3GridCruncher(table);
            CrunchedWord3Grid crunchedGrid = cruncher.Crunch(grid);

            CrunchedWord3Grid expectedGrid = new CrunchedWord3Grid(Idx(5), Idx(3), Idx(4), Idx(6), Idx(1), Idx(2));

            Assert.Equal(expectedGrid, crunchedGrid);
        }
Exemplo n.º 27
0
        public SyncfusionTestViewModel(IAccountBalanceDataService dataService)
        {
            var table = dataService.AccountPeople;

            _accountFilter = (FilteredTable)table.Filter(
                new DelegatePredicate1 <decimal>(AccountColumns.AccountBalance, b => b > BalanceBelowFilter));
            _balanceSort = new SortedTable(_accountFilter);
            _balanceSort.SortBy(AccountColumns.AccountBalance, Comparer <decimal> .Default);
            SetTable(_balanceSort);

            _columnTypes = new Dictionary <string, Type>
            {
                { AccountColumns.AccountBalance, typeof(decimal) },
                { PersonColumns.IdNameColumn, typeof(string) },
                { PersonColumns.NameColumn, typeof(string) },
                { PersonAccountColumns.AccountDetails, typeof(string) }
            };
            Columns = new ObservableCollection <string>(_columnTypes.Keys);
        }
Exemplo n.º 28
0
        public void Crunch_ColumnsLessThanRows_ReturnsColumnIndexesFirst()
        {
            Word4Grid           grid  = new Word4Grid(new Word4("zbcd"), new Word4("aefg"), new Word4("ahij"), new Word4("aklm"));
            SortedTable <Word4> table = new SortedTable <Word4>();

            table.Add(new Word4("aefg"));
            table.Add(new Word4("ahij"));
            table.Add(new Word4("aklm"));
            table.Add(new Word4("behk"));
            table.Add(new Word4("cfil"));
            table.Add(new Word4("dgjm"));
            table.Add(new Word4("zaaa"));
            table.Add(new Word4("zbcd"));

            Word4GridCruncher cruncher     = new Word4GridCruncher(table);
            CrunchedWord4Grid crunchedGrid = cruncher.Crunch(grid);

            CrunchedWord4Grid expectedGrid = new CrunchedWord4Grid(Idx(7), Idx(4), Idx(5), Idx(6), Idx(8), Idx(1), Idx(2), Idx(3));

            Assert.Equal(expectedGrid, crunchedGrid);
        }
Exemplo n.º 29
0
        }         // HasValidParameters

        public SortedTable <int, long, Esignature> Load()
        {
            var oResult = new SortedTable <int, long, Esignature>();

            ForEachResult <ResultRow>(oRow => {
                if (!oResult.Contains(oRow.CustomerID))
                {
                    oResult[oRow.CustomerID, oRow.EsignatureID] = oRow.CreateEsignature();
                    return(ActionResult.Continue);
                }                 // if

                if (!oResult.Contains(oRow.CustomerID, oRow.EsignatureID))
                {
                    oResult[oRow.CustomerID, oRow.EsignatureID] = oRow.CreateEsignature();
                    return(ActionResult.Continue);
                }                 // if

                oResult[oRow.CustomerID, oRow.EsignatureID].Signers.Add(oRow.CreateEsigner());
                return(ActionResult.Continue);
            });

            return(oResult);
        }         // Load
Exemplo n.º 30
0
        public void TestUpdatingSortKey()
        {
            var       sourceTable = TestTableHelper.CreateReactiveTable();
            const int count       = 100;

            AddValuesInReverseOrder(count, sourceTable);

            var table = new SortedTable(sourceTable);

            table.SortBy(TestTableColumns.StringColumn, Comparer <string> .Default);
            CheckValuesAreSorted(count, table);

            var rowId = 5;

            sourceTable.SetValue(TestTableColumns.StringColumn, rowId, "_");

            Assert.AreEqual("_", table.GetValue(TestTableColumns.StringColumn, 0));

            rowId = 6;
            sourceTable.SetValue(TestTableColumns.StringColumn, rowId, "X");

            Assert.AreEqual("X", table.GetValue(TestTableColumns.StringColumn, count - 1));
        }
Exemplo n.º 31
0
		/// <inheritdoc/>
		protected override RidList FindAllRowsUnsorted(MDTable tableSource, int keyColIndex, uint key) {
			if (tablesStream.IsSorted(tableSource))
				return FindAllRows(tableSource, keyColIndex, key);
			SortedTable sortedTable;
#if THREAD_SAFE
			theLock.EnterWriteLock(); try {
#endif
			if (!sortedTables.TryGetValue(tableSource.Table, out sortedTable))
				sortedTables[tableSource.Table] = sortedTable = new SortedTable(tableSource, keyColIndex);
#if THREAD_SAFE
			} finally { theLock.ExitWriteLock(); }
#endif
			return sortedTable.FindAllRows(key);
		}