Beispiel #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 <SizedElem <T>, uint>, FTreeM <SizedElem <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));
        }
Beispiel #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);
        }
Beispiel #3
0
 public FNSeq <T> Merge(FNSeq <T> seq2)
 {
     return(new FNSeq <T>(new Seq <T>(theSeq.Merge(seq2.theSeq.treeRep))));
 }