public BallOnTable(IDictionary <int, byte> indexedData, PointF location, TableSize tableSize) { this._data = new ReadOnlyDictionary <int, byte>(indexedData); this._foundAtLocation = location; this._tableSize = tableSize; this._calculatedLocation = BallOnTable.CalculateActualLocation(indexedData, tableSize); }
static int _SubTableCountFromTableSize(TableSize size) { // size is Small, Medium, or Large. NOT Default. Debug.Assert(TableSize.Small <= size && size <= TableSize.Large); int nCPUs = GetProcessorCount(); int subTableCount; switch (size) { case TableSize.Small: subTableCount = nCPUs; break; case TableSize.Medium: subTableCount = 2 * nCPUs; break; case TableSize.Large: subTableCount = 4 * nCPUs; break; default: throw new InvalidOperationException(); } ; subTableCount = Math.Min(subTableCount, MAX_SUBTABLES); return(subTableCount); }
public LkrHashtable( string name, TableSize size, double maxLoad, int subTableCount) : this(name, size, maxLoad, subTableCount, null, null) { }
private void InsertTopCells() { int startSection = 0, startRow = 0; int endSection = visibleCells.First.Value.Section, endRow = visibleCells.First.Value.Row; if (!tableSize.RowAt(TopOffset, ref startSection, ref startRow)) { startSection = 0; startRow = -1; } if (TableSize.IndexCompare(startSection, startRow, endSection, endRow) < 0) { ////Debug.LogFormat("Insert top ({0}, {1}) -> ({2}, {3})", startSection, startRow, endSection, endRow); tableSize.Prev(ref endSection, ref endRow, startSection, startRow); GenerateCells(endSection, endRow, startSection, startRow, true); } }
private void InserBottomCells() { int startSection = visibleCells.Last.Value.Section, startRow = visibleCells.Last.Value.Row; int endSection = 0, endRow = 0; if (!tableSize.RowAt(BottomOffset, ref endSection, ref endRow)) { endSection = tableSize.SectionCount - 1; endRow = tableSize.LastSection.RowCount - 1; } if (TableSize.IndexCompare(startSection, startRow, endSection, endRow) < 0) { ////Debug.LogFormat("Insert bottom ({0}, {1}) -> ({2}, {3})", startSection, startRow, endSection, endRow); tableSize.Next(ref startSection, ref startRow, endSection, endRow); GenerateCells(startSection, startRow, endSection, endRow); } }
private void RemoveBottomInvisible() { if (visibleCells.Count == 0) { return; } int section = 0, row = 0; if (tableSize.RowAt(BottomOffset, ref section, ref row)) { while (visibleCells.Count > 0 && TableSize.IndexCompare(section, row, visibleCells.Last.Value.Section, visibleCells.Last.Value.Row) < 0) { //Debug.LogFormat("Remove invisible cell ({0}, {1})", visibleCells.Last.Value.Section, visibleCells.Last.Value.Row); Cache(visibleCells.Last.Value); visibleCells.RemoveLast(); } } }
public LkrHashtable( string name, TableSize size, double maxLoad, int subTableCount, IHashCodeProvider hcp, IComparer comparer) { _hcp = hcp; if (size == TableSize.Default) { size = DEFAULT_META_TABLE_SIZE; } _CtorCheckParameters(maxLoad, subTableCount); if (subTableCount == 0) { subTableCount = _SubTableCountFromTableSize(size); } Debug.Trace("LkrHashtable", "LkrHashtable.ctor name=" + name + " size=" + size + " subtables=" + subTableCount); _CtorMakeSubTables(subTableCount, out _subTables, out _subTableMask); for (int i = 0; i < subTableCount; ++i) { string subTableName = name + " sub " + i.ToString(); _subTables[i] = new LinearHashtable( subTableName, size, maxLoad, hcp, comparer); } }
private void CreateTable(TableSize tableSize) { canvas.Children.Clear(); int lineSize = (int)tableSize; for (int i = 0; i < lineSize; i++) { for (int j = 0; j < lineSize; j++) { const int squareSize = 50; const int padding = 1; //Rectangle rect = new Rectangle { Width = squareSize, Height = squareSize, Stroke = Brushes.Black, Fill = Brushes.Brown }; Image img = new Image { Width = squareSize, Height = squareSize }; img.Source = new DrawingImage(drawingGroup); Canvas.SetLeft(img, i * (img.Width + padding)); Canvas.SetTop(img, j * (img.Height + padding)); canvas.Children.Add(img); } } }
private string Encrypt(string clearedInput, TableSize tableSize) { var encryptedResult = new StringBuilder(); for (int j = 0; j < tableSize.Columns; j++) { if (j != 0) { encryptedResult.Append(" "); } for (int i = 0; i < tableSize.Rows; i++) { var index = CalculateOrderNum(i, j, tableSize); if (index >= clearedInput.Length) { break; } encryptedResult.Append(clearedInput[index]); } } return(encryptedResult.ToString()); }
public int CompareTo(object obj) { var objTable = (VpaTableViewModel)obj; switch (SortColumn) { case "ColumnCardinality": return(RowsCount.CompareTo(objTable.RowsCount) * SortDirection); case "TotalSize": return(TotalSize.CompareTo(objTable.TotalSize) * SortDirection); case "DictionarySize": return(DictionarySize.CompareTo(objTable.DictionarySize) * SortDirection); case "DataSize": return(DataSize.CompareTo(objTable.DataSize) * SortDirection); case "HierarchiesSize": return(HierarchiesSize.CompareTo(objTable.HierarchiesSize) * SortDirection); case "TableSize": return(TableSize.CompareTo(objTable.TableSize) * SortDirection); case "PercentageDatabase": return(PercentageDatabase.CompareTo(objTable.PercentageDatabase) * SortDirection); case "SegmentsNumber": return(SegmentsNumber.CompareTo(objTable.SegmentsNumber) * SortDirection); case "PartitionsNumber": return(PartitionsNumber.CompareTo(objTable.PartitionsNumber) * SortDirection); case "ColumnsNumber": return(ColumnsNumber.CompareTo(objTable.ColumnsNumber) * SortDirection); case "ReferentialIntegrityViolationCount": return(ReferentialIntegrityViolationCount.CompareTo(objTable.ReferentialIntegrityViolationCount) * SortDirection); case "UserHierarchiesSize": return(UserHierarchiesSize.CompareTo(objTable.UserHierarchiesSize) * SortDirection); case "RelationshipSize": return(RelationshipSize.CompareTo(objTable.RelationshipSize) * SortDirection); case "RowsCount": return(RowsCount.CompareTo(objTable.RowsCount) * SortDirection); case "MissingKeys": return(RelationshipFromMissingKeys.CompareTo(objTable.RelationshipFromMissingKeys) * SortDirection); case "FromColumnCardinality": return(RelationshipMaxFromCardinality.CompareTo(objTable.RelationshipMaxFromCardinality) * SortDirection); case "ToColumnCardinality": return(RelationshipMaxToCardinality.CompareTo(objTable.RelationshipMaxToCardinality) * SortDirection); case "InvalidRows": return(RelationshipInvalidRows.CompareTo(objTable.RelationshipInvalidRows) * SortDirection); case "UsedSize": return(RelationshipSize.CompareTo(objTable.RelationshipSize) * SortDirection); default: return(TableName.CompareTo(objTable.TableName) * SortDirection); } }
private static RectangleF CalculateActualLocation(IDictionary <int, byte> data, TableSize tableSize) { return(new RectangleF()); }
public LkrHashtable(string name, TableSize size, IHashCodeProvider hcp, IComparer comparer) : this(name, size, 0, 0, hcp, comparer) { }
public LkrHashtable(string name, TableSize size) : this(name, size, 0, 0, null, null) { }
public byte[] Serialize() { byte[] serialized = TableSize.ToBytes().Append(KeySize.ToBytes(), ValueSize.ToBytes()); return(serialized); }
public void ReloadData(bool purgeCache = false) { if (datasource == null) { //Debug.LogError("No data source"); return; } if (purgeCache) { foreach (var i in reusableCells) { while (i.Value.Count > 0) { Destroy(i.Value.First.Value.gameObject); i.Value.RemoveFirst(); } } reusableCells.Clear(); while (visibleCells.Count > 0) { Destroy(visibleCells.First.Value.gameObject); visibleCells.RemoveFirst(); } } else { // Try to cache visible cells while (visibleCells.Count > 0) { var cell = visibleCells.First.Value; if (!string.IsNullOrEmpty(cell.reuseIdentifier)) { Cache(cell); } else { Destroy(cell.gameObject); } visibleCells.RemoveFirst(); } } visibleCells.Clear(); tableSize = new TableSize(this, datasource); var contentSize = scrollRect.content.sizeDelta; if (direction == Direction.Verical) { contentSize.y = tableSize.TotalHeight; } else { contentSize.x = tableSize.TotalHeight; } scrollRect.content.sizeDelta = contentSize; GenerateCells(); }
private int CalculateOrderNum(int rowNum, int columnNum, TableSize tableSize) { return(rowNum * tableSize.Columns + columnNum); }