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


C# ISet.Add方法代码示例

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


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

示例1: WalkCircularDependency

        private static IEnumerable<BuildItem> WalkCircularDependency(BuildItem item, IDictionary<BuildItem, List<BuildItem>> scriptsToDependencies, ISet<BuildItem> visitedItems, out bool isCircularPath)
        {
            if(visitedItems.Contains(item))
            {
                isCircularPath = true;
                return Enumerable.Repeat(item, 1);
            }
            if (!scriptsToDependencies.ContainsKey(item))
            {
                isCircularPath = false;
                return Enumerable.Empty<BuildItem>();
            }

            visitedItems.Add(item);
            foreach (var d in scriptsToDependencies[item])
            {
                bool currentIsCircular;
                var currentPath = WalkCircularDependency(d, scriptsToDependencies, visitedItems, out currentIsCircular);
                if(currentIsCircular)
                {
                    isCircularPath = true;
                    return Enumerable.Repeat(item, 1).Concat(currentPath);
                }
            }

            isCircularPath = false;
            return Enumerable.Empty<BuildItem>();
        }
开发者ID:Zocdoc,项目名称:ZocBuild.Database,代码行数:28,代码来源:CircularDependencyError.cs

示例2: ParseInput

        static void ParseInput()
        {
            //string[] inputStr = { "9",
            //    "1 2 1",
            //    "1 4 4",
            //    "1 5 3",
            //    "2 4 4",
            //    "2 5 2",
            //    "4 5 4",
            //    "5 3 4",
            //    "5 6 7",
            //    "3 6 5" };
            int N = int.Parse(Console.ReadLine());
            paths = new Tuple<int, int, int>[N];
            houses = new HashSet<int>();

            for (int i = 1; i <= N; i++)
            {
                var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

                paths[i-1] = new Tuple<int, int, int>(input[0], input[1], input[2]);
                houses.Add(input[0]);
                houses.Add(input[1]);
            }
        }
开发者ID:TheOldMan66,项目名称:TelerikAcademy,代码行数:25,代码来源:Program.cs

示例3: SimpleFixedCityLayer

        public SimpleFixedCityLayer(ISet<ICity> cities, ICityFactory<City> cityFactory)
        {
            Cities = cities;

            Cities.Add(cityFactory.Create(RedCityTile, Red));
            Cities.Add(cityFactory.Create(BlueCityTile, Blue));
        }
开发者ID:SPDiswal,项目名称:ExtenCiv,代码行数:7,代码来源:SimpleFixedCityLayer.cs

示例4: DocumentTitleMatchClassifier

    /// <summary>
    /// Creates a new instance of <see cref="DocumentTitleMatchClassifier"/>
    /// </summary>
    /// <param name="title">the title to match.</param>
    public DocumentTitleMatchClassifier(string title) {
      if (title == null) {
        _potentialTitles = null;
      } else {
        title = title.Trim();
        if (title.Length == 0) {
          _potentialTitles = null;
        } else {
          _potentialTitles = new HashSet<String> { title };

          string p = GetLongestPart(title, "[ ]*[\\|»|:][ ]*");
          if (p != null) {
            _potentialTitles.Add(p);
          }
          p = GetLongestPart(title, "[ ]*[\\|»|:\\(\\)][ ]*");
          if (p != null) {
            _potentialTitles.Add(p);
          }
          p = GetLongestPart(title, "[ ]*[\\|»|:\\(\\)\\-][ ]*");
          if (p != null) {
            _potentialTitles.Add(p);
          }
          p = GetLongestPart(title, "[ ]*[\\|»|,|:\\(\\)\\-][ ]*");
          if (p != null) {
            _potentialTitles.Add(p);
          }
        }
      }
    }
开发者ID:rasmusjp,项目名称:boilerpipe.net,代码行数:33,代码来源:DocumentTitleMatchClassifier.cs

示例5: WhitespaceScanner

 internal WhitespaceScanner(TextReader reader, ErrorReporter reporter)
     : base(reader, reporter)
 {
     whitespace = new HashSet<char>();
     whitespace.Add(' ');
     whitespace.Add('\t');
     whitespace.Add('\n');
 }
开发者ID:Valtis,项目名称:CompilerCourseProject,代码行数:8,代码来源:WhitespaceScanner.cs

示例6: SimpleFixedUnitLayer

        public SimpleFixedUnitLayer(ISet<IUnit> units,
                                    IUnitFactory<Archer> archerFactory,
                                    IUnitFactory<Legion> legionFactory,
                                    IUnitFactory<Settler> settlerFactory)
        {
            Units = units;

            Units.Add(archerFactory.Create(RedArcherTile, Red));
            Units.Add(legionFactory.Create(BlueLegionTile, Blue));
            Units.Add(settlerFactory.Create(RedSettlerTile, Red));
        }
开发者ID:SPDiswal,项目名称:ExtenCiv,代码行数:11,代码来源:SimpleFixedUnitLayer.cs

示例7: Window

 static Window()
 {
     EmptyKeyMap = new KeyMap();
     IgnoreKeys = new HashSet<Gdk.Key>();
     IgnoreKeys.Add(Gdk.Key.Shift_L);
     IgnoreKeys.Add(Gdk.Key.Shift_R);
     IgnoreKeys.Add(Gdk.Key.Shift_Lock);
     IgnoreKeys.Add(Gdk.Key.Meta_L);
     IgnoreKeys.Add(Gdk.Key.Meta_R);
     IgnoreKeys.Add(Gdk.Key.Control_L);
     IgnoreKeys.Add(Gdk.Key.Control_R);
     IgnoreKeys.Add(Gdk.Key.Super_L);
     IgnoreKeys.Add(Gdk.Key.Super_R);
     IgnoreKeys.Add(Gdk.Key.Menu);
 }
开发者ID:ktvoelker,项目名称:di,代码行数:15,代码来源:Window.cs

示例8: SimpleFixedTerrainLayer

        public SimpleFixedTerrainLayer(ISet<ITerrain> terrains,
                                       ITerrainFactory<Hills> hillsFactory,
                                       ITerrainFactory<Mountains> mountainsFactory,
                                       ITerrainFactory<Oceans> oceansFactory,
                                       ITerrainFactory<Plains> plainsFactory)
        {
            Terrains = terrains;
            this.plainsFactory = plainsFactory;

            Terrains.Add(hillsFactory.Create(HillsTile));
            Terrains.Add(mountainsFactory.Create(MountainsTile));
            Terrains.Add(oceansFactory.Create(OceansTile));
            
            AddRemainingPlains();
        }
开发者ID:SPDiswal,项目名称:ExtenCiv,代码行数:15,代码来源:SimpleFixedTerrainLayer.cs

示例9: ParseInput

        private static void ParseInput()
        {
            int N = int.Parse(Console.ReadLine());
            paths = new Tuple<int, int, int>[N];
            houses = new HashSet<int>();

            for (int i = 0; i < N; i++)
            {
                var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

                paths[i] = new Tuple<int, int, int>(input[0], input[1], input[2]);
                houses.Add(input[0]);
                houses.Add(input[1]);
            }
        }
开发者ID:danisio,项目名称:DataStructuresAndAlgorithms-Homeworks,代码行数:15,代码来源:Startup.cs

示例10: LoadGroup

 static void LoadGroup(IList<string> source, ISet<string> target)
 {
     foreach (string buffer in source)
     {
         target.Add(buffer);
     }
 }
开发者ID:p07r0457,项目名称:Liar-Liar,代码行数:7,代码来源:Program.cs

示例11: AddAll

 public static void AddAll(ISet<object> target, IEnumerable source)
 {
     foreach (object entry in source)
     {
         target.Add(entry);
     }
 }
开发者ID:Craiel,项目名称:CarbonProjects,代码行数:7,代码来源:BridgeCollections.cs

示例12: MakeParametersUnique

        private static int MakeParametersUnique(ScriptAction action, ISet<Tuple<string, string>> properties, int sequence)
        {
            if (action.ConfigurationVariables == null)
            {
                return sequence;
            }

            foreach (var configVar in action.ConfigurationVariables)
            {
                var tuple = Tuple.Create(CleanInvalidCharacters(configVar.OriginalName), configVar.Value);
                if (!properties.Contains(tuple))
                {
                    if (properties.Any(p => p.Item1 == tuple.Item1 && p.Item2 != tuple.Item2))
                    {
                        var newVariableName = configVar.RemappedName + sequence;
                        sequence++;
                        action.Arguments = action.Arguments?.Replace(configVar.RemappedName, newVariableName);
                        configVar.RemappedName = newVariableName;
                    }
                }

                properties.Add(tuple);
            }

            return sequence;
        }
开发者ID:DanielBMann9000,项目名称:Migrate-assets-from-RM-server-to-VSTS,代码行数:26,代码来源:UniquePropertyResolver.cs

示例13: CreateEvents

        /// <summary>
        /// Creates the local events and returns the creationEvents, the other Events are stored in the eventMap, handled objects are removed from storedObjects.
        /// </summary>
        /// <returns>
        /// The remote events.
        /// </returns>
        /// <param name='storedObjects'>
        /// Stored objects.
        /// </param>
        /// <param name='remoteTree'>
        /// Remote tree.
        /// </param>
        /// <param name='eventMap'>
        /// Event map.
        /// </param>
        public List<AbstractFolderEvent> CreateEvents(
            List<IMappedObject> storedObjects,
            IObjectTree<IFileableCmisObject> remoteTree,
            Dictionary<string, Tuple<AbstractFolderEvent, AbstractFolderEvent>> eventMap,
            ISet<IMappedObject> handledStoredObjects)
        {
            List<AbstractFolderEvent> createdEvents = new List<AbstractFolderEvent>();
            var storedParent = storedObjects.Find(o => o.RemoteObjectId == remoteTree.Item.Id);

            foreach (var child in remoteTree.Children) {
                var storedMappedChild = storedObjects.Find(o => o.RemoteObjectId == child.Item.Id);
                if (storedMappedChild != null) {
                    AbstractFolderEvent newEvent = this.CreateRemoteEventBasedOnStorage(child.Item, storedParent, storedMappedChild);
                    eventMap[child.Item.Id] = new Tuple<AbstractFolderEvent, AbstractFolderEvent>(null, newEvent);
                } else {
                    // Added
                    AbstractFolderEvent addEvent = FileOrFolderEventFactory.CreateEvent(child.Item, null, MetaDataChangeType.CREATED, src: this);
                    createdEvents.Add(addEvent);
                }

                createdEvents.AddRange(this.CreateEvents(storedObjects, child, eventMap, handledStoredObjects));
                if (storedMappedChild != null) {
                    handledStoredObjects.Add(storedMappedChild);
                }
            }

            return createdEvents;
        }
开发者ID:OpenDataSpace,项目名称:CmisSync,代码行数:43,代码来源:RemoteEventGenerator.cs

示例14: LadderLength

 public int LadderLength(string start, string end, ISet<string> dict)
 {
     var queue = new Queue<string>();
     queue.Enqueue(start);
     dict.Add(end);
     int step = 0;
     while (queue.Count != 0)
     {
         var level = new Queue<string>();
         step++;
         while (queue.Count != 0)
         {
             String q = queue.Dequeue();
             if (q.Equals(end))
                 return step;
             for (int i = 0; i < start.Length; i++)
             {
                 for (char c = 'a'; c <= 'z'; c++)
                 {
                     String s = q.Substring(0, i) + c + q.Substring(i + 1, start.Length - 1 - i);
                     if (dict.Contains(s))
                     {
                         level.Enqueue(s);
                         dict.Remove(s);
                     }
                 }
             }
         }
         queue = level;
     }
     return 0;
 }
开发者ID:YouenZeng,项目名称:LeetCode,代码行数:32,代码来源:WordLadderSolution.cs

示例15: AddMods

        protected override void AddMods( ISet<AttributeMod> mods, ISet<StatMod> statMods )
        {
            int music, peace, provo, disco;
            GetSkillBonus( out music, out peace, out provo, out disco );

            int statBonus = 2 + music + provo + peace + disco;
            statMods.Add( new StatMod( StatType.Str, "Invigorate Str", statBonus ) );
            statMods.Add( new StatMod( StatType.Dex, "Invigorate Dex", statBonus ) );
            statMods.Add( new StatMod( StatType.Int, "Invigorate Int", statBonus ) );

            int hitsBonus = 5 + ( 2 * music ) + ( 3 * provo ) + peace + disco;
            mods.Add( new AttributeMod( MagicalAttribute.BonusHits, hitsBonus ) );

            this.BuffInfo = new BuffInfo( this.BuffIcon, 1115613, 1115730,
                String.Format( "{0}\t{1}\t{1}\t{1}", hitsBonus, statBonus ), false );
        }
开发者ID:Ravenwolfe,项目名称:xrunuo,代码行数:16,代码来源:Invigorate.cs


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