Esempio n. 1
0
        // this inserts a whole sequence, so we cannot just use Seq.snsertAt()
        public FNSeq <T> insert_before(int ind, FNSeq <T> fSeq2)
        {
            if (ind < 0 || ind >= this.Length())
            {
                throw new ArgumentOutOfRangeException();
            }
            //else
            Pair <FTreeM <SizedElement <T>, uint>, FTreeM <SizedElement <T>, uint> > theSplit =
                theSeq.SeqSplit
                    (new MPredicate <uint>
                    (
                        FP.Curry <uint, uint, bool>(theLTMethod, (uint)ind - 1)
                    )
                    );

            FNSeq <T> fs1 = new FNSeq <T>((Seq <T>)(theSplit.First));
            FNSeq <T> fs3 = new FNSeq <T>((Seq <T>)(theSplit.Second));

            return(fs1.Merge(fSeq2).Merge(fs3));
        }
Esempio n. 2
0
        public FNSeq <T> subsequence(int startInd, int subLength)
        {
            uint theLength = theSeq.length;

            if (theLength == 0 || subLength <= 0)
            {
                return(this);
            }
            //else
            if (startInd < 0)
            {
                startInd = 0;
            }

            if (startInd + subLength > theLength)
            {
                subLength = (int)(theLength - startInd);
            }

            // Now ready to do the real work
            FNSeq <T> fsResult =
                new FNSeq <T>(
                    (Seq <T>)
                    (
                        ((Seq <T>)
                             (theSeq.SeqSplit
                             (
                                 new MPredicate <uint>
                                     (FP.Curry <uint, uint, bool>(theLTMethod, (uint)startInd))
                             ).Second
                             )
                        ).SeqSplit
                            (new MPredicate <uint>
                                (FP.Curry <uint, uint, bool>(theLTMethod, (uint)subLength))
                            ).First
                    )
                    );

            return(fsResult);
        }
Esempio n. 3
0
 public FNSeq <T> Merge(FNSeq <T> seq2)
 {
     return(new FNSeq <T>(new Seq <T>(theSeq.Merge(seq2.theSeq.treeRep))));
 }