示例#1
0
文件: SparseList.cs 项目: HeToC/HDK
        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
文件: SparseList.cs 项目: HeToC/HDK
        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);
                }
            }
        }