public void Clear_OK() { var sa = new SparseArray <decimal>(2, new Dictionary <int, decimal>() { { 0, 1M }, { 1, 2M } }); Assert.AreEqual(2, sa.Capacity, "Incorrect capacity."); Assert.AreEqual(2, sa.Count, "Incorrect count."); Assert.AreEqual(2, sa.Sparsity, "Incorrect sparsity."); Assert.AreEqual(1.0M, sa.SparsityPercent, "Incorrect sparsity percent."); Assert.IsTrue(sa.Keys.SequenceEqual(new List <int> { 0, 1 }), "Incorrect keys."); Assert.IsTrue(sa.ToArray().SequenceEqual(new[] { 1M, 2M }), "Unequal elements in sparse array"); sa.Clear(); Assert.AreEqual(2, sa.Capacity, "Incorrect capacity after Clear()."); Assert.AreEqual(2, sa.Count, "Incorrect count after Clear()."); Assert.AreEqual(0, sa.Sparsity, "Incorrect sparsity after Clear()."); Assert.AreEqual(0.0M, sa.SparsityPercent, "Incorrect sparsity percent after Clear()."); Assert.AreEqual(0, sa.Keys.Count(), "Incorrect keys after Clear()."); Assert.IsTrue(sa.ToArray().SequenceEqual(new[] { 0M, 0M }), "Unequal elements in sparse array after Clear()"); }
public void ClearTest() { var a = new SparseArray <bool> { [5] = true, [90] = false }; Assert.That(a.Count, Is.EqualTo(2)); a.Clear(); Assert.That(a.Count, Is.EqualTo(0)); }
/** * Call this method to reset animation status on all views. */ public void reset() { for (int i = 0; i < mAnimators.Size(); i++) { mAnimators.Get(mAnimators.KeyAt(i)).Cancel(); } mAnimators.Clear(); mFirstAnimatedPosition = -1; mLastAnimatedPosition = -1; mAnimationStartMillis = -1; mShouldAnimate = true; }
public void PreDepacketize() { // Release all current objects. We need to do this before the rest of // the depacketization process because the auto-packetizer will read // the entity and component ids. foreach (var entity in _entityIds) { ReleaseEntity(_entities[entity]); } _entities.Clear(); foreach (var component in _componentIds.Select(id => _components[id])) { ReleaseComponent(component); } _components.Clear(); }
public void SparseArrayClearTest() { // empty array SparseArray <Int32> array = new SparseArray <Int32>(0); array.Clear(); array.ActualCount.ShouldBe(0); array.Count.ShouldBe(0); array.Length.ShouldBe(0); // filled array array = new SparseArray <Int32>(this.values); array.Clear(); array.ActualCount.ShouldBe(0); array.Count.ShouldBe(this.values.Length); array.Length.ShouldBe(this.values.Length); }
public void SparseArrayClearTest() { // empty array SparseArray <Int32> array = new SparseArray <Int32>(0); array.Clear(); Assert.AreEqual(0, array.Length); // filled array array = new SparseArray <Int32>(_values); array.Clear(); Assert.AreEqual(0, array.Count); Assert.AreEqual(_values.Length, array.Length); }
private bool Layout(ControlListBase parent, LayoutEventArgs layoutEventArgs, Size proposedSize) { if (parent == null) { throw new InvalidCastException(nameof(ColumnLayoutEngine) + " can only be used to layout controls derived from " + nameof(ControlListBase)); } if (proposedSize == Size.Empty) { proposedSize = parent.ClientSize; } if (parent.BaseItems != null && parent.BaseItems.Count > 0) { System.Diagnostics.Debug.WriteLine(parent.Name + ": Layout:"); System.Diagnostics.Debug.WriteLine($" ClientSize:{proposedSize}, Margin:{parent.Margin}, Padding:{parent.Padding}, Cols:{parent.RepeatColumns}, Spacing:{parent.ItemSpacing}, Items:{parent.BaseItems.Count}, Dir:{parent.RepeatDirection}, Even:{parent.SpaceEvenly}"); itemBounds.Clear(); using (Graphics g = parent.CreateGraphics()) { // Determine the start coordinate of each column int colWidth = (parent.ClientSize.Width - parent.Padding.Horizontal - ((parent.RepeatColumns - 1) * parent.ItemSpacing.Width)) / parent.RepeatColumns; Point[] colPos = new Point[parent.RepeatColumns]; for (int x = 0; x < parent.RepeatColumns; x++) { colPos[x] = new Point(parent.Padding.Left + (x * (colWidth + parent.ItemSpacing.Width)), parent.Padding.Top); } // Get the base height of all items and the max height int maxItemHeight = 0; idealSize.Height = 0; Size maxSize = new Size(colWidth, 0); for (int i = 0; i < parent.BaseItems.Count; i++) { Size sz = parent.MeasureItem(g, i, maxSize); itemBounds[i] = new Rectangle(Point.Empty, sz); // Calculate maximum item height maxItemHeight = Math.Max(maxItemHeight, sz.Height); } // Calculate the positions of each item int curCol = 0; for (int i = 0; i < parent.BaseItems.Count; i++) { // Set bounds of the item itemBounds[i] = new Rectangle(colPos[curCol], itemBounds[i].Size); // Set top position of next item colPos[curCol].Y += (parent.SpaceEvenly ? maxItemHeight : itemBounds[i].Height) + parent.ItemSpacing.Height; if (parent.RepeatDirection == GroupControls.RepeatDirection.Horizontal) { if (++curCol == parent.RepeatColumns) { curCol = 0; } } // If parent.ItemSpacing evenly we can determine all locations now by changing column count at pure divisions /*if (parent.SpaceEvenly && parent.RepeatDirection == GroupControls.RepeatDirection.Vertical && i > 0) * { * if (i % (parent.BaseItems.Count / parent.RepeatColumns) == 0 && curCol <= (parent.BaseItems.Count % parent.RepeatColumns)) * curCol++; * }*/ } // Split vertical parent.RepeatColumns and reset positions of items if (parent.RepeatDirection == GroupControls.RepeatDirection.Vertical && parent.RepeatColumns > 1) { int idealColHeight = colPos[0].Y / parent.RepeatColumns; int thisColBottom = idealColHeight; int y = parent.Padding.Top + parent.Margin.Top; for (int i = 0; i < parent.BaseItems.Count; i++) { Rectangle iBounds = itemBounds[i]; Rectangle nBounds = Rectangle.Empty; if ((i + 1) < parent.BaseItems.Count) { nBounds = itemBounds[i + 1]; } if (curCol > 0) { itemBounds[i] = new Rectangle(new Point(colPos[curCol].X, y), itemBounds[i].Size); } colPos[curCol].Y = itemBounds[i].Bottom + parent.ItemSpacing.Height; if ((iBounds.Bottom > thisColBottom || nBounds.Bottom > thisColBottom) && (curCol + 1 < parent.RepeatColumns)) { if (Math.Abs(iBounds.Bottom - idealColHeight) < Math.Abs(nBounds.Bottom - idealColHeight)) { y = parent.Padding.Top; curCol++; thisColBottom = iBounds.Bottom + parent.ItemSpacing.Height + idealColHeight; } } else { y += (parent.SpaceEvenly ? maxItemHeight : itemBounds[i].Height) + parent.ItemSpacing.Height; } } } // Set ideal height idealSize.Height = 0; for (int c = 0; c < parent.RepeatColumns; c++) { if (idealSize.Height < colPos[c].Y) { idealSize.Height = colPos[c].Y; } } idealSize.Height = idealSize.Height - parent.ItemSpacing.Height + parent.Padding.Bottom; } // Set scroll height and autosize to ideal height parent.AutoScrollMinSize = new Size(parent.ClientRectangle.Width, idealSize.Height); if (parent.AutoSize) { parent.Height = idealSize.Height; } System.Diagnostics.Debug.WriteLine(" " + string.Join(" ", Array.ConvertAll(itemBounds.ToArray(), r => $"({r})"))); } return(parent.AutoSize); }
public void ClearTest() { _array.Clear(); Assert.Empty(_array); }
public virtual void ClearHideRowList() { mHideRowList.Clear(); }
public virtual void ClearHideColumnList() { mHideColumnList.Clear(); }