示例#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;
                }
            }
        }
示例#2
0
        void DoTestIntersect(R r1, R r2, int pos, R r1left, R r1right, R common, R r2left, R r2right)
        {
            S r = R.Intersect(r1, r2);

            Assert.AreEqual(pos, r.RelativePosition);
            AssertEqual(r1left, r.Leftover1Left);
            AssertEqual(r1right, r.Leftover1Right);
            AssertEqual(common, r.Common);
            AssertEqual(r2left, r.Leftover2Left);
            AssertEqual(r2right, r.Leftover2Right);
        }
示例#3
0
 static public void AssertEqual(R exp, R act)
 {
     Assert.AreEqual(exp.IsEmpty, act.IsEmpty);
     if (exp.IsEmpty)
     {
         return;
     }
     Assert.AreEqual(exp.Begin, act.Begin);
     Assert.AreEqual(exp.End, act.End);
     Assert.AreEqual(exp.Priority, act.Priority);
 }
示例#4
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;
            }
        }
        public bool SetActiveRange(long p1, long p2)
        {
            if (openRange != null)
            {
                throw new InvalidOperationException("Cannot move the active range when there is a subrange being filled");
            }

            CheckIntegrity();

            bool ret = false;

            if (p2 < p1)
            {
                p2 = p1;
            }

            FRange fileRange = new FRange(p1, p2, 1);

            for (LinkedListNode <MessagesRange> r = ranges.First; r != null;)
            {
                LinkedListNode <MessagesRange> next = r.Next;

                FIntersectStruct s = FRange.Intersect(r.Value.DesirableRange, fileRange);
                if (s.RelativePosition < 0)
                {
                    ranges.Remove(r);
                    ret = true;
                }
                else if (s.RelativePosition == 0)
                {
                    r.Value.SetPriority(fileRange.Priority);

                    if (!s.Leftover1Left.IsEmpty)
                    {
                        r.Value.TrimLeft(fileRange.Begin);
                        ret = true;
                    }

                    if (!s.Leftover1Right.IsEmpty)
                    {
                        r.Value.TrimRight(fileRange.End);
                        ret = true;
                    }

                    if (!s.Leftover2Left.IsEmpty)
                    {
                        ranges.AddBefore(r, new MessagesRange(s.Leftover2Left));
                    }

                    fileRange = s.Leftover2Right;
                }
                else if (s.RelativePosition > 0)
                {
                    while (r != null)
                    {
                        next = r.Next;
                        ranges.Remove(r);
                        r = next;
                    }
                    ret = true;
                }

                r = next;
            }

            if (!fileRange.IsEmpty)
            {
                ranges.AddLast(new MessagesRange(fileRange));
                ret = true;
            }

            Merge();

            CheckIntegrity();

            return(ret);
        }
 public void SetActiveRange(FRange range)
 {
     SetActiveRange(range.Begin, range.End);
 }
示例#7
0
 public long PositionRangeToBytes(LogJoint.FileRange.Range range)
 {
     throw new NotImplementedException();
 }
示例#8
0
 public long PositionRangeToBytes(LogJoint.FileRange.Range range)
 {
     CheckDisposed();
     return(range.Length);
 }
 public long PositionRangeToBytes(LogJoint.FileRange.Range range)
 {
     return(underliyingReader.PositionRangeToBytes(range));
 }
示例#10
0
 public void AssertEqual(Range exp, Range act)
 {
     FileRangeQueueTest.AssertEqual(exp, act);
 }
示例#11
0
 public void SetPriority(int priority)
 {
     CheckNotOpen();
     desirableRange = new FRange(desirableRange.Begin, desirableRange.End, priority);
 }
示例#12
0
 public MessagesRange(FRange desirableRange)
 {
     this.desirableRange = desirableRange;
 }