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


C# Set.ForEach方法代码示例

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


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

示例1: TestSet

        /// <summary>
        /// Set<T>
        /// A set based on hash-table   (NO DUPLICATES)
        /// Add / Find / Remove work in time O(1) 
        /// Like .NET’s HashSet<T>
        /// </summary>
        private static void TestSet()
        {
            Set<Student> students = new Set<Student>();
            var student1 = new Student("Pesho", 21);
            var student2 = new Student("Pesho", 21);
            var student3 = new Student("Pesho", 22);
            var student4 = new Student("Pesho", 22);
            var student5 = new Student("Pesho", 24);
            students.Add(student1);
            students.Add(student2);
            students.Add(student3);
            students.Add(student4);
            students.Add(student5);

            foreach (var student in students)
            {
                Console.WriteLine(student);
            }

            Console.WriteLine("=====FindAll(x => x.Age < 23)=====");
            var someStudents = students.FindAll(x => x.Age < 23);
            foreach (var student in someStudents)
            {
                Console.WriteLine(student);
            }

            Console.WriteLine("=====ForEach(x => { x.Age += 1; Console.WriteLine(x); })=====");
            students.ForEach(x => { x.Age += 1; Console.WriteLine(x); });
        }
开发者ID:bstaykov,项目名称:Telerik-DSA,代码行数:35,代码来源:Program.cs

示例2: GetFilesXml

        public static FFTText GetFilesXml( XmlNode doc, BackgroundWorker worker, Set<Guid> guidsToLoadFromIso, Stream iso )
        {
            Context context = (Context)Enum.Parse( typeof( Context ), doc.SelectSingleNode( "/FFTText/@context" ).InnerText );
            XmlNode layoutDoc = context == Context.US_PSP ? Resources.PSP : Resources.PSX;
            GenericCharMap charmap = (context == Context.US_PSP) ? (GenericCharMap)TextUtilities.PSPMap : (GenericCharMap)TextUtilities.PSXMap;

            Dictionary<Guid, ISerializableFile> result = new Dictionary<Guid, ISerializableFile>();
            foreach (XmlNode fileNode in doc.SelectNodes( "//File" ))
            {
                string guidText = fileNode.SelectSingleNode( "Guid" ).InnerText;
                Guid guid = new Guid( guidText );
                if (worker.CancellationPending)
                    return null;
                FileInfo fi = GetFileInfo( context, layoutDoc.SelectSingleNode( string.Format( "//Files/*[Guid='{0}']", guidText ) ) );
                string fileComment = GetFileComment( doc.SelectSingleNode( string.Format( "//FFTText/*[Guid='{0}']", guidText ) ) );
                if (worker.CancellationPending)
                    return null;
                XmlNode sectionsNode = fileNode.SelectSingleNode( "Sections" );
                result.Add(
                    guid,
                    AbstractFile.ConstructFile( fi.FileType, charmap, fi, GetStrings( sectionsNode ), fileComment, GetSectionComments( sectionsNode ) ) );
                if (worker.CancellationPending)
                    return null;
            }

            if (guidsToLoadFromIso != null && guidsToLoadFromIso.Count > 0 && iso != null)
            {
                FFTText tempText = null;
                if (context == Context.US_PSP)
                {
                    tempText = GetPspText( iso, worker );
                }
                else if (context == Context.US_PSX)
                {
                    tempText = GetPsxText( iso, worker );
                }

                Set<IFile> isoFiles =
                    new Set<IFile>(
                        tempText.Files.FindAll( f => f is ISerializableFile ).FindAll( g => guidsToLoadFromIso.Contains( (g as ISerializableFile).Layout.Guid ) ) );
                isoFiles.ForEach( f => result.Add( (f as ISerializableFile).Layout.Guid, f as ISerializableFile ) );
            }

            //result.Values.ForEach( f => RemoveUnnecessaryColors( f ) );

            XmlNode quickEditNode = layoutDoc.SelectSingleNode( "//QuickEdit" );
            Set<Guid> guids = GetGuidsNeededForQuickEdit( quickEditNode );
            QuickEdit quickEdit = null;
            if (guids.TrueForAll( g => result.ContainsKey( g ) ))
            {
                quickEdit = new QuickEdit( context, result, GetQuickEditLookup( layoutDoc.SelectSingleNode( "//QuickEdit" ), worker ) );
                if (quickEdit == null || worker.CancellationPending)
                {
                    return null;
                }
            }

            return new FFTText( context, result, null, quickEdit );
        }
开发者ID:Glain,项目名称:FFTPatcher,代码行数:59,代码来源:FFTTextFactory.cs


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