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)); }
/// <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); }
private int Add(string NameC, int Code) { int i = MainTable.Count; MainTable.Add(new SymbolTableItem(NameC, Code)); SortedTable.Add(NameC, i); return(i); }
} // 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
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
/// <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); }
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); }
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); }
} // 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
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; }
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); }
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); } }
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); }
public void Enumerator_Empty_YieldsNothing() { SortedTable <int> table = new SortedTable <int>(); int count = 0; foreach (int item in table) { ++count; } Assert.Equal(0, count); }
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
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); }
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); }
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; } }
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); }
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()); }
/// <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)); } }
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); }
} // 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
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); }
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); }
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); }
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); }
} // 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
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)); }
/// <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); }