Exemplo n.º 1
0
 static FingerTree <Node <T, M>, M> Append1 <T, M>(Measured <T, M> m, FingerTree <Node <T, M>, M> t1, Node <T, M> n1,
                                                   FingerTree <Node <T, M>, M> t2)
 {
     return(t1.Match(e => t2.AddLeft(n1),
                     s => t2.AddLeft(n1).AddLeft(s.Item),
                     d => t2.Match(e2 => t1.AddRight(n1),
                                   s2 => t1.AddRight(n1).AddRight(s2.Item),
                                   d2 =>
                                   new Deep <Node <T, M>, M>(m.Node, m.Append(m.Append(d.Size, m.Node.Measure(n1)), d2.Size),
                                                             d._prefix,
                                                             AddDigits1(m.Node, d._middle, d._suffix, n1, d2._prefix,
                                                                        d2._middle),
                                                             d2._suffix))));
 }
Exemplo n.º 2
0
        public override FingerTree <T, M> AddLeft(T a)
        {
            Measured <T, M> m = Measured;
            M size            = m.Append(m.Measure(a), Size);

            return(_prefix.Match(x1 => new Deep <T, M>(m, size, _mk.Two(a, x1.V), _middle, _suffix),
                                 x2 => new Deep <T, M>(m, size, _mk.Three(a, x2.V1, x2.V2), _middle, _suffix),
                                 x3 => new Deep <T, M>(m, size, _mk.Four(a, x3.V1, x3.V2, x3.V3), _middle, _suffix),
                                 x4 => new Deep <T, M>(m, size, _mk.Two(a, x4.V1),
                                                       _middle.AddLeft(_mk.Node3(x4.V2, x4.V3, x4.V4)), _suffix)));
        }
Exemplo n.º 3
0
 static FingerTree <Node <T, M>, M> Append4 <T, M>(Measured <T, M> m, FingerTree <Node <T, M>, M> t1, Node <T, M> n1,
                                                   Node <T, M> n2,
                                                   Node <T, M> n3, Node <T, M> n4, FingerTree <Node <T, M>, M> t2)
 {
     return(t1.Match(e => t2.AddLeft(n4).AddLeft(n3).AddLeft(n2).AddLeft(n1),
                     s => t2.AddLeft(n4).AddLeft(n3).AddLeft(n2).AddLeft(n1).AddLeft(s.Item),
                     d => t2.Match(e2 => t2.AddRight(n1).AddRight(n2).AddRight(n3).AddRight(n4),
                                   s2 => t2.AddRight(n1).AddRight(n2).AddRight(n3).AddRight(n4).AddRight(s2.Item),
                                   d2 =>
                                   new Deep <Node <T, M>, M>(m.Node,
                                                             m.Append(
                                                                 m.Append(
                                                                     m.Append(
                                                                         m.Append(
                                                                             m.Append(d.Size, n1.Measure),
                                                                             n2.Measure), n3.Measure),
                                                                     n4.Measure),
                                                                 d2.Size), d._prefix,
                                                             AddDigits4(m.Node, d._middle, d._suffix, n1, n2, n3, n4,
                                                                        d2._prefix,
                                                                        d2._middle),
                                                             d2._suffix))));
 }
Exemplo n.º 4
0
 public override FingerTree <T, M> Concat(FingerTree <T, M> t)
 {
     return(t.AddLeft(_item));
 }