public void TestOverlaps () { var aSet = new HashSet<int> { 1, 2 }; var bSet = new HashSet<int> { 1 }; Assert.IsTrue (aSet.Overlaps (bSet)); }
public virtual List<AbstracteEffect> getEffectListByKey(HashSet<EffectActionTypes> keys) { List<AbstracteEffect> returnedList = new List<AbstracteEffect> (); foreach (AbstracteEffect effect in effects.Values) { if (keys.Overlaps(effect.getEffectActionList())) { returnedList.Add(effect); } } return returnedList; }
static void Main(string[] args) { var myHash = new HashSet<String>(); myHash.Add("hello"); myHash.Add("hello"); String[] s = new String[] { "hello" }; Console.WriteLine(myHash.Count); Console.WriteLine(myHash.Overlaps(s)); }
public override List<AbstracteEffect> getEffectListByKey(HashSet<EffectActionTypes> keys) { List<AbstracteEffect> returnedList = base.getEffectListByKey (keys); for (int i = currentLifeIndex; i < healthPoints.Length; i++) { if ((healthPoints [i].effect != null) && (keys.Overlaps(healthPoints [i].effect.getEffectActionList())) ) { returnedList.Add(healthPoints [i].effect); } } return returnedList; }
static void Main() { var companyTeams = new HashSet<string>() { "Ferrari", "McLaren", "Mercedes" }; var traditionalTeams = new HashSet<string>() { "Ferrari", "McLaren" }; var privateTeams = new HashSet<string>() { "Red Bull", "Lotus", "Toro Rosso", "Force India", "Sauber" }; if (privateTeams.Add("Williams")) WriteLine("Williams added"); if (!companyTeams.Add("McLaren")) WriteLine("McLaren was already in this set"); if (traditionalTeams.IsSubsetOf(companyTeams)) { WriteLine("traditionalTeams is subset of companyTeams"); } if (companyTeams.IsSupersetOf(traditionalTeams)) { WriteLine("companyTeams is a superset of traditionalTeams"); } traditionalTeams.Add("Williams"); if (privateTeams.Overlaps(traditionalTeams)) { WriteLine("At least one team is the same with traditional and private teams"); } var allTeams = new SortedSet<string>(companyTeams); allTeams.UnionWith(privateTeams); allTeams.UnionWith(traditionalTeams); WriteLine(); WriteLine("all teams"); foreach (var team in allTeams) { WriteLine(team); } allTeams.ExceptWith(privateTeams); WriteLine(); WriteLine("no private team left"); foreach (var team in allTeams) { WriteLine(team); } }
int GetDisplayedBountyValue(Actor self, HashSet<string> deathTypes, string bountyType) { var bounty = GetBountyValue(self); if (cargo == null) return bounty; foreach (var a in cargo.Passengers) { var givesProximityBounty = a.TraitsImplementing<GivesProximityBounty>().Where(gpb => deathTypes.Overlaps(gpb.info.DeathTypes) && (gpb.info.BountyTypes.Count == 0 || gpb.info.BountyTypes.Contains(bountyType))); foreach (var gpb in givesProximityBounty) bounty += gpb.GetDisplayedBountyValue(a, deathTypes, bountyType); } return bounty; }
private static HashSet<string> GetRequiredStrippableModules(HashSet<string> nativeClasses) { HashSet<string> hashSet = new HashSet<string>(); string[] moduleNames = ModuleMetadata.GetModuleNames(); for (int i = 0; i < moduleNames.Length; i++) { string text = moduleNames[i]; if (ModuleMetadata.GetModuleStrippable(text)) { HashSet<string> classNames = CodeStrippingUtils.GetClassNames(ModuleMetadata.GetModuleClasses(text)); if (nativeClasses.Overlaps(classNames)) { hashSet.Add(text); } } } return hashSet; }
/// <summary> /// Append the result of this dependency graph to the end of the given sorting solution /// </summary> /// <param name="instance">The instance.</param> /// <returns></returns> public TopologicalSort CalculateSort(TopologicalSort instance) { HashSet<OrderedProcess> unused = new HashSet<OrderedProcess>(_processes); do { HashSet<OrderedProcess> set = new HashSet<OrderedProcess>( unused.Where(p => !unused.Overlaps(p.Predecessors)) //select processes which have no predecessors in the unused set, which means that all their predecessors must either be used, or not exist, either way is fine ); if (set.Count == 0) throw new InvalidOperationException("Cannot order this set of processes"); unused.ExceptWith(set); foreach (var subset in SolveResourceDependencies(set)) instance.Append(subset); } while (unused.Count > 0); return instance; }
private static bool NameContainsUri(string name) { var wordsInName = name.SplitCamelCaseToWords(); return(UrlNameVariants.Overlaps(wordsInName)); }
public bool Overlaps(IEnumerable <string> other) { return(tags.Overlaps(other)); }
private bool EvaluateTags(HashSet <string> allcats) { return(!allcats.Overlaps(this.GetHideCategories())); }
/// <summary> /// Verifies that no circular exception will be created and then sends CHANGE request to server. /// </summary> /// <param name="name">The cell to be changed</param> /// <param name="content">The candidate contents of the cell</param> public void Change(string name, string content) { // If we're waiting for a change to be confirmed by the server, don't take a new change. if (_currentChangeCell != null) { return; } var normalizedName = Normalize(name); // Check if content is null. if (content == null) { throw new ArgumentNullException(); } // Check if name is null or invalid. if (normalizedName == null || !_validCellNameRegex.IsMatch(normalizedName) || !IsValid(normalizedName)) { throw new InvalidNameException(); } if (content.StartsWith("=")) { Formula formula = new Formula(content.Substring(1), IsValid, Normalize); // The HashSet dependents contains name and all of name's direct and indirect dependents. var dependents = new HashSet<string>(GetCellsToRecalculate(normalizedName)); // Variables contains name's new dependees. var variables = formula.GetVariables(); // Checking if any of name's new dependees are already its dependents // or if name is its own new dependee. if (dependents.Overlaps(variables)) { throw new CircularException(); } } _currentChangeCell = normalizedName; _currentChangeContent = content; _socket.BeginSend("CHANGE\n" + _name + "\n" + _version + "\nCell:" + normalizedName + "\nLength:" + content.Length.ToString() + "\n" + content + "\n", (e, o) => { }, null); }
/// <summary> /// temporarily flips joints to remove cycles /// </summary> private void RemoveGraphCycles() { HashSet<GraphNode> tempGraph = new HashSet<GraphNode>(RobotNodes.Values.ToArray()); while (tempGraph.Count > 0) { bool hasFinished = false; while (!hasFinished)//remove all sources from tempGraph. A source is a node with no parents { hasFinished = true; GraphNode tempNode; for (int i = 0; i < tempGraph.Count;i++ ) { tempNode = tempGraph.ElementAt(i); if(!tempGraph.Overlaps(tempNode.ParentNodes)) { tempGraph.Remove(tempNode); hasFinished = false; i--; } } } hasFinished = false; while (!hasFinished)//remove all sinks from the graph. A sink is a node with no children { hasFinished = true; GraphNode tempNode; for (int i = 0; i < tempGraph.Count; i++) { tempNode = tempGraph.ElementAt(i); if(!tempGraph.Overlaps(tempNode.ChildNodes)) { tempGraph.Remove(tempNode); hasFinished = false; i--; } } } if (tempGraph.Count > 0) //If nodes are left, they must be in a cycle, so flip joints to fix { foreach (GraphNode tempNode in tempGraph) { if (tempNode.Equals(RobotNodes[0]) || tempNode.ParentNodes.Count > 1) { List<GraphNode> tempList = tempNode.ParentNodes.ToList(); foreach (GraphNode g in tempList) { if (tempGraph.Contains(g)) { tempNode.FlipJoint(g); } } break; } } } } }
/// <summary> /// Checks the second transition in a 2-transition jump and sees if we can /// perform the collapse (there's no overlap, etc.) /// </summary> /// <param name="beginning">The first expanded node (beginning, middle, /// end)</param> /// <param name="jump1">The first edge (beginning-middle)</param> /// <param name="jump1Events">The events in the first edge</param> /// <param name="involvedInFirst">The objects involved in jump1</param> /// <param name="edgesToAdd">(out) A list in which we write the edges to /// add to the graph</param> private static void AnalyzeEndpoints( ExplorationNode beginning, ExplorationEdge jump1, IEnumerable<TransitionEvent> jump1Events, HashSet<uint> involvedInFirst, IList<ExplorationEdge> edgesToAdd) { // Get all of the final endpoint jumps (middle-end) foreach (ExplorationEdge jump2 in jump1.Target.Outgoing) { ExplorationNode end = jump2.Target; List<TransitionEvent> jump2Events = new List<TransitionEvent>(jump2.Events); // All the objects in jump2 HashSet<uint> involvedSecond = new HashSet<uint>(); GetInvolved(jump2Events).ForEach( (uint id) => { DebugUtil.Assert(involvedSecond.Contains(id) == false); involvedSecond.Add(id); }); // There's no overlap if (involvedInFirst.Overlaps(involvedSecond) == false) { List<TransitionEvent> combined = new List<TransitionEvent>(); combined.AddRange( jump1Events.Convert(s => new TransitionEvent(s))); combined.AddRange( jump2Events.Convert(s => new TransitionEvent(s))); edgesToAdd.Add( new ExplorationEdge(beginning, end, combined.ToArray())); } } }
public void Test_Overlaps() { hs = new HashSet<int> { 1, 6, 7, 8}; HashSet<int> hs1 = new HashSet<int> { 1, 2, 3, 4, 5, 6, 7, 8}; Assert.That(hs.Overlaps(hs1), Is.True); }
// Adds an output adapter to the dependency chain. private void AddOutputAdapter(IOutputAdapter adapter, ISet <IAdapter> dependencyChain, IInputAdapter[] inputAdapterCollection, IActionAdapter[] actionAdapterCollection, IOutputAdapter[] outputAdapterCollection) { HashSet <MeasurementKey> inputMeasurementKeys = new HashSet <MeasurementKey>(adapter.InputMeasurementKeys()); // Adds the adapter to the chain dependencyChain.Add(adapter); if ((object)inputAdapterCollection != null) { // Checks all input adapters to determine whether they also need to be // added to the chain as a result of this adapter being added to the chain foreach (IInputAdapter inputAdapter in inputAdapterCollection) { if (inputAdapter.Initialized && !dependencyChain.Contains(inputAdapter) && inputMeasurementKeys.Overlaps(inputAdapter.OutputMeasurementKeys())) { AddInputAdapter(inputAdapter, dependencyChain, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection); } } } if ((object)actionAdapterCollection != null) { // Checks all action adapters to determine whether they also need to be // added to the chain as a result of this adapter being added to the chain foreach (IActionAdapter actionAdapter in actionAdapterCollection) { if (actionAdapter.Initialized && actionAdapter.RespectOutputDemands && !dependencyChain.Contains(actionAdapter) && inputMeasurementKeys.Overlaps(actionAdapter.OutputMeasurementKeys())) { AddActionAdapter(actionAdapter, dependencyChain, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection); } } } }
void InitializeActorPreviews() { panel.RemoveChildren(); if (!selectedCategories.Any()) { return; } foreach (var a in allActors) { if (!selectedCategories.Overlaps(a.Categories)) { continue; } if (!string.IsNullOrEmpty(searchFilter) && !a.SearchTerms.Any(s => s.IndexOf(searchFilter, StringComparison.OrdinalIgnoreCase) >= 0)) { continue; } var actor = a.Actor; var td = new TypeDictionary(); td.Add(new OwnerInit(selectedOwner.Name)); td.Add(new FactionInit(selectedOwner.Faction)); foreach (var api in actor.TraitInfos <IActorPreviewInitInfo>()) { foreach (var o in api.ActorPreviewInits(actor, ActorPreviewType.MapEditorSidebar)) { td.Add(o); } } try { var item = ScrollItemWidget.Setup(itemTemplate, () => { var brush = editor.CurrentBrush as EditorActorBrush; return(brush != null && brush.Actor == actor); }, () => editor.SetBrush(new EditorActorBrush(editor, actor, selectedOwner, worldRenderer))); var preview = item.Get <ActorPreviewWidget>("ACTOR_PREVIEW"); preview.SetPreview(actor, td); // Scale templates to fit within the panel var scale = 1f; if (scale * preview.IdealPreviewSize.X > itemTemplate.Bounds.Width) { scale = (itemTemplate.Bounds.Width - panel.ItemSpacing) / (float)preview.IdealPreviewSize.X; } preview.GetScale = () => scale; preview.Bounds.Width = (int)(scale * preview.IdealPreviewSize.X); preview.Bounds.Height = (int)(scale * preview.IdealPreviewSize.Y); item.Bounds.Width = preview.Bounds.Width + 2 * preview.Bounds.X; item.Bounds.Height = preview.Bounds.Height + 2 * preview.Bounds.Y; item.IsVisible = () => true; item.GetTooltipText = () => a.Tooltip; panel.AddChild(item); } catch { Log.Write("debug", "Map editor ignoring actor {0}, because of missing sprites for tileset {1}.", actor.Name, world.Map.Rules.TileSet.Id); continue; } } }
public static bool Overlaps <T>(IEnumerable <T> set1, IEnumerable <T> set2) { var newSet = new HashSet <T>(set1); return(newSet.Overlaps(set2)); }
public bool Overlaps(IEnumerable <T> other) => items.Overlaps(other);
public IEnumerable <ArgSwitch> ParseArgs(string[] args) { var current = new ArgSwitch(); bool inProgramArgs = true; var used = new HashSet <string>(); int index = 0; int end = args.Length - 1; foreach (var argument in args) { ArgSwitchDesc desc; if (Switches.TryGetValue(argument, out desc)) { if (!inProgramArgs) { var last = Switches[current.Name]; if (last.MustBeUsedAlone) { throw new ArgParseException( string.Format("Option '{0}' cannot be used with other arguments.", desc.Name)); } if (current.Arguments.Count < last.MinArgs) { throw new ArgParseException(string.Format("Option '{0}' requires at least {1} argument{2}.", last.Name, last.MinArgs, last.MinArgs > 1 ? "s" : "")); } } if (used.Overlaps(desc.CantBeUsedWith)) { throw new ArgParseException(string.Format("Option '{0}' cannot be used with: '{1}'.", desc.Name, string.Join(" or ", desc.CantBeUsedWith))); } if (desc.MustAppearOnlyOnce && used.Contains(desc.Name)) { throw new ArgParseException(string.Format("Option '{0}' may only be used once.", desc.Name)); } used.Add(argument); yield return(current); inProgramArgs = false; current = new ArgSwitch(argument); if (index == end) { if (desc.MinArgs > 0) { throw new ArgParseException( string.Format("Option '{0}' requires at least {1} argument{2}.", desc.Name, desc.MinArgs, desc.MinArgs > 1 ? "s" : "")); } yield return(current); } } else if (index == end) { if (!inProgramArgs) { var last = Switches[current.Name]; if (last.MaxArgs == 0) { throw new ArgParseException(string.Format("Option '{0}' does not allow for arguments.", last.Name)); } if (last.MaxArgs != -1 && current.Arguments.Count == last.MaxArgs) { throw new ArgParseException(string.Format("Option '{0}' only allows {1} argument{2}.", last.Name, last.MaxArgs, last.MaxArgs > 1 ? "s" : "")); } current.Arguments.Add(argument); } else { current.Arguments.Add(argument); } yield return(current); } else { if (!inProgramArgs) { var last = Switches[current.Name]; if (last.MaxArgs == 0) { throw new ArgParseException(string.Format("Option '{0}' does not allow for arguments.", last.Name)); } if (last.MaxArgs != -1 && current.Arguments.Count == last.MaxArgs) { throw new ArgParseException(string.Format("Option '{0}' only allows {1} argument{2}.", last.Name, last.MaxArgs, last.MaxArgs > 1 ? "s" : "")); } } current.Arguments.Add(argument); } index++; } }
private static void ExcludeModuleManagers(ref HashSet<string> nativeClasses) { string[] moduleNames = ModuleMetadata.GetModuleNames(); int derivedFromClassID = BaseObjectTools.StringToClassID("GlobalGameManager"); foreach (string str in moduleNames) { if (ModuleMetadata.GetModuleStrippable(str)) { int[] moduleClasses = ModuleMetadata.GetModuleClasses(str); HashSet<int> set = new HashSet<int>(); HashSet<string> other = new HashSet<string>(); foreach (int num3 in moduleClasses) { if (BaseObjectTools.IsDerivedFromClassID(num3, derivedFromClassID)) { set.Add(num3); } else { other.Add(BaseObjectTools.ClassIDToString(num3)); } } if ((other.Count != 0) && !nativeClasses.Overlaps(other)) { foreach (int num5 in set) { nativeClasses.Remove(BaseObjectTools.ClassIDToString(num5)); } } } } }
public static void Update() { if (!File.Exists(BoltFlow.Paths.unitOptions)) { Build(); return; } lock (@lock) { using (ProfilingUtility.SampleBlock("Update Unit Database")) { using (NativeUtility.Module("sqlite3.dll")) { var progressTitle = "Updating unit database..."; SQLiteConnection database = null; try { VersionControlUtility.Unlock(BoltFlow.Paths.unitOptions); var steps = 7f; var step = 0f; ProgressUtility.DisplayProgressBar(progressTitle, "Connecting to database...", step++ / steps); database = new SQLiteConnection(BoltFlow.Paths.unitOptions); ProgressUtility.DisplayProgressBar(progressTitle, "Updating type mappings...", step++ / steps); UpdateTypeMappings(); ProgressUtility.DisplayProgressBar(progressTitle, "Fetching modified scripts...", step++ / steps); var modifiedScriptGuids = GetModifiedScriptGuids().Distinct().ToHashSet(); ProgressUtility.DisplayProgressBar(progressTitle, "Fetching deleted scripts...", step++ / steps); var deletedScriptGuids = GetDeletedScriptGuids().Distinct().ToHashSet(); ProgressUtility.DisplayProgressBar(progressTitle, "Updating codebase...", step++ / steps); var modifiedScriptTypes = modifiedScriptGuids.SelectMany(GetScriptTypes).ToArray(); UpdateCodebase(modifiedScriptTypes); var outdatedScriptGuids = new HashSet <string>(); outdatedScriptGuids.UnionWith(modifiedScriptGuids); outdatedScriptGuids.UnionWith(deletedScriptGuids); ProgressUtility.DisplayProgressBar(progressTitle, "Removing outdated unit options...", step++ / steps); options?.RemoveWhere(option => outdatedScriptGuids.Overlaps(option.sourceScriptGuids)); // We want to use the database level WHERE here for speed, // so we'll run multiple queries, one for each outdated script GUID. foreach (var outdatedScriptGuid in outdatedScriptGuids) { foreach (var outdatedRowId in database.Table <UnitOptionRow>() .Where(row => row.sourceScriptGuids.Contains(outdatedScriptGuid)) .Select(row => row.id)) { database.Delete <UnitOptionRow>(outdatedRowId); } } ProgressUtility.DisplayProgressBar(progressTitle, "Converting codebase to unit options...", step++ / steps); var newOptions = new HashSet <IUnitOption>(modifiedScriptGuids.SelectMany(GetScriptTypes) .Distinct() .SelectMany(GetIncrementalOptions)); var rows = new HashSet <UnitOptionRow>(); float progress = 0; foreach (var newOption in newOptions) { options?.Add(newOption); try { ProgressUtility.DisplayProgressBar(progressTitle, newOption.label, (step / steps) + ((1 / step) * (progress / newOptions.Count))); rows.Add(newOption.Serialize()); } catch (Exception ex) { Debug.LogError($"Failed to serialize option '{newOption.GetType()}'.\n{ex}"); } progress++; } ProgressUtility.DisplayProgressBar(progressTitle, "Writing to database...", 1); try { database.InsertAll(rows); } catch (Exception ex) { Debug.LogError($"Failed to write options to database.\n{ex}"); } // Make sure the database is touched to the current date, // even if we didn't do any change. This will avoid unnecessary // analysis in future update checks. File.SetLastWriteTimeUtc(BoltFlow.Paths.unitOptions, DateTime.UtcNow); } finally { database?.Close(); ProgressUtility.ClearProgressBar(); UnityAPI.Async(AssetDatabase.Refresh); //ConsoleProfiler.Dump(); } } } } }
/// <summary> /// Determines whether the current System.Collections.Generic.HashSet`1 object and a specified collection share common elements. /// </summary> /// <param name="other"> The collection to compare to the current hash set. </param> /// <returns> /// True if the hash set and other share at least one common element; otherwise, false. /// </returns> public virtual bool Overlaps(IEnumerable <T> other) => _set.Overlaps(other);
public override bool CanParse(HashSet <Type> packetTypeSet) { return(packetTypeSet.Overlaps(this.unusedPacketTypes)); }
private bool EvaluateTags(HashSet<string> allcats) { return !allcats.Overlaps(HideTags); }
private static HashSet<string> GetRequiredStrippableModules(HashSet<string> nativeClasses) { HashSet<string> set = new HashSet<string>(); foreach (string str in ModuleMetadata.GetModuleNames()) { if (ModuleMetadata.GetModuleStrippable(str)) { HashSet<string> classNames = GetClassNames(ModuleMetadata.GetModuleClasses(str)); if (nativeClasses.Overlaps(classNames)) { set.Add(str); } } } return set; }
public void OverlapsFailureTest() { var set = new HashSet<int>(); var arr = Enumerable.Range(0, 10); set.UnionWith(Enumerable.Range(11, 20)); Assert.IsFalse(set.Overlaps(arr)); }
private static void ExcludeModuleManagers(ref HashSet<string> nativeClasses) { string[] moduleNames = ModuleMetadata.GetModuleNames(); int derivedFromClassID = BaseObjectTools.StringToClassID("GlobalGameManager"); string[] array = moduleNames; for (int i = 0; i < array.Length; i++) { string moduleName = array[i]; if (ModuleMetadata.GetModuleStrippable(moduleName)) { int[] moduleClasses = ModuleMetadata.GetModuleClasses(moduleName); HashSet<int> hashSet = new HashSet<int>(); HashSet<string> hashSet2 = new HashSet<string>(); int[] array2 = moduleClasses; for (int j = 0; j < array2.Length; j++) { int num = array2[j]; if (BaseObjectTools.IsDerivedFromClassID(num, derivedFromClassID)) { hashSet.Add(num); } else { hashSet2.Add(BaseObjectTools.ClassIDToString(num)); } } if (hashSet2.Count != 0) { if (!nativeClasses.Overlaps(hashSet2)) { foreach (int current in hashSet) { nativeClasses.Remove(BaseObjectTools.ClassIDToString(current)); } } } } } }
//GL public HashSet<MDPStateStat> CollectPminZeroStates() { bool done = false; HashSet<MDPStateStat> target = new HashSet<MDPStateStat>(TargetStates); HashSet<MDPStateStat> reached = new HashSet<MDPStateStat>(); reached.UnionWith(target); HashSet<MDPStateStat> copyTarget = new HashSet<MDPStateStat>(); //updated while (done == false) { HashSet<MDPStateStat> postreached = MDPStateStat.cloneHashSet(reached); List<MDPStateStat> preTarget = new List<MDPStateStat>(); HashSet<MDPStateStat> intsPre = null; foreach (MDPStateStat state in reached) //updated { if (copyTarget.Contains(state)) { continue; } //updated preTarget = state.Pre; if (intsPre == null) { intsPre = new HashSet<MDPStateStat>(preTarget); } else { //intsPre.IntersectWith(preTarget); intsPre.UnionWith(preTarget); } } // intsPre2 = this.ListStateFromHashset(intsPre); if (intsPre == null) { done = true; break; } //updated HashSet<MDPStateStat> enLargeTarget = MDPStateStat.cloneHashSet(intsPre); foreach (MDPStateStat st in intsPre) { foreach (DistributionStat ds in st.Distributions) { // HashSet<MDPStateStat> nextStates = new HashSet<KeyValuePair> (ds.States); HashSet<MDPStateStat> endStates = new HashSet<MDPStateStat>(); endStates = ds.getEndStates(); if (!reached.Overlaps(endStates)) //updated { enLargeTarget.Remove(st); goto firstforloop; } } firstforloop: ; } copyTarget = MDPStateStat.cloneHashSet(reached); //updated postreached.UnionWith(enLargeTarget); if (reached.SetEquals(postreached)) done = true; reached = postreached; } return reached; }
//static async Task Main() //{ // //var intList = new List<int>(); // var racers=new List<Racer>(); // List<int> intList=new List<int>(10); // intList.Capacity = 20; // intList.TrimExcess(); // var intList2=new List<int>(); // intList2.Add(1); // intList2.Add(2); // var stringList=new List<string>(); // stringList.Add("one"); // stringList.Add("two"); // var graham=new Racer(7,"Graham","Hill","UK",14); // var emerson = new Racer(7, "Graham", "Hill", "UK", 14); // var mario = new Racer(7, "Graham", "Hill", "UK", 14); // var racers2 = new List<Racer>(20){ graham,emerson,mario}; // racers2.Add(new Racer(24,"a","b","c",25)); // racers2.Add(new Racer(21,"a","b","c",22)); // racers2.Insert(3,new Racer(6,"Pjil","Hill","USA",3)); // racers2.RemoveAt(3); // int index = racers2.IndexOf(mario); // RacerComparer racerComparer = new RacerComparer(RacerComparer.CompareType.Country); // racers2.Sort(racerComparer); // var dm=new DocumentManager(); // Task processDocuments = ProcessDocuments.Start(dm); // for (int i = 0; i < 1000; i++) // { // var doc=new Document($"Doc{i.ToString()}","content"); // dm.AddDocument(doc); // Console.WriteLine(doc.Title); // await Task.Delay(new Random().Next(20)); // } // await processDocuments; // Console.ReadLine(); // var alphabet = new Stack<char>(); // alphabet.Push('A'); // alphabet.Push('B'); // alphabet.Push('C'); // foreach (char item in alphabet) // { // Console.WriteLine(item); // } // Console.WriteLine(); // while (alphabet.Count>0) // { // Console.WriteLine(alphabet.Pop()); // } // Console.WriteLine(); // var pdm=new PriorityDocumentManager(); // pdm.AddDocument(new Document("a","b",1)); // pdm.AddDocument(new Document("a", "b", 2)); // pdm.AddDocument(new Document("a", "b", 3)); // pdm.AddDocument(new Document("a", "b", 4)); // pdm.AddDocument(new Document("a", "b", 5)); // pdm.DisplayAllNodes(); // #region 有序列表 // var books=new SortedList<string, string>(); // books.Add("a","1"); // books.Add("b","2"); // books.Add("c","3"); // books["d"] = "4"; // foreach (var book in books) // { // Console.WriteLine($"{book.Key},{book.Value}"); // } // foreach (var title in books.Keys) // { // Console.WriteLine(title); // } // #endregion //} static void Main() { var companyTeams = new HashSet <string>() { "A", "b", "c" }; var traditionalTeams = new HashSet <string>() { "a1", "b1", "c1" }; var privateTeams = new HashSet <string>() { "a2", "b2", "c2" }; if (privateTeams.Add("williams")) { Console.WriteLine("w add"); } if (!companyTeams.Add("McLaren")) { Console.WriteLine("mclaren set"); } if (traditionalTeams.IsSubsetOf(companyTeams)) { Console.WriteLine("tarditionalTeams is subset of companyTeams"); } if (companyTeams.IsSubsetOf(traditionalTeams)) { Console.WriteLine("companyTeams is a superset of traditionalTeams"); } traditionalTeams.Add("Williams"); if (privateTeams.Overlaps(traditionalTeams)) { Console.WriteLine("At least one team is the same with traditional and private teams"); } var idJimmie = new EmployeeId("C48"); var jimmie = new Employee(idJimmie, "Jimmie Johnson", 150926.00m); var idJoey = new EmployeeId("F22"); var joey = new Employee(idJoey, "Joey Logano", 45125.00m); var employees = new Dictionary <EmployeeId, Employee>(31) { [idJimmie] = jimmie, [idJoey] = joey }; foreach (var employee in employees.Values) { Console.WriteLine(employee); } while (true) { Console.WriteLine("Enter employee id (X to exit)> "); var userInput = Console.ReadLine(); userInput = userInput.ToUpper(); if (userInput == "X") { break; } EmployeeId id; try { id = new EmployeeId(userInput); if (!employees.TryGetValue(id, out Employee employee)) { Console.WriteLine($"{id} 不存在"); } else { Console.WriteLine(employee); } } catch (Exception e) { Console.WriteLine(e.Message); } } }
private static void ExcludeModuleManagers(ref HashSet<string> nativeClasses) { string[] moduleNames = ModuleMetadata.GetModuleNames(); int classId = BaseObjectTools.StringToClassID("GlobalGameManager"); foreach (string moduleName in moduleNames) { if (ModuleMetadata.GetModuleStrippable(moduleName)) { int[] moduleClasses = ModuleMetadata.GetModuleClasses(moduleName); HashSet<int> intSet = new HashSet<int>(); HashSet<string> stringSet = new HashSet<string>(); foreach (int num in moduleClasses) { if (BaseObjectTools.IsDerivedFromClassID(num, classId)) intSet.Add(num); else stringSet.Add(BaseObjectTools.ClassIDToString(num)); } if (stringSet.Count != 0 && !nativeClasses.Overlaps((IEnumerable<string>) stringSet)) { using (HashSet<int>.Enumerator enumerator = intSet.GetEnumerator()) { while (enumerator.MoveNext()) { int current = enumerator.Current; nativeClasses.Remove(BaseObjectTools.ClassIDToString(current)); } } } } } }
public bool Overlaps(IEnumerable <T> other) { return(collection.Overlaps(other)); }
public bool Overlaps(IEnumerable <T> other) { bool overlaps = hashSet.Overlaps(other); return(overlaps); }
//-------------------------------------------------------------------------------------------------------------------------------- public bool Overlaps(EnumHashSet <T> other) { return(Raw.Overlaps(other.Raw)); }
public void TestOverlaps() { var set = new HashSet <int> (new [] { 1, 2, 3, 4, 5 }); Assert.IsTrue(set.Overlaps(new [] { 0, 2 })); }
/// <inheritdoc/> public bool Overlaps(IEnumerable <T> other) { return(innerHashSet.Overlaps(other)); }
public bool Overlaps(IEnumerable <T> other) { return(_set.Overlaps(other)); }
public static bool Overlaps <T>(HashSet <T> hashSet, IEnumerable <T> other) { (hashSet as Mock <T>)?.CheckDataRace(false); return(hashSet.Overlaps(other)); }
public bool Overlaps(IEnumerable <T> other) { return(_wrapped.Overlaps(other)); }
public bool Overlaps(IEnumerable <T> set) => content.Overlaps(set);
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor) { return(targetTypes.Overlaps(target.GetEnabledTargetTypes())); }
public bool IsValidTarget(IEnumerable <string> targetTypes) { return(validTargetSet.Overlaps(targetTypes) && !invalidTargetSet.Overlaps(targetTypes)); }
// Adds an output adapter to the dependency chain. private void AddOutputAdapter(IOutputAdapter adapter, ISet<IAdapter> dependencyChain, IInputAdapter[] inputAdapterCollection, IActionAdapter[] actionAdapterCollection, IOutputAdapter[] outputAdapterCollection) { HashSet<MeasurementKey> inputMeasurementKeys = new HashSet<MeasurementKey>(adapter.InputMeasurementKeys()); // Adds the adapter to the chain dependencyChain.Add(adapter); if ((object)inputAdapterCollection != null) { // Checks all input adapters to determine whether they also need to be // added to the chain as a result of this adapter being added to the chain foreach (IInputAdapter inputAdapter in inputAdapterCollection) { if (!dependencyChain.Contains(inputAdapter) && inputMeasurementKeys.Overlaps(inputAdapter.OutputMeasurementKeys())) AddInputAdapter(inputAdapter, dependencyChain, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection); } } if ((object)actionAdapterCollection != null) { // Checks all action adapters to determine whether they also need to be // added to the chain as a result of this adapter being added to the chain foreach (IActionAdapter actionAdapter in actionAdapterCollection) { if (actionAdapter.RespectOutputDemands && !dependencyChain.Contains(actionAdapter) && inputMeasurementKeys.Overlaps(actionAdapter.OutputMeasurementKeys())) AddActionAdapter(actionAdapter, dependencyChain, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection); } } }
// <summary> // Requires: other set must not be null and must have the same comparer. // Returns true if this set and other set have some elements in common. // </summary> internal bool Overlaps(Set <TElement> other) { AssertSetCompatible(other); return(_values.Overlaps(other._values)); }
private static OverloadGroupEquivalenceInfo GetOverloadGroupEquivalence(Dictionary<string, List<RuntimeArgument>> groupDefinitions) { OverloadGroupEquivalenceInfo info = new OverloadGroupEquivalenceInfo(); if (!groupDefinitions.IsNullOrEmpty()) { string[] array = new string[groupDefinitions.Count]; groupDefinitions.Keys.CopyTo(array, 0); for (int i = 0; i < array.Length; i++) { string str = array[i]; HashSet<RuntimeArgument> set = new HashSet<RuntimeArgument>(groupDefinitions[str]); for (int j = i + 1; j < array.Length; j++) { string str2 = array[j]; HashSet<RuntimeArgument> other = new HashSet<RuntimeArgument>(groupDefinitions[str2]); if (set.IsProperSupersetOf(other)) { info.SetAsSuperset(str, str2); } else if (set.IsProperSubsetOf(other)) { info.SetAsSuperset(str2, str); } else if (set.SetEquals(other)) { info.SetAsEquivalent(str, str2); } else if (set.Overlaps(other)) { info.SetAsOverlapping(str, str2); } else { info.SetAsDisjoint(str, str2); } } } } return info; }
public bool Overlaps(IEnumerable <TVal> other) => hashSet.Overlaps(other);
public void OverlapsTest() { var set=new HashSet<int>(); var arr = Enumerable.Range(0, 10); set.UnionWith(Enumerable.Range(8, 10)); Assert.IsTrue(set.Overlaps(arr)); }
static OverloadGroupEquivalenceInfo GetOverloadGroupEquivalence(Dictionary<string, List<RuntimeArgument>> groupDefinitions) { OverloadGroupEquivalenceInfo overloadGroupsInfo = new OverloadGroupEquivalenceInfo(); if (!groupDefinitions.IsNullOrEmpty()) { string[] groupNames = new string[groupDefinitions.Count]; groupDefinitions.Keys.CopyTo(groupNames, 0); for (int i = 0; i < groupNames.Length; i++) { string group1 = groupNames[i]; HashSet<RuntimeArgument> group1Args = new HashSet<RuntimeArgument>(groupDefinitions[group1]); for (int j = i + 1; j < groupNames.Length; j++) { string group2 = groupNames[j]; HashSet<RuntimeArgument> group2Args = new HashSet<RuntimeArgument>(groupDefinitions[group2]); if (group1Args.IsProperSupersetOf(group2Args)) { overloadGroupsInfo.SetAsSuperset(group1, group2); } else if (group1Args.IsProperSubsetOf(group2Args)) { overloadGroupsInfo.SetAsSuperset(group2, group1); } else if (group1Args.SetEquals(group2Args)) { overloadGroupsInfo.SetAsEquivalent(group1, group2); } else if (group1Args.Overlaps(group2Args)) { overloadGroupsInfo.SetAsOverlapping(group1, group2); } else // the groups are disjoint. { overloadGroupsInfo.SetAsDisjoint(group1, group2); } } } } return overloadGroupsInfo; }
public override void PostUpdateBySync(HashSet<SyncableProperties.Type> updatedProperties) { SceneObjectPart sop = (SceneObjectPart)SceneThing; UUID uuid = sop.UUID; // All updated properties are in the set of TerseUpdateProperites bool allTerseUpdates = updatedProperties.IsSubsetOf(SyncableProperties.TerseUpdateProperties); // Any updated properties are in the set of GroupProperties bool hasGroupUpdates = updatedProperties.Overlaps(SyncableProperties.GroupProperties); if (!hasGroupUpdates || sop.ParentGroup == null) { if (allTerseUpdates) sop.ScheduleTerseUpdate(); else sop.ScheduleFullUpdate(); } else { if (allTerseUpdates) sop.ParentGroup.ScheduleGroupForTerseUpdate(); else sop.ParentGroup.ScheduleGroupForFullUpdate(); } /* string props = ""; foreach (SyncableProperties.Type t in updatedProperties) props += t.ToString() + ","; DebugLog.WarnFormat("{0}: PostUpdateBySync: uuid={1}, allterse={2}, groupupates={3}, props={4}", LogHeader, uuid, allTerseUpdates, hasGroupUpdates, props); */ }
/// <summary> /// NOTE: Relies on the results from CombineMCPComicsData /// </summary> /// <param name="pathDataDir"></param> private static void AssembleMCPCharacterCharacters(string pathDataDir) { Console.WriteLine("Starting character-characters data assembling . . ."); int countProcessedCharacter = 0; int totalNumCharacters = FileManager.GetNumLinesInCSV(FileManager.GetPathResultCharComics(pathDataDir)); using (StreamWriter writer = new StreamWriter(FileManager.GetPathResultCharChars(pathDataDir), false)) { string pathCharComics = FileManager.GetPathResultCharComics(pathDataDir); FileStream outerFileStream = new FileStream(pathCharComics, FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read); using (StreamReader outerReader = new StreamReader(outerFileStream)) { while (!outerReader.EndOfStream) { string outerInput = outerReader.ReadLine(); if (!outerReader.Equals(String.Empty)) { Console.WriteLine(String.Format("Processing character #{0} of {1}", countProcessedCharacter, totalNumCharacters)); ++countProcessedCharacter; string[] testCharData = outerInput.Split(','); string testCharId = testCharData[0]; HashSet<string> testCharComics = new HashSet<string>(); for (int i = 1; i < testCharData.Length; ++i) { testCharComics.Add(testCharData[i]); } writer.Write(testCharId); // Check overlapping with all characters FileStream innerFileStream = new FileStream(pathCharComics, FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read); using (StreamReader innerReader = new StreamReader(innerFileStream)) { while (!innerReader.EndOfStream) { string innerInput = innerReader.ReadLine(); if (!innerInput.Equals(String.Empty)) { string[] nextCharData = innerInput.Split(','); string nextCharId = nextCharData[0]; if (!nextCharId.Equals(testCharId)) { HashSet<string> nextCharComics = new HashSet<string>(); for (int i = 1; i < nextCharData.Length; ++i) { nextCharComics.Add(nextCharData[i]); } if (testCharComics.Overlaps(nextCharComics)) { writer.Write(String.Format(",{0}", nextCharId)); } } } } } writer.WriteLine(); } } } } Console.WriteLine("Finished character-characters data assembling."); }
public static bool LocationsAreUniqueOnRoute(INetworkCoverage source, Route route) { //find all locations and checks for doubles. var locationsSet = new HashSet<INetworkLocation>(); foreach (var segment in route.Segments.Values) { IEnumerable<INetworkLocation> locations = GetLocationsForSegment(segment, source, false); if (locationsSet.Overlaps(locations)) return false; foreach (var location in locations) { locationsSet.Add(location); } } return true; }
public bool Overlaps(IEnumerable <string> other) { return(_hashset.Overlaps(other)); }
private static HashSet<string> GetRequiredStrippableModules(HashSet<string> nativeClasses) { HashSet<string> stringSet = new HashSet<string>(); foreach (string moduleName in ModuleMetadata.GetModuleNames()) { if (ModuleMetadata.GetModuleStrippable(moduleName)) { HashSet<string> classNames = CodeStrippingUtils.GetClassNames((IEnumerable<int>) ModuleMetadata.GetModuleClasses(moduleName)); if (nativeClasses.Overlaps((IEnumerable<string>) classNames)) stringSet.Add(moduleName); } } return stringSet; }
public static async Task <bool> DoOperationAndWaitForReplicasToRestart(TyeHost host, HashSet <string> toRestart, HashSet <string> rest, Func <ReplicaEvent, string> entitySelector, TimeSpan waitUntilSuccess, Func <TyeHost, Task> operation) { if (rest != null && rest.Overlaps(toRestart)) { throw new ArgumentException($"{nameof(toRestart)} and {nameof(rest)} can't overlap"); } var restartedTask = new TaskCompletionSource <bool>(); var remaining = toRestart.Count; var alreadyStarted = 0; void OnReplicaChange(ReplicaEvent ev) { if (ev.State == ReplicaState.Started) { Interlocked.Increment(ref alreadyStarted); } else if (ev.State == ReplicaState.Stopped) { if (toRestart.Contains(entitySelector(ev))) { Interlocked.Decrement(ref remaining); } else if (rest != null && rest.Contains(entitySelector(ev))) { restartedTask !.SetResult(false); } } if (remaining == 0 && alreadyStarted == toRestart.Count) { Task.Delay(waitUntilSuccess) .ContinueWith(_ => { if (!restartedTask !.Task.IsCompleted) { restartedTask !.SetResult(remaining == 0 && alreadyStarted == toRestart.Count); } }); } } var servicesStateObserver = host.Application.Services.Select(srv => srv.Value.ReplicaEvents.Subscribe(OnReplicaChange)).ToList(); await operation(host); using var cancellation = new CancellationTokenSource(WaitForServicesTimeout); try { await using (cancellation.Token.Register(() => restartedTask.TrySetCanceled())) { return(await restartedTask.Task); } } finally { foreach (var observer in servicesStateObserver) { observer.Dispose(); } } }
public void OnEnable() { editorSettings = JointEditorSettings.Singleton; if (editorSettings == null) { return; } var defaultNames = new HashSet<string> {"slider", "lock", "offset"}; var childControlNames = GetControlNames(); if (defaultNames.Overlaps(childControlNames)) { Debug.LogError("Reserved control names: " + String.Join(",", defaultNames.Intersect(childControlNames) .ToArray()) + "."); } controlNames = new HashSet<string>(defaultNames.Union(childControlNames)); if (EditorHelpers.AllowMultiObjectAccess) { var allSettings = targets.Cast<Joint2D>() .Select(joint2D => SettingsHelper.GetOrCreate(joint2D)) .Where(jointSettings => jointSettings != null) .Cast<Object>() .ToList(); if (allSettings.Count > 0) { serializedSettings = new SerializedObject(allSettings.ToArray()); } else { serializedSettings = null; } } else { if (target) { serializedSettings = new SerializedObject(new Object[] {SettingsHelper.GetOrCreate(target as Joint2D)}); } else { serializedSettings = null; } } }
public void Collections() { string stringExample = "Hello world!"; string[] stringArray = { "Hello", "World", "Why", "is", "it", "always", stringExample, "?" }; string thirdItem = stringArray[2]; Console.WriteLine(thirdItem); stringArray[0] = "Hello there"; Console.WriteLine(stringArray[0]); // Lists List <string> listOfStrings = new List <string>(); List <int> listOfInts = new List <int>(); listOfStrings.Add("some \"silly\" nonsense"); listOfInts.Add(12345); int length = listOfStrings.Count; Console.WriteLine(listOfStrings[0]); Console.WriteLine(listOfInts[0]); // Queues Queue <string> firstInFirstOut = new Queue <string>(); firstInFirstOut.Enqueue("I'm first"); firstInFirstOut.Enqueue("I'm next"); string firstItem = firstInFirstOut.Dequeue(); Console.WriteLine(firstItem); Console.WriteLine(firstInFirstOut.Dequeue()); // Dictionaries Dictionary <int, string> keysAndValues = new Dictionary <int, string>(); keysAndValues.Add(5, "something"); keysAndValues.Add(6, "something else"); keysAndValues[5] = "something totally different"; Console.WriteLine("DICTIONARY VALUE: " + keysAndValues[5]); Dictionary <string, decimal> importantNumbers = new Dictionary <string, decimal>(); importantNumbers.Add("pi", 3.141592653589793238462643383279m); importantNumbers.Add("phi", 1.681033m); Console.WriteLine(importantNumbers["pi"]); Dictionary <string, Dictionary <string, string> > dictionaryception = new Dictionary <string, Dictionary <string, string> >(); SortedList <int, string> sortedKeyAndValue = new SortedList <int, string>(); sortedKeyAndValue.Add(13, "blah"); HashSet <int> uniqueList = new HashSet <int>(); uniqueList.Add(1); uniqueList.Add(3); uniqueList.Add(5); HashSet <int> otherHashSet = new HashSet <int>(); otherHashSet.Add(3); Console.WriteLine(uniqueList.Overlaps(otherHashSet)); Stack <string> lastInFirstOut = new Stack <string>(); }
public bool Overlaps(IEnumerable <string> other) => Flags.Overlaps(other);
/// <summary> /// Loads hidden field state. We use this instead of LoadViewState because the latter doesn't get called during post backs on which the page structure /// changes. /// </summary> protected override sealed object LoadPageStateFromPersistenceMedium() { string formValueHash = null; string lastPostBackFailingDmId = null; try { // Based on our implementation of SavePageStateToPersistenceMedium, the base implementation of LoadPageStateFromPersistenceMedium will return a Pair // with no First object. var pair = base.LoadPageStateFromPersistenceMedium() as Pair; var savedState = PageState.CreateFromViewState( (object[])pair.Second ); AppRequestState.Instance.EwfPageRequestState = new EwfPageRequestState( savedState.Item1, Request.Form[ "__SCROLLPOSITIONX" ], Request.Form[ "__SCROLLPOSITIONY" ] ); formValueHash = (string)savedState.Item2[ 0 ]; lastPostBackFailingDmId = (string)savedState.Item2[ 1 ]; } catch { // Set a 400 status code if there are any problems loading hidden field state. We're assuming these problems are never the developers' fault. if( AppRequestState.Instance.EwfPageRequestState == null ) AppRequestState.Instance.EwfPageRequestState = new EwfPageRequestState( PageState.CreateForNewPage(), null, null ); Response.StatusCode = 400; Response.TrySkipIisCustomErrors = true; AppRequestState.Instance.EwfPageRequestState.TopModificationErrors = Translation.ApplicationHasBeenUpdatedAndWeCouldNotInterpretAction.ToSingleElementArray(); resetPage(); } onLoadData(); var requestState = AppRequestState.Instance.EwfPageRequestState; ResourceInfo redirectInfo = null; FullResponse fullSecondaryResponse = null; executeWithDataModificationExceptionHandling( () => { validateFormSubmission( formValueHash ); // Get the post-back object and, if necessary, the last post-back's failing data modification. var postBackId = Request.Form[ postBackHiddenFieldName ]; // returns null if field missing var postBack = postBackId != null ? GetPostBack( postBackId ) : null; if( postBack == null ) throw new DataModificationException( Translation.AnotherUserHasModifiedPageAndWeCouldNotInterpretAction ); var lastPostBackFailingDm = postBack.IsIntermediate && lastPostBackFailingDmId != null ? lastPostBackFailingDmId.Any() ? GetPostBack( lastPostBackFailingDmId ) as DataModification : dataUpdate : null; if( postBack.IsIntermediate && lastPostBackFailingDmId != null && lastPostBackFailingDm == null ) throw new DataModificationException( Translation.AnotherUserHasModifiedPageAndWeCouldNotInterpretAction ); // Execute the page's data update. var dmExecuted = false; if( !postBack.IsIntermediate ) { try { dmExecuted |= dataUpdate.Execute( !postBack.ForcePageDataUpdate, formValues.Any( i => i.ValueChangedOnPostBack( requestState.PostBackValues ) ), handleValidationErrors ); } catch { AppRequestState.Instance.EwfPageRequestState.DmIdAndSecondaryOp = Tuple.Create( "", SecondaryPostBackOperation.NoOperation ); throw; } } // Execute the post-back. var actionPostBack = postBack as ActionPostBack; if( actionPostBack != null ) { var formValuesChanged = GetDescendants( contentContainer ) .OfType<FormControl>() .Any( i => i.FormValue != null && i.FormValue.ValueChangedOnPostBack( requestState.PostBackValues ) ); try { dmExecuted |= actionPostBack.Execute( formValuesChanged, handleValidationErrors, postBackAction => { if( postBackAction == null ) return; redirectInfo = postBackAction.Resource; if( postBackAction.SecondaryResponse != null ) fullSecondaryResponse = postBackAction.SecondaryResponse.GetFullResponse(); } ); } catch { AppRequestState.Instance.EwfPageRequestState.DmIdAndSecondaryOp = Tuple.Create( actionPostBack.Id, SecondaryPostBackOperation.NoOperation ); throw; } } if( dmExecuted ) { AppRequestState.AddNonTransactionalModificationMethod( () => StandardLibrarySessionState.Instance.StatusMessages.AddRange( statusMessages ) ); try { AppRequestState.Instance.CommitDatabaseTransactionsAndExecuteNonTransactionalModificationMethods(); } finally { DataAccessState.Current.ResetCache(); } } if( postBack.IsIntermediate ) { var regionSets = new HashSet<UpdateRegionSet>( actionPostBack.UpdateRegions ); var preModRegions = updateRegionLinkers.SelectMany( i => i.PreModificationRegions, ( linker, region ) => new { region.Sets, region.ControlGetter, linker.Key, region.ArgumentGetter } ) .Where( i => regionSets.Overlaps( i.Sets ) ) .ToArray(); var staticRegionContents = getStaticRegionContents( preModRegions.SelectMany( i => i.ControlGetter() ) ); requestState.PostBackValues.RemoveExcept( staticRegionContents.Item2.Select( i => i.GetPostBackValueKey() ) ); requestState.DmIdAndSecondaryOp = Tuple.Create( actionPostBack.ValidationDm == dataUpdate ? "" : ( (ActionPostBack)actionPostBack.ValidationDm ).Id, actionPostBack.ValidationDm == lastPostBackFailingDm ? SecondaryPostBackOperation.Validate : SecondaryPostBackOperation.ValidateChangesOnly ); requestState.SetStaticAndUpdateRegionState( staticRegionContents.Item1, preModRegions.Select( i => Tuple.Create( i.Key, i.ArgumentGetter() ) ).ToArray() ); } else requestState.PostBackValues = null; } ); navigate( redirectInfo, requestState.ModificationErrorsExist ? null : fullSecondaryResponse ); return null; }
/// <summary> /// Overlaps /// </summary> /// <param name="other">Other</param> /// <returns>"true" if overlaps, otherwise "false"</returns> public bool Overlaps(IEnumerable <Regex> other) => patterns.Overlaps(other);
public void Overlaps() { var set = new HashSet<int>(); Assert.That(() => { set.Overlaps(null); }, Throws.TypeOf(typeof(ArgumentNullException))); Assert.IsFalse(set.Overlaps(new[] { 3, 9, 11 })); set.AddRange(Enumerable.Range(0, 10)); Assert.IsTrue(set.Overlaps(set)); Assert.IsTrue(set.Overlaps(new[] { 3, 9, 11 })); Assert.IsTrue(set.Overlaps(new HashSet<int>(new[] { 3, 9, 11 }))); Assert.IsFalse(set.Overlaps(new[] { 11 })); Assert.IsFalse(set.Overlaps(new HashSet<int>(new[] { 11 }))); }