Exemplo n.º 1
0
        public void TrimRight(long newEnd)
        {
            CheckNotOpen();
            if (!desirableRange.IsInRange(newEnd))
            {
                throw new ArgumentException("Position specified is out of this range", "position");
            }

            desirableRange = new FRange(desirableRange.Begin, newEnd, desirableRange.Priority);

            if (newEnd <= LastReadPosition.GetValueOrDefault(long.MinValue))
            {
                PositionedLine pos = new PositionedLine();
                foreach (PositionedLine p in ReverseIterator(newEnd))
                {
                    pos = p;
                    break;
                }
                if (pos.Chunk != null)
                {
                    pos.Chunk.TrimRight(pos.Position);
                    last      = pos.Chunk;
                    last.next = null;
                }
                else
                {
                    first = null;
                    last  = null;
                }
            }
        }
Exemplo n.º 2
0
        public void TrimLeft(long newBegin)
        {
            CheckNotOpen();
            if (!desirableRange.IsInRange(newBegin))
            {
                throw new ArgumentException("Position specified is out of this range", "position");
            }

            desirableRange = new FRange(newBegin, desirableRange.End, desirableRange.Priority);

            bool clearThisRange = false;

            if (newBegin > LastReadPosition.GetValueOrDefault(long.MinValue))
            {
                clearThisRange = true;
            }
            else
            {
                PositionedLine pos = new PositionedLine();
                foreach (PositionedLine p in ForwardIterator(newBegin))
                {
                    pos = p;
                    break;
                }
                if (pos.Chunk != null)
                {
                    pos.Chunk.TrimLeft(pos.Position);
                    first      = pos.Chunk;
                    first.prev = null;
                }
                else
                {
                    clearThisRange = true;
                }
            }

            if (clearThisRange)
            {
                first = null;
                last  = null;
            }
        }