当前位置: 首页>>代码示例>>C#>>正文


C# LinkedList.Clear方法代码示例

本文整理汇总了C#中LinkedList.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# LinkedList.Clear方法的具体用法?C# LinkedList.Clear怎么用?C# LinkedList.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LinkedList的用法示例。


在下文中一共展示了LinkedList.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    // Implement the data structure linked list. 
    public static void Main()
    {
        var linkedList = new LinkedList<string>();

        linkedList.AddFirst("first");
        linkedList.AddLast("second");
        Console.WriteLine(string.Join(", ", linkedList));

        linkedList.Clear();
        linkedList.AddLast("second");
        linkedList.AddFirst("first");
        Console.WriteLine(string.Join(", ", linkedList));

        string value = "first";
        Console.WriteLine("List contains \"{0}\": {1}", value, linkedList.Contains(value));

        Console.WriteLine("List contains {0} item(s)", linkedList.Count);

        var item = linkedList.Find("second");
        Console.WriteLine(item);

        linkedList.Remove("first");
        Console.WriteLine(string.Join(", ", linkedList));

        linkedList.Remove("second");
        Console.WriteLine("List contains {0} item(s): {1}", linkedList.Count, string.Join(", ", linkedList));

        linkedList.AddFirst("second");
        linkedList.AddFirst("first");
        linkedList.AddLast("third");
        Console.WriteLine(string.Join(", ", linkedList));

        linkedList.Remove("second");
        Console.WriteLine(string.Join(", ", linkedList));
    }
开发者ID:MarKamenov,项目名称:TelerikAcademy,代码行数:36,代码来源:LinkedListTest.cs

示例2: GetTests

        private void GetTests()
        {
            methods = methods ?? new LinkedList<MethodInfo>();
            methods.Clear();
            status = status ?? new Dictionary<MethodInfo, Status>();
            status.Clear();
            toggleGroup = toggleGroup ?? new Dictionary<string, bool>();

            var bindingFlags = BindingFlags.Public;
            bindingFlags |= BindingFlags.Static;
            bindingFlags |= BindingFlags.DeclaredOnly;

            Type[] typelist = GetTypesInNamespace("Exodrifter.ExpressionParser.Test");
            for (int i = 0; i < typelist.Length; i++) {
                foreach (var method in typelist[i].GetMethods(bindingFlags)) {
                    if (0 == method.GetParameters().Length) {
                        methods.AddLast(method);
                        status.Add(method, Status.UNKNOWN);

                        if (!toggleGroup.ContainsKey(method.DeclaringType.Name)) {
                            toggleGroup[method.DeclaringType.Name] = false;
                        }
                    }
                }
            }
        }
开发者ID:exodrifter,项目名称:unity-expression-parser,代码行数:26,代码来源:ExpressionParserTests.cs

示例3: FieldPhraseList

        /// <summary>
        /// a constructor. 
        /// </summary>
        /// <param name="fieldTermStack">FieldTermStack object</param>
        /// <param name="fieldQuery">FieldQuery object</param>
        /// <param name="phraseLimit">maximum size of phraseList</param>
        public FieldPhraseList(FieldTermStack fieldTermStack, FieldQuery fieldQuery, int phraseLimit)
        {
            String field = fieldTermStack.FieldName;

            LinkedList<TermInfo> phraseCandidate = new LinkedList<TermInfo>();
            QueryPhraseMap currMap = null;
            QueryPhraseMap nextMap = null;
            while (!fieldTermStack.IsEmpty() && (phraseList.Count < phraseLimit) )
            {

                phraseCandidate.Clear();

                TermInfo ti = fieldTermStack.Pop();
                currMap = fieldQuery.GetFieldTermMap(field, ti.Text);

                // if not found, discard top TermInfo from stack, then try next element
                if (currMap == null) continue;

                // if found, search the longest phrase
                phraseCandidate.AddLast(ti);
                while (true)
                {
                    ti = fieldTermStack.Pop();
                    nextMap = null;
                    if (ti != null)
                        nextMap = currMap.GetTermMap(ti.Text);
                    if (ti == null || nextMap == null)
                    {
                        if (ti != null)
                            fieldTermStack.Push(ti);
                        if (currMap.IsValidTermOrPhrase(new List<TermInfo>(phraseCandidate)))
                        {
                            AddIfNoOverlap(new WeightedPhraseInfo(phraseCandidate, currMap.Boost, currMap.TermOrPhraseNumber));
                        }
                        else
                        {
                            while (phraseCandidate.Count > 1)
                            {
                                TermInfo last = phraseCandidate.Last.Value;
                                phraseCandidate.RemoveLast();
                                fieldTermStack.Push(last);
                                currMap = fieldQuery.SearchPhrase(field, new List<TermInfo>(phraseCandidate));
                                if (currMap != null)
                                {
                                    AddIfNoOverlap(new WeightedPhraseInfo(phraseCandidate, currMap.Boost, currMap.TermOrPhraseNumber));
                                    break;
                                }
                            }
                        }
                        break;
                    }
                    else
                    {
                        phraseCandidate.AddLast(ti);
                        currMap = nextMap;
                    }
                }
            }
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:65,代码来源:FieldPhraseList.cs

示例4: addMaterijal

        public RezultatKomanda addMaterijal(string Naslov, string Opis, string DodadenOd, string Slika, string Pateka,String Type)
        {
            RezultatKomanda rezultat = new RezultatKomanda(false);
            try
            {
                parametriKomanda = new LinkedList<SqlParameter>();

                parametriKomanda.Clear();

                //Parametar za @Naslov  = Naslov
                //Input Parametar
                SqlParam = new SqlParameter("@Naslov", SqlDbType.NVarChar);
                SqlParam.Value = Naslov;
                parametriKomanda.AddLast(SqlParam);

                //Parametar za @Opis = Opis
                //Input Parametar
                SqlParam = new SqlParameter("@Opis", SqlDbType.NVarChar);
                SqlParam.Value = Opis;
                parametriKomanda.AddLast(SqlParam);

                //Parametar za @DodadenOd  = DodadenOd
                //Input Parametar
                SqlParam = new SqlParameter("@DodadenOd", SqlDbType.VarChar);
                SqlParam.Value = DodadenOd;
                parametriKomanda.AddLast(SqlParam);

                //Parametar za @Slika  = Slika
                //Input Parametar
                SqlParam = new SqlParameter("@Slika", SqlDbType.NVarChar);
                SqlParam.Value = Slika ;
                parametriKomanda.AddLast(SqlParam);

                //Parametar za @Pateka  = Pateka
                //Input Parametar
                SqlParam = new SqlParameter("@Pateka", SqlDbType.NVarChar);
                SqlParam.Value = Pateka;
                parametriKomanda.AddLast(SqlParam);

                //Parametar za @Type = Type
                //Input Parametar
                SqlParam = new SqlParameter("@Type", SqlDbType.NVarChar);
                SqlParam.Value = Type;
                parametriKomanda.AddLast(SqlParam);

                BazaDB.ExecuteScalar(parametriKomanda.ToArray(), "sp_ZacuvajMaterijal", sqlCn: null);


                rezultat.Rezultat = RezultatKomandaEnum.Uspeh;

                return rezultat;
            }
            catch (Exception ex)
            {
                rezultat.Rezultat = RezultatKomandaEnum.Neuspeh;
                rezultat.Pricina = ex.Message;
                return rezultat;
            }
        }
开发者ID:markomitr,项目名称:.Net-3-Tier-Architecture-ModelViewPresenter-Solution-StudentFileSharingService,代码行数:59,代码来源:MaterijaliDB.cs

示例5: Solve

    // Looks like I ended up with the typical sliding-window deque solution. Here's an example for k = 3:
    // 1 3 2 8 4 7 2, initialize left looking dominators like {3, 2}. These dominate everything to their
    // left until a bigger dominator. Leftmost dominator goes to max value for subarray.
    // [1 3 2] 8 4 7 2, {3, 2}
    // 1 [3 2 8] 4 7 2, {8}, lost 1 but it wasn't a dominator, gained 8 and it dominates everything, kills 3 and 2.
    // 1 3 [2 8 4] 7 2, {8, 4}, lost 3 but wasn't a dominator, gained 4 which dominates til 8.
    // 1 3 2 [8 4 7] 2, {8, 7}, lost 2 but wasn't a dominator, gained 7 which kills 4 and domaintes til 8.
    // 1 3 2 8 [4 7 2], {7, 2}, lost 8 so pop it off, gained 2 which dominates til 7.
    // I say dominate because if you're an element and there's an element in your sliding window to your right
    // that's greater than you (dominating you), you're never going to be the max for any of your remaining subarrays.
    // That dominating element to your right will always be there until you're kicked out of the window.
    // When a big number slides in it can dominate all of the dominators and be the only one left; the existing
    // dominators would be to its left so they'd never be able to be the max for any remaining subarrays.
    // We have to keep track of the dominators to the right of other, larger dominators because those other dominators
    // are going to slide out before the ones to their right, and we need to know where to pick up from. It should be
    // clear the dominators are always sorted, descending, from left to right. Dominators could be thought of recursively
    // as greatest element in subarray, followed by greatest element in subarray to that element's right, etc. O(n)
    // because we add or remove an array element from the dominators at most one time.
    public static int[] Solve(int[] array, int k)
    {
        if (k == array.Length) return new[] { array.Max() };
        if (k == 1) return array;

        // Initializing the dominators for the first subarray. Gotta have the rightmost, then the next to the left that's
        // larger than (or equal to) it, and so on. Equal to because we need the next one after an equal one is popped off.
        var leftLookingDominators = new LinkedList<int>();
        leftLookingDominators.AddFirst(array[k - 1]);

        for (int i = k - 2; i >= 0; --i)
        {
            if (array[i] >= leftLookingDominators.Last.Value)
            {
                leftLookingDominators.AddLast(array[i]);
            }
        }

        // Each iteration we're looking at the next subarray, slid over from the previous. We lose an element during the
        // slide which might've been the leftmost dominator (the leftmost dominator is the only one that can be lost). We
        // gain an element which might start dominating everything, or just some dominators til hitting some dominator to its
        // left that's greater than it, or just itself. Don't have to worry about dominators ever becoming empty, because
        // base case handled above. Even for k = 2, if there's only 1 dominator going in to the next iteration, it must be
        // the rightmost element of the previous subarray, so it's not going to get popped off the end until the next next iteration.
        int subarrayCount = array.Length - k + 1;
        int[] subarrayMaximums = new int[subarrayCount];
        subarrayMaximums[0] = leftLookingDominators.Last.Value;

        for (int i = 1, j = k; i < subarrayCount; ++i, ++j)
        {
            int lostLeftValue = array[i - 1];
            int gainedRightValue = array[j];

            if (lostLeftValue == leftLookingDominators.Last.Value)
            {
                leftLookingDominators.RemoveLast();
            }

            if (gainedRightValue > leftLookingDominators.Last.Value)
            {
                leftLookingDominators.Clear();
                leftLookingDominators.AddFirst(gainedRightValue);
            }
            else
            {
                while (gainedRightValue > leftLookingDominators.First.Value)
                {
                    leftLookingDominators.RemoveFirst();
                }
                leftLookingDominators.AddFirst(gainedRightValue);
            }

            subarrayMaximums[i] = leftLookingDominators.Last.Value;
        }

        return subarrayMaximums;
    }
开发者ID:davghouse,项目名称:SPOJ,代码行数:75,代码来源:ARRAYSUB.cs

示例6: addUstanova

        public RezultatKomanda addUstanova(string Ime, string Adresa, string WebStrana, int Institucija_ID)
        {
            RezultatKomanda rezultat = new RezultatKomanda(false);
            dsKomanda = null;
            try
            {
                parametriKomanda = new LinkedList<SqlParameter>();

                parametriKomanda.Clear();

                //Parametar za @Ime  = Ime
                //Input Parametar
                SqlParam = new SqlParameter("@Ime", SqlDbType.NVarChar);
                SqlParam.Value = Ime;
                parametriKomanda.AddLast(SqlParam);

                //Parametar za @Adresa = Adresa
                //Input Parametar
                SqlParam = new SqlParameter("@Adresa", SqlDbType.NVarChar);
                SqlParam.Value = Adresa;
                parametriKomanda.AddLast(SqlParam);

                //Parametar za @WebAdresa = WebAdresa
                //Input Parametar
                SqlParam = new SqlParameter("@WebStrana", SqlDbType.NVarChar);
                SqlParam.Value = WebStrana;
                parametriKomanda.AddLast(SqlParam);

                //Parametar za @Institucija_ID  = Institucija_ID
                //Input Parametar
                SqlParam = new SqlParameter("@Institucija_ID", SqlDbType.Int);
                SqlParam.Value = Institucija_ID;
                parametriKomanda.AddLast(SqlParam);

                //Parametar za @Aktiven  = D
                //Input Parametar
                SqlParam = new SqlParameter("@Aktiven", SqlDbType.Char);
                SqlParam.Value = 'D';
                parametriKomanda.AddLast(SqlParam);


                BazaDB.ExecuteScalar(parametriKomanda.ToArray(), "sp_ZacuvajUstanova", sqlCn: null);


                rezultat.Rezultat = RezultatKomandaEnum.Uspeh;

                return rezultat;
            }
            catch (Exception ex)
            {
                rezultat.Rezultat = RezultatKomandaEnum.Neuspeh;
                rezultat.Pricina = ex.Message;
                return rezultat;
            }
        }
开发者ID:markomitr,项目名称:.Net-3-Tier-Architecture-ModelViewPresenter-Solution-StudentFileSharingService,代码行数:55,代码来源:UstanovaDB.cs

示例7: foreach

        public Boolean TryCalculateFanMotif 
            (IGraph oGraph, BackgroundWorker oBackgroundWorker, out ICollection<Motif> oMotifs)
        {
            Debug.Assert(oGraph != null);

            oMotifs = null;

            LinkedList<Motif> oFanMotifs = new LinkedList<Motif>();
            LinkedList<IVertex> oLeaves = new LinkedList<IVertex>();

            IVertexCollection oVertices = oGraph.Vertices;
            Int32 iVertices = oVertices.Count;
            Int32 iCalculationsSoFar = 0;

            foreach (IVertex oVertex in oVertices)
            {
                if ((iCalculationsSoFar % 100 == 0) &&
                    !ReportProgressAndCheckCancellationPending(iCalculationsSoFar, iVertices, oBackgroundWorker)
                    )
                {
                    return (false);
                }

                ICollection<IVertex> oAdjacentVertices = oVertex.AdjacentVertices;

                if (oAdjacentVertices.Count >= 2)
                {
                    foreach (IVertex oAdjacentVertex in oAdjacentVertices)
                    {
                        if (oAdjacentVertex.AdjacentVertices.Count == 1)
                        {
                            oLeaves.AddLast(oAdjacentVertex);
                        }
                    }

                    if (oLeaves.Count >= 2)
                    {
                        oFanMotifs.AddLast(
                            new FanMotif(oVertex, oLeaves.ToArray()));
                    }

                    oLeaves.Clear();
                }

                iCalculationsSoFar++;
            }

            // Set the ArcScale property on each FanMotif object.

            SetFanMotifArcScale(oFanMotifs);

            oMotifs = oFanMotifs;

            return (true);
        }
开发者ID:2014-sed-team3,项目名称:term-project,代码行数:55,代码来源:FanMotifDetector.cs

示例8: SetPolygons

        public override void SetPolygons()
        {
            base.SetPolygons();

            LinkedList<float> tempList = new LinkedList<float>();
            foreach ( Polygon poly in filledPolygons ) {
                for ( int i = 2 ; i < poly.Points.Count ; ++i ) {
                    tempList.AddLast( poly.Points[ 0 ].X );
                    tempList.AddLast( poly.Points[ 0 ].Y );
                    tempList.AddLast( 1 );
                    tempList.AddLast( 1 );
                    tempList.AddLast( poly.Colors[ 0 ].X );
                    tempList.AddLast( poly.Colors[ 0 ].Y );
                    tempList.AddLast( poly.Colors[ 0 ].Z );
                    tempList.AddLast( poly.Colors[ 0 ].W );

                    tempList.AddLast( poly.Points[ i - 1 ].X );
                    tempList.AddLast( poly.Points[ i - 1 ].Y );
                    tempList.AddLast( 1 );
                    tempList.AddLast( 1 );
                    tempList.AddLast( poly.Colors[ i - 1 ].X );
                    tempList.AddLast( poly.Colors[ i - 1 ].Y );
                    tempList.AddLast( poly.Colors[ i - 1 ].Z );
                    tempList.AddLast( poly.Colors[ i - 1 ].W );

                    tempList.AddLast( poly.Points[ i ].X );
                    tempList.AddLast( poly.Points[ i ].Y );
                    tempList.AddLast( 1 );
                    tempList.AddLast( 1 );
                    tempList.AddLast( poly.Colors[ i ].X );
                    tempList.AddLast( poly.Colors[ i ].Y );
                    tempList.AddLast( poly.Colors[ i ].Z );
                    tempList.AddLast( poly.Colors[ i ].W );
                }
            }
            fillArray = tempList.ToArray();
            tempList.Clear();

            foreach ( Polygon poly in outlinePolygons ) {
                for ( int i = 0 ; i < poly.Points.Count ; ++i ) {
                    tempList.AddLast( poly.Points[ i ].X );
                    tempList.AddLast( poly.Points[ i ].Y );
                    tempList.AddLast( 1 );
                    tempList.AddLast( 1 );
                    tempList.AddLast( poly.Colors[ i ].X );
                    tempList.AddLast( poly.Colors[ i ].Y );
                    tempList.AddLast( poly.Colors[ i ].Z );
                    tempList.AddLast( poly.Colors[ i ].W );
                }
            }
            outlineArray = tempList.ToArray();

            GenerateBuffers();
        }
开发者ID:LukaHorvat,项目名称:FireflyGL,代码行数:54,代码来源:ColoredShape.cs

示例9: NetworkToConnections

        public static LinkedList<String> NetworkToConnections(double[,] matrix, bool[] rev, String[] metabolite_names = null, String[] reaction_names = null)
        {
            if (metabolite_names == null)
            {
                metabolite_names = new String[matrix.Length / rev.Length];
                for (int i = 0; i < matrix.Length / rev.Length; ++i)
                    metabolite_names[i] = "M_" + (i + 1);
            }

            if (reaction_names == null)
            {
                reaction_names = new String[rev.Length];
                for (int i = 0; i < rev.Length; ++i)
                    reaction_names[i] = "R_" + (i + 1);
            }

            LinkedList<String> res = new LinkedList<string>();

            res.AddFirst("digraph Network {");
            res.AddLast("\tnodesep=0.7;");
            res.AddLast("\trankdir=LR;");

            int n = rev.Length, m = matrix.Length / n;

            for (int i = 0; i < m; ++i)
                res.AddLast(String.Format("\t{0}[label=\"{1}\"];", i + 1, metabolite_names[i]));

            LinkedList<int> produced = new LinkedList<int>(), consumed = new LinkedList<int>();
            for (int j = 0; j < n; ++j)
            {
                produced.Clear();
                consumed.Clear();

                for (int i = 0; i < m; ++i)
                {
                    if (matrix[i, j] < 0)
                        consumed.AddLast(i);
                    if (matrix[i, j] > 0)
                        produced.AddLast(i);
                }

                foreach (int m1 in produced)
                    foreach (int m2 in consumed)
                        if (rev[j])
                            res.AddLast(String.Format("{0}->{1}[dir=both]", m1 + 1, m2 + 1));
                        else
                            res.AddLast(String.Format("{0}->{1}", m1 + 1, m2 + 1));
            }

            res.AddLast("}");

            return res;
        }
开发者ID:goldsteiny,项目名称:tEFCA_Lattice_Solver,代码行数:53,代码来源:BiologyConverter.cs

示例10: CreateFriendships

        private List<FriendshipLink> CreateFriendships(List<Person> people)
        {
            List<FriendshipLink> friendships = new List<FriendshipLink>();
            Person p1, p2;

            int totalCount  = people.Count;
            int missing;

            LinkedList<DistanceNode> list = new LinkedList<DistanceNode>();

            for (int i = 0; i < totalCount; i++)
            {
                p1 = people[i];
                missing = Mathf.Clamp((int) Utils.GetRandomValue(avgConnections, avgConnections*1.2f, 3), 1, 100) - p1.FriendCount;

                if (missing <= 0)
                    continue;

                list.Clear();

                for (int j = i+1; j < totalCount; j++)
                {
                    p2 = people[j];
                    if (p2.FriendCount < avgConnections * 1.2)
                        list.AddLast(new DistanceNode(p1, p2));
                }

                while (list.Count > 0 && missing > 0)
                {
                    DistanceNode smallest = list.First.Value;

                    //Lerp between probability and 1, depending on how many are left and how many are missing

                    float prob = Mathf.Lerp(probability, 1, missing / list.Count);
                    foreach (DistanceNode node in list)
                    {
                        if (node.dist < smallest.dist)
                            smallest = node;
                    }
                    //TODO Code/use a heap instead

                    if (Random.value < prob)
                    {
                        friendships.Add(CreateFriendship(p1, smallest.p));
                        missing--;
                    }
                    list.Remove(smallest);
                }
            }

            return friendships;
        }
开发者ID:ConjureETS,项目名称:DeathBook,代码行数:52,代码来源:LevelGenerator.cs

示例11: ItShouldBeAbleToClear

 public void ItShouldBeAbleToClear()
 {
     LinkedList<object> list = new LinkedList<object>();
     list.Add('a');
     list.Add('b');
     list.Add('c');
     list.Add('d');
     list.Add('e');
     list.Clear();
     object expected = 0;
     object actual = list.Count;
     Assert.AreEqual(expected, actual);
 }
开发者ID:bogdanuifalean,项目名称:JuniorMind,代码行数:13,代码来源:LinkedListTest.cs

示例12: Clear_Empty

        public void Clear_Empty()
        {
            LinkedList<int> list = new LinkedList<int>();

            Assert.IsNull(list.Head);
            Assert.IsNull(list.Tail);
            Assert.AreEqual(0, list.Count);

            list.Clear();

            Assert.IsNull(list.Head);
            Assert.IsNull(list.Tail);
            Assert.AreEqual(0, list.Count);
        }
开发者ID:SubhasisDutta,项目名称:Subhasis-MyPrograms,代码行数:14,代码来源:Clear.cs

示例13: buttonRemoveSTL_Click

 public void buttonRemoveSTL_Click(object sender, EventArgs e)
 {
     //STL stl = (STL)listSTLObjects.SelectedItem;
     //if (stl == null) return;
     LinkedList<STL> list = new LinkedList<STL>();
     foreach (STL stl in listSTLObjects.SelectedItems)
         list.AddLast(stl);
     foreach (STL stl in list)
     {
         cont.models.Remove(stl);
         listSTLObjects.Items.Remove(stl);
     }
     list.Clear();
     cont.UpdateChanges();
 }
开发者ID:logxen,项目名称:Repetier-Host,代码行数:15,代码来源:STLComposer.cs

示例14: doProcess

        public virtual SetOfSentences doProcess(SetOfSentences sos)
        {
            List< Eojeol [] > eojeolSetArray = sos.getEojeolSetArray();

            LinkedList < Eojeol > eojeolArray = new LinkedList < Eojeol >();

            for (int i = 0; i < eojeolSetArray.Count; i++)
            {
                Eojeol[] eojeolSet = eojeolSetArray[i];

                eojeolArray.Clear();
                for (int j = 0; j < eojeolSet.Length; j++)
                {
                    eojeolArray.AddLast(eojeolSet[j]);
                }

                int unkCount = 0;
                for (int j = 0; j < eojeolArray.Count; j++)
                {
                    Eojeol eojeol = eojeolArray.Get_Renamed(j);
                    System.String[] tags = eojeol.Tags;
                    System.String[] morphemes = eojeol.Morphemes;

                    for (int k = 0; k < tags.Length; k++)
                    {
                        if (tags[k].Equals("unk"))
                        {
                            tags[k] = "nqq";

                            Eojeol newEojeol = new Eojeol(morphemes.Clone() as string[], tags.Clone() as string[]);
                            eojeolArray.AddLast(newEojeol);

                            tags[k] = "ncn";
                            unkCount++;
                        }
                    }
                }

                if (unkCount > 0)
                {
                    eojeolSetArray[i] = eojeolArray.ToArray(eojeolSet);
                }
            }

            return sos;
        }
开发者ID:hyunjong-lee,项目名称:NHanNanum,代码行数:46,代码来源:UnknownProcessor.cs

示例15: Calcular

        private static void Calcular(int[] l, int M, int lim, int i, LinkedList<int> r,
                                     ref int max, LinkedList<int> aux, int auxv, int auxt) {
            if(i < M) {
                if(auxt + l[i] <= lim) {
                    aux.AddLast(i);
                    Calcular(l, M, lim, i + 1, r, ref max, aux, auxv + 1, auxt + l[i]);
                    aux.RemoveLast();

                }
                Calcular(l, M, lim, i + 1, r, ref max, aux, auxv, auxt);
            } else if(auxv > max) {
                max = auxv;
                r.Clear();
                foreach(int n in aux) {
                    r.AddLast(n);
                }
            }
        }
开发者ID:gorkinovich,项目名称:MTP,代码行数:18,代码来源:Ejercicio304.cs


注:本文中的LinkedList.Clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。