public void Merge() { StringSet ss = new StringSet(); ss.Add("foo"); StringSet so = new StringSet(); so.Add("bar"); so.Add("baz"); ss.Add(so); Assert.AreEqual(3, ss.Count); so = new StringSet(); so.Add("boo"); so.Add("baz"); ss.Add(so); Assert.AreEqual(4, ss.Count); ss.Remove(so); Assert.AreEqual(2, ss.Count); Assert.IsTrue(ss["foo"]); Assert.IsTrue(ss["bar"]); Assert.IsFalse(ss["boo"]); Assert.IsFalse(ss["baz"]); Assert.IsFalse(ss["bloo"]); }
//TODO: This needs more work. Currently it reports all individual symbols most of the time, in a message like // "Syntax error, expected: + - < > = ..."; the better method is to group operator symbols under one alias "operator". // The reason is that code picks expected key list at current(!) state only, // slightly tweaking it for non-terminals, without exploring Reduce roots // It is quite difficult to discover grouping non-terminals like "operator" in current structure. // One possible solution would be to introduce "ExtendedLookaheads" in ParserState which would include // all NonTerminals that might follow the current position. This list would be calculated at start up, // in addition to normal lookaheads. #endregion private StringList GetCurrentExpectedSymbols() { BnfTermList inputElements = new BnfTermList(); StringSet inputKeys = new StringSet(); inputKeys.AddRange(_currentState.Actions.Keys); //First check all NonTerminals foreach (NonTerminal nt in Data.NonTerminals) { if (!inputKeys.Contains(nt.Key)) { continue; } //nt is one of our available inputs; check if it has an alias. If not, don't add it to element list; // and we have already all its "Firsts" keys in the list. // If yes, add nt to element list and remove // all its "fists" symbols from the list. These removed symbols will be represented by single nt alias. if (string.IsNullOrEmpty(nt.DisplayName)) { inputKeys.Remove(nt.Key); } else { inputElements.Add(nt); foreach (string first in nt.Firsts) { inputKeys.Remove(first); } } } //Now terminals foreach (Terminal term in Data.Terminals) { if (inputKeys.Contains(term.Key)) { inputElements.Add(term); } } StringList result = new StringList(); foreach (BnfTerm term in inputElements) { result.Add(string.IsNullOrEmpty(term.DisplayName)? term.Name : term.DisplayName); } result.Sort(); return(result); }
/// <summary> /// Remove a single feature from the node. /// Does not fire OnFeatures, since this should mostly be used by /// things that are not querying externally. /// /// No exception should be thrown if the feature doesn't exist. /// </summary> /// <param name="feature">The feature URI to remove</param> public void RemoveFeature(string feature) { if (Features == null) { return; } Features.Remove(feature); }
public void ShouldRemoveAndContainsReturnFalse() { var stringSet = new StringSet(); stringSet.Add("Test"); Assert.IsTrue(stringSet.Contains("Test")); stringSet.Remove("Test"); Assert.IsFalse(stringSet.Contains("Test")); }
public void SetOfStringVsStringSetTest() { var setOfString = new Set <string> { "Case" }; var stringSet = new StringSet(true) { "Case" }; setOfString.Remove("case"); setOfString.Must().HaveCountOfExactly(1).OrThrow(); stringSet.Remove("case"); setOfString.Must().HaveCountOfExactly(0).OrThrow(); }
public void RemoveSet(ChartSetInfo setInfo) { string relPath = Path.Combine(setInfo.FilePath, setInfo.FileName); m_chartSets.Remove(setInfo.ID, out var _); m_chartSetsByFilePath.Remove(relPath, out var _); m_setFiles.Remove(relPath); Exec("DELETE FROM Sets WHERE filePath=?", setInfo.FilePath); foreach (var chart in setInfo.Charts) { RemoveChart(chart); } }
public void Add() { StringSet ss = new StringSet(); ss.Add("foo"); ss.Add("foo"); ss.Add("bar"); Assert.IsTrue(ss["foo"]); Assert.AreEqual(2, ss.Count); Assert.AreEqual("foo\r\nbar\r\n", ss.ToString()); ss.Remove("bar"); Assert.AreEqual(1, ss.Count); Assert.IsFalse(ss["fool"]); ss = new StringSet(new string[] { "foo", "bar"}); ss.Add(new StringSet("baz")); Assert.AreEqual(3, ss.Count); }
private void ParseFile(string physicalPath, VirtualPath virtualPath) { // Determine the file used for the circular references checker. Normally, // we use the virtualPath, but we use the physical path if it specified, // as is the case for <!-- #include file="foo.inc" --> string fileToReferenceCheck = physicalPath != null ? physicalPath : virtualPath.VirtualPathString; // Check for circular references of include files if (_circularReferenceChecker.Contains(fileToReferenceCheck)) { throw new HttpException( SR.GetString(SR.Circular_include)); } // Add the current file to the circular references checker. _circularReferenceChecker.Add(fileToReferenceCheck); try { // Open a TextReader either from the physical or virtual path TextReader reader; if (physicalPath != null) { using (reader = Util.ReaderFromFile(physicalPath, virtualPath)) { ParseReader(reader); } } else { using (Stream stream = virtualPath.OpenFile()) { reader = Util.ReaderFromStream(stream, virtualPath); ParseReader(reader); } } } finally { // Remove the current file from the circular references checker _circularReferenceChecker.Remove(fileToReferenceCheck); } }
private StringSet FilterBracesInExpectedSet(StringSet stateExpectedSet) { var result = new StringSet(); result.UnionWith(stateExpectedSet); //Find what brace we expect var nextClosingBrace = string.Empty; if (OpenBraces.Count > 0) { var lastOpenBraceTerm = OpenBraces.Peek().KeyTerm; var nextClosingBraceTerm = lastOpenBraceTerm.IsPairFor as KeyTerm; if (nextClosingBraceTerm != null) nextClosingBrace = nextClosingBraceTerm.Text; } //Now check all closing braces in result set, and leave only nextClosingBrace foreach(var closingBrace in Language.GrammarData.ClosingBraces) { if (result.Contains(closingBrace) && closingBrace != nextClosingBrace) result.Remove(closingBrace); } return result; }
private StringList GetCurrentExpectedSymbols() { BnfTermList inputElements = new BnfTermList(); StringSet inputKeys = new StringSet(); inputKeys.AddRange(_currentState.Actions.Keys); //First check all NonTerminals foreach (NonTerminal nt in Data.NonTerminals) { if (!inputKeys.Contains(nt.Key)) continue; //nt is one of our available inputs; check if it has an alias. If not, don't add it to element list; // and we have already all its "Firsts" keys in the list. // If yes, add nt to element list and remove // all its "fists" symbols from the list. These removed symbols will be represented by single nt alias. if (string.IsNullOrEmpty(nt.DisplayName)) inputKeys.Remove(nt.Key); else { inputElements.Add(nt); foreach(string first in nt.Firsts) inputKeys.Remove(first); } } //Now terminals foreach (Terminal term in Data.Terminals) { if (inputKeys.Contains(term.Key)) inputElements.Add(term); } StringList result = new StringList(); foreach(BnfTerm term in inputElements) result.Add(string.IsNullOrEmpty(term.DisplayName)? term.Name : term.DisplayName); result.Sort(); return result; }