Exemple #1
0
        public void TrimToCount(int capacity, int extraElements, int newCount, int[] expected)
        {
            // Arrange
            var collection = new PushOutCollection <int>(capacity);

            PopulateCollection(collection, capacity + extraElements);

            // Act
            collection.TrimTo(newCount);

            // Assert
            Assert.Equal(expected, collection);
        }
Exemple #2
0
        private bool TryAddSnapshotInternal(ref LineViewSnapshot snapshot)
        {
            if (EqualsToCurrentSnapshot(ref snapshot))
            {
                return(false);
            }

            if (_iterator.HasNext())
            {
                _snapshots.TrimTo(_iterator.Index + 1);
            }

            _snapshots.Add(snapshot);
            _iterator.MoveToLast();

            return(true);
        }