Пример #1
0
        private PageAndSubIndex EnsureCurrentPage(int index)
        {
            var pageAndSubIndex = new PageAndSubIndex(index / _pageSize, index % _pageSize);

            if (_currentPage == null || _currentPage.PageIndex != pageAndSubIndex.PageIndex)
            {
                _currentPage = _allocatedPages.GetOrCreatePage(pageAndSubIndex.PageIndex);
            }

            return(pageAndSubIndex);
        }
Пример #2
0
        public void RemoveRange(int firstIndex, int count)
        {
            var firstItem = new PageAndSubIndex(firstIndex / _pageSize, firstIndex % _pageSize);

            if (firstItem.SubIndex + count > _pageSize)
            {
                throw new NotImplementedException("RemoveRange is only implemented to work within page boundaries");
            }

            if (_allocatedPages.Contains(firstItem.PageIndex))
            {
                if (_allocatedPages[firstItem.PageIndex].Trim(firstItem.SubIndex, count))
                {
                    _allocatedPages.Remove(firstItem.PageIndex);
                }
            }
        }