Exemple #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))));
 }
Exemple #2
0
        public override FingerTree <T, M> AddRight(T a)
        {
            Measured <T, M> m = Measured;
            M measure         = m.Append(m.Measure(a), Size);

            return(_suffix.Match(x1 => new Deep <T, M>(m, measure, _prefix, _middle, _mk.Two(x1.V, a)),
                                 x2 => new Deep <T, M>(m, measure, _prefix, _middle, _mk.Three(x2.V1, x2.V2, a)),
                                 x3 => new Deep <T, M>(m, measure, _prefix, _middle, _mk.Four(x3.V1, x3.V2, x3.V3, a)),
                                 x4 => new Deep <T, M>(m, measure, _prefix, _middle.AddRight(_mk.Node3(x4.V1, x4.V2, x4.V3)),
                                                       _mk.Two(x4.V4, a))));
        }
Exemple #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))));
 }