示例#1
0
        private static void SetColumns(Table t, OrderedHashSet <string> set)
        {
            int num = 0;

            bool[] newColumnCheckList = t.GetNewColumnCheckList();
            for (int i = 0; i < set.Size(); i++)
            {
                string name  = set.Get(i);
                int    index = t.FindColumn(name);
                if (index == -1)
                {
                    throw Error.GetError(0x157d, name);
                }
                newColumnCheckList[index] = true;
                num++;
            }
            if (num == 0)
            {
                throw Error.GetError(0x157d);
            }
            set.Clear();
            for (int j = 0; j < newColumnCheckList.Length; j++)
            {
                if (newColumnCheckList[j])
                {
                    set.Add(t.GetColumn(j).GetName().Name);
                }
            }
        }
示例#2
0
        public OrderedHashSet <ISchemaObject> GetComponents()
        {
            OrderedHashSet <ISchemaObject> set1 = new OrderedHashSet <ISchemaObject>();

            set1.AddAll(this.Routines);
            return(set1);
        }
示例#3
0
        public OrderedHashSet <string> GetColumnsForAllRights(Table table)
        {
            if (this.IsFull)
            {
                return(table.GetColumnNameSet());
            }
            if ((this.IsFullSelect || this.IsFullInsert) || (this.IsFullUpdate || this.IsFullReferences))
            {
                return(table.GetColumnNameSet());
            }
            OrderedHashSet <string> set2 = new OrderedHashSet <string>();

            if (this._selectColumnSet != null)
            {
                set2.AddAll(this._selectColumnSet);
            }
            if (this._insertColumnSet != null)
            {
                set2.AddAll(this._insertColumnSet);
            }
            if (this._updateColumnSet != null)
            {
                set2.AddAll(this._updateColumnSet);
            }
            if (this._referencesColumnSet != null)
            {
                set2.AddAll(this._referencesColumnSet);
            }
            return(set2);
        }
示例#4
0
 public Constraint(QNameManager.QName name, OrderedHashSet <string> mainCols, int type)
 {
     this.Core       = new ConstraintCore();
     this._name      = name;
     this.ConstType  = type;
     this.MainColSet = mainCols;
 }
示例#5
0
 /** Add local var decl */
 public virtual void AddLocalDecl(Decl d)
 {
     if (locals == null)
         locals = new OrderedHashSet<Decl>();
     locals.Add(d);
     d.isLocal = true;
 }
示例#6
0
        public OrderedHashSet <QNameManager.QName> GetReferences()
        {
            switch (this.ConstType)
            {
            case 0:
            {
                OrderedHashSet <QNameManager.QName> set1 = new OrderedHashSet <QNameManager.QName>();
                set1.Add(this.Core.UniqueName);
                return(set1);
            }

            case 3:
            {
                OrderedHashSet <QNameManager.QName> set = new OrderedHashSet <QNameManager.QName>();
                this.Check.CollectObjectNames(set);
                for (int i = set.Size() - 1; i >= 0; i--)
                {
                    QNameManager.QName name = set.Get(i);
                    if ((name.type == 9) || (name.type == 3))
                    {
                        set.Remove(i);
                    }
                }
                return(set);
            }
            }
            return(new OrderedHashSet <QNameManager.QName>());
        }
示例#7
0
        public OrderedHashSet <Expression> GetCheckColumnExpressions()
        {
            OrderedHashSet <Expression> set = new OrderedHashSet <Expression>();

            this.Check.CollectAllExpressions(set, Expression.ColumnExpressionSet, Expression.EmptyExpressionSet);
            return(set);
        }
示例#8
0
 public override void CollectTableNamesForWrite(OrderedHashSet <QNameManager.QName> set)
 {
     if (this._expression == null)
     {
         set.AddAll(this.Procedure.GetTableNamesForWrite());
     }
 }
示例#9
0
        public static void SetVariables(RangeVariable[] rangeVars, OrderedHashSet <string> colNames, int[] indexes, ColumnSchema[] variables)
        {
            int i = -1;

            for (int j = 0; j < variables.Length; j++)
            {
                string columnName = colNames.Get(j);
                for (int k = 0; k < rangeVars.Length; k++)
                {
                    if (rangeVars[k].IsVariable)
                    {
                        i = rangeVars[k].FindColumn(columnName);
                        if (i > -1)
                        {
                            indexes[j]   = i;
                            variables[j] = rangeVars[k].GetColumn(i);
                            break;
                        }
                    }
                }
                if (i == -1)
                {
                    throw Error.GetError(0x157d, columnName);
                }
            }
        }
示例#10
0
        public void CheckRoleList(string granteeName, OrderedHashSet <string> roleList, Grantee grantor, bool grant)
        {
            Grantee grantee = this.Get(granteeName);

            for (int i = 0; i < roleList.Size(); i++)
            {
                string  name = roleList.Get(i);
                Grantee role = this.GetRole(name);
                if (role == null)
                {
                    throw Error.GetError(0x898, name);
                }
                if (name.Equals("SYS") || name.Equals("PUBLIC"))
                {
                    throw Error.GetError(0xfa2, name);
                }
                if (grant)
                {
                    if (grantee.GetDirectRoles().Contains(role))
                    {
                        throw Error.GetError(0x898, granteeName);
                    }
                }
                else if (!grantee.GetDirectRoles().Contains(role))
                {
                    throw Error.GetError(0x898, name);
                }
                if (!grantor.IsAdmin())
                {
                    throw Error.GetError(0x7d0, grantor.GetNameString());
                }
            }
        }
        public IEnumerable <IEventDefinition> GetEvents(EventDefinitionFilter filter)
        {
            if (_events == null)
            {
                return(Enumerable.Empty <IEventDefinition>());
            }

            switch (filter)
            {
            case EventDefinitionFilter.All:
                return(FilterSupersededAndUpdateToLatestEntity(_events));

            case EventDefinitionFilter.FirstIn:
                var l1 = new OrderedHashSet <IEventDefinition>();
                foreach (var e in _events)
                {
                    l1.Add(e);
                }
                return(FilterSupersededAndUpdateToLatestEntity(l1));

            case EventDefinitionFilter.LastIn:
                var l2 = new OrderedHashSet <IEventDefinition>(keepOldest: false);
                foreach (var e in _events)
                {
                    l2.Add(e);
                }
                return(FilterSupersededAndUpdateToLatestEntity(l2));

            default:
                throw new ArgumentOutOfRangeException("filter", filter, null);
            }
        }
示例#12
0
        public Right GetAllGrantableRights(QNameManager.QName name)
        {
            if (this._isAdmin)
            {
                return(name.schema.Owner.OwnerRights);
            }
            if (name.schema.Owner == this)
            {
                return(this.OwnerRights);
            }
            if (this.Roles.Contains(name.schema.Owner))
            {
                return(name.schema.Owner.OwnerRights);
            }
            OrderedHashSet <Grantee> allRoles = this.GetAllRoles();

            for (int i = 0; i < allRoles.Size(); i++)
            {
                Grantee grantee = allRoles.Get(i);
                if (name.schema.Owner == grantee)
                {
                    return(grantee.OwnerRights);
                }
            }
            Right right2 = this._fullRightsMap.Get(name);

            if ((right2 != null) && (right2.GrantableRights != null))
            {
                return(right2.GrantableRights);
            }
            return(Right.NoRights);
        }
示例#13
0
文件: SubQuery.cs 项目: cwdotson/FwNs
        protected void SetDependentProperties(OrderedHashSet <SubQuery> set)
        {
            Iterator <SubQuery> iterator = set.GetIterator();
            bool flag = false;

            while (iterator.HasNext())
            {
                SubQuery query = iterator.Next();
                if (query.IsNamed)
                {
                    flag = true;
                }
                if (query.NamedParentSubQuery == null)
                {
                    query.NamedParentSubQuery = this;
                }
            }
            if (flag)
            {
                iterator = set.GetIterator();
                while (iterator.HasNext())
                {
                    iterator.Next().SetCorrelated();
                }
            }
        }
示例#14
0
    public override void AppendTo(ref SpanWriter writer, OrderedHashSet <string> strings, ref int entries, ref int switches)
    {
        var textIndex = strings.GetOrAdd(InitialText ?? "");

        writer.WriteAscii($"{{ textentry {X} {Y} {Width} {Height} {Hue} {EntryID} {textIndex} }}");
        entries++;
    }
示例#15
0
        public void Remove()
        {
            Random random = new Random(1);

            OrderedHashSet <string> ohs = new OrderedHashSet <string>(random);


            string s_1 = "hello";
            string s_2 = "world";

            ohs.Add(s_1);
            ohs.Add(s_2);


            ohs.Remove(s_2);


            bool found = false;

            foreach (string s in ohs)
            {
                if (s == s_2)
                {
                    found = true;

                    break;
                }
            }


            Assert.IsFalse(found);
        }
示例#16
0
        public string[] GetSql(OrderedHashSet <object> resolved, OrderedHashSet <object> unresolved)
        {
            List <string> list = new List <string>();

            if (!(this.Map is HashMappedList <string, object>))
            {
                return(null);
            }
            if (this.Map.IsEmpty())
            {
                return(new string[0]);
            }
            Iterator <object> it = this.Map.GetValues().GetIterator();

            if (((this._type == 0x10) || (this._type == 0x11)) || (this._type == 0x1b))
            {
                OrderedHashSet <object> set = new OrderedHashSet <object>();
                while (it.HasNext())
                {
                    RoutineSchema schema = (RoutineSchema)it.Next();
                    for (int i = 0; i < schema.Routines.Length; i++)
                    {
                        Routine key = schema.Routines[i];
                        if ((key.DataImpact != 1) && (key.DataImpact != 2))
                        {
                            set.Add(key);
                        }
                    }
                }
                it = set.GetIterator();
            }
            AddAllSql(resolved, unresolved, list, it, null);
            return(list.ToArray());
        }
示例#17
0
        public OrderedHashSet <SubQuery> GetSubqueries()
        {
            OrderedHashSet <SubQuery> set = null;

            if (this.JoinCondition != null)
            {
                set = this.JoinCondition.CollectAllSubqueries(set);
            }
            if (!(this.RangeTable is TableDerived))
            {
                return(set);
            }
            QueryExpression queryExpression = this.RangeTable.GetQueryExpression();

            if (((TableDerived)this.RangeTable).view != null)
            {
                if (set == null)
                {
                    set = new OrderedHashSet <SubQuery>();
                }
                set.AddAll(((TableDerived)this.RangeTable).view.GetSubqueries());
                return(set);
            }
            if (queryExpression == null)
            {
                return(OrderedHashSet <SubQuery> .Add(set, this.RangeTable.GetSubQuery()));
            }
            OrderedHashSet <SubQuery> subqueries = queryExpression.GetSubqueries();

            set = OrderedHashSet <SubQuery> .AddAll(set, subqueries);

            SubQuery subQuery = this.RangeTable.GetSubQuery();

            return(OrderedHashSet <SubQuery> .AddAll(OrderedHashSet <SubQuery> .Add(set, subQuery), subQuery.GetExtraSubqueries()));
        }
示例#18
0
 internal Enumerator(OrderedHashSet <TValue> OrderedHashSet)
 {
     _OrderedHashSet = OrderedHashSet;
     _version        = OrderedHashSet._version;
     _index          = 0;
     _current        = default;
 }
示例#19
0
        public override void AppendTo(ref SpanWriter writer, OrderedHashSet <string> strings, ref int entries, ref int switches)
        {
            writer.Write((ushort)0x7B20); // "{ "
            writer.Write(LayoutName);
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(X.ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(Y.ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(NormalID.ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(PressedID.ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(((int)Type).ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(Param.ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(ButtonID.ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(ItemID.ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(Hue.ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(Width.ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(Height.ToString());

            if (LocalizedTooltip > 0)
            {
                writer.Write(LayoutTooltip);
                writer.WriteAscii(LocalizedTooltip.ToString());
            }

            writer.Write((ushort)0x207D); // " }"
        }
示例#20
0
 public void Revoke(OrderedHashSet <string> granteeList, ISchemaObject[] routines, Right rights, Grantee grantor, bool grantOption, bool cascade)
 {
     for (int i = 0; i < routines.Length; i++)
     {
         this.Revoke(granteeList, routines[i], rights, grantor, grantOption, cascade);
     }
 }
示例#21
0
    public override void AppendTo(ref SpanWriter writer, OrderedHashSet <string> strings, ref int entries, ref int switches)
    {
        var initialState = InitialState ? "1" : "0";

        writer.WriteAscii($"{{ radio {X} {Y} {InactiveID} {ActiveID} {initialState} {SwitchID} }}");
        switches++;
    }
示例#22
0
        internal static void DeduplicateFiles()
        {
            Console.WriteLine("Deduplicating Files");
            foreach (var f in UsedFiles)
            {
                var removed = 0;
                var scanned = new OrderedHashSet <string>();
                using (var reader = new StreamReader(f))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        try
                        {
                            scanned.Add(line);
                        }
                        catch
                        {
                            removed++;
                        }
                    }
                }

                using (var writer = new StreamWriter(f, false))
                {
                    foreach (var line in scanned)
                    {
                        writer.WriteLine(line);
                    }
                }
                Console.WriteLine($"Removed {removed} lines from {f}");
            }
        }
示例#23
0
        public AlphaMemory(ILoggerFactory loggerFactory)
        {
            _scheduler = new LimitedConcurrencyLevelTaskScheduler(1);
            _facts     = new OrderedHashSet <TFact>();

            _log = loggerFactory.CreateLogger <AlphaMemory <TFact> >();
        }
示例#24
0
        public void SetDatabseObjects(Session session, ParserDQL.CompileContext compileContext)
        {
            this.Parameters = compileContext.GetParameters();
            this.SetParameters();
            this.SetParameterMetaData();
            this.Subqueries         = this.GetSubqueries(session);
            this.RangeIteratorCount = compileContext.GetRangeVarCount();
            this.RangeVariables     = compileContext.GetRangeVariables();
            this.Sequences          = compileContext.GetSequences();
            this.Routines           = compileContext.GetRoutines();
            OrderedHashSet <QNameManager.QName> set = new OrderedHashSet <QNameManager.QName>();

            this.CollectTableNamesForWrite(set);
            if (set.Size() > 0)
            {
                base.WriteTableNames = new QNameManager.QName[set.Size()];
                set.ToArray(base.WriteTableNames);
                set.Clear();
            }
            this.CollectTableNamesForRead(set);
            set.RemoveAll(base.WriteTableNames);
            if (set.Size() > 0)
            {
                base.ReadTableNames = new QNameManager.QName[set.Size()];
                set.ToArray(base.ReadTableNames);
            }
            base.References = compileContext.GetSchemaObjectNames();
            if (this.TargetTable != null)
            {
                base.References.Add(this.TargetTable.GetName());
            }
        }
示例#25
0
        private Result GetExplainResult(Session session)
        {
            Result result = Result.NewSingleColumnStringResult("OPERATION", this.Describe(session));
            OrderedHashSet <QNameManager.QName> references = this.GetReferences();

            object[] data = new object[] { "Object References" };
            result.navigator.Add(data);
            for (int i = 0; i < references.Size(); i++)
            {
                QNameManager.QName name      = references.Get(i);
                object[]           objArray2 = new object[] { name.GetSchemaQualifiedStatementName() };
                result.navigator.Add(objArray2);
            }
            object[] objArray3 = new object[] { "Read Locks" };
            result.navigator.Add(objArray3);
            for (int j = 0; j < base.ReadTableNames.Length; j++)
            {
                QNameManager.QName name2     = base.ReadTableNames[j];
                object[]           objArray4 = new object[] { name2.GetSchemaQualifiedStatementName() };
                result.navigator.Add(objArray4);
            }
            object[] objArray5 = new object[] { "WriteLocks" };
            result.navigator.Add(objArray5);
            for (int k = 0; k < base.WriteTableNames.Length; k++)
            {
                QNameManager.QName name3     = base.WriteTableNames[k];
                object[]           objArray6 = new object[] { name3.GetSchemaQualifiedStatementName() };
                result.navigator.Add(objArray6);
            }
            return(result);
        }
示例#26
0
        public OrderedHashSet <Grantee> GetAllRoles()
        {
            OrderedHashSet <Grantee> granteeAndAllRoles = this.GetGranteeAndAllRoles();

            granteeAndAllRoles.Remove(this);
            return(granteeAndAllRoles);
        }
示例#27
0
        public override SubQuery[] GetSubqueries(Session session)
        {
            OrderedHashSet <SubQuery> set = null;

            if (this._expression != null)
            {
                set = this._expression.CollectAllSubqueries(set);
            }
            for (int i = 0; i < this._arguments.Length; i++)
            {
                set = this._arguments[i].CollectAllSubqueries(set);
            }
            if ((set == null) || (set.Size() == 0))
            {
                return(SubQuery.EmptySubqueryArray);
            }
            SubQuery[] a = new SubQuery[set.Size()];
            set.ToArray(a);
            ArraySort.Sort <SubQuery>(a, 0, a.Length, a[0]);
            for (int j = 0; j < base.Subqueries.Length; j++)
            {
                a[j].PrepareTable(session);
            }
            return(a);
        }
示例#28
0
        public OrderedHashSet <Grantee> GetGranteeAndAllRoles()
        {
            OrderedHashSet <Grantee> set = new OrderedHashSet <Grantee>();

            this.AddGranteeAndRoles(set);
            return(set);
        }
        /** enclosingRule calls targetRule. Find the cycle containing
         *  the target and add the caller.  Find the cycle containing the caller
         *  and add the target.  If no cycles contain either, then create a new
         *  cycle.
         */
        protected virtual void AddRulesToCycle(Rule enclosingRule, Rule targetRule)
        {
            //System.err.println("left-recursion to "+targetRule.name+" from "+enclosingRule.name);
            bool foundCycle = false;

            foreach (ISet <Rule> rulesInCycle in listOfRecursiveCycles)
            {
                // ensure both rules are in same cycle
                if (rulesInCycle.Contains(targetRule))
                {
                    rulesInCycle.Add(enclosingRule);
                    foundCycle = true;
                }
                if (rulesInCycle.Contains(enclosingRule))
                {
                    rulesInCycle.Add(targetRule);
                    foundCycle = true;
                }
            }
            if (!foundCycle)
            {
                ISet <Rule> cycle = new OrderedHashSet <Rule>();
                cycle.Add(targetRule);
                cycle.Add(enclosingRule);
                listOfRecursiveCycles.Add(cycle);
            }
        }
示例#30
0
文件: DFAState.cs 项目: zapov/antlrcs
 public virtual void Reset()
 {
     //nfaConfigurations = null; // getGatedPredicatesInNFAConfigurations needs
     _configurationsWithLabeledEdges = null;
     _closureBusy     = null;
     _reachableLabels = null;
 }
示例#31
0
        public OrderedHashSet <QNameManager.QName> GetReferences()
        {
            OrderedHashSet <QNameManager.QName> set1 = new OrderedHashSet <QNameManager.QName>();

            set1.Add(this.BaseName);
            return(set1);
        }
		public HomeViewModel(MainWindow main, ConfigurationViewModel configuration) {
			Main = main;
			Configuration = configuration;

			OrderPred = (entry, item) => {
				return entry.CreatedAt.CompareTo(item.CreatedAt) >= 0;
			};

			Timeline = new OrderedHashSet<Status>(OrderPred);
			Mentions = new OrderedHashSet<Status>(OrderPred);
			Favorites = new OrderedHashSet<Status>(OrderPred);
			DM = new OrderedHashSet<Status>(OrderPred);
		}
示例#33
0
        public void ListHashSetTest()
        {
            OrderedHashSet<string> set = new OrderedHashSet<string>();

            Assert.AreEqual(set.Count(), 0);
            CollectionAssert.AreEqual(new string[] { }, set.ToArray());
            Assert.IsFalse(set.Contains("a"));
            Assert.IsFalse(set.Contains("b"));

            set.Add("b");
            Assert.AreEqual(set.Count(), 1);
            Assert.IsFalse(set.Contains("a"));
            Assert.IsTrue(set.Contains("b"));
            CollectionAssert.AreEqual(new string[] { "b" }, set.ToArray());

            set.Add("a");
            Assert.AreEqual(set.Count(), 2);
            Assert.IsTrue(set.Contains("a"));
            Assert.IsTrue(set.Contains("b"));
            CollectionAssert.AreEqual(new string[] { "b", "a" }, set.ToArray());

            set.Add("b");
            Assert.AreEqual(set.Count(), 2);
            Assert.IsTrue(set.Contains("a"));
            Assert.IsTrue(set.Contains("b"));
            CollectionAssert.AreEqual(new string[] { "b", "a" }, set.ToArray());

            Assert.AreEqual(set[0], "b");
            Assert.AreEqual(set[1], "a");

            set.Remove("b");

            CollectionAssert.AreEqual(new string[] { "a" }, set.ToArray());
            Assert.IsTrue(set.Contains("a"));
            Assert.IsFalse(set.Contains("b"));

            set.Clear();

            CollectionAssert.AreEqual(new string[] {}, set.ToArray());
            Assert.IsFalse(set.Contains("a"));
            Assert.IsFalse(set.Contains("b"));
        }
示例#34
0
 /** enclosingRule calls targetRule. Find the cycle containing
  *  the target and add the caller.  Find the cycle containing the caller
  *  and add the target.  If no cycles contain either, then create a new
  *  cycle.
  */
 protected virtual void AddRulesToCycle(Rule enclosingRule, Rule targetRule)
 {
     //System.err.println("left-recursion to "+targetRule.name+" from "+enclosingRule.name);
     bool foundCycle = false;
     foreach (ISet<Rule> rulesInCycle in listOfRecursiveCycles)
     {
         // ensure both rules are in same cycle
         if (rulesInCycle.Contains(targetRule))
         {
             rulesInCycle.Add(enclosingRule);
             foundCycle = true;
         }
         if (rulesInCycle.Contains(enclosingRule))
         {
             rulesInCycle.Add(targetRule);
             foundCycle = true;
         }
     }
     if (!foundCycle)
     {
         ISet<Rule> cycle = new OrderedHashSet<Rule>();
         cycle.Add(targetRule);
         cycle.Add(enclosingRule);
         listOfRecursiveCycles.Add(cycle);
     }
 }
示例#35
0
 public virtual void Reset()
 {
     //nfaConfigurations = null; // getGatedPredicatesInNFAConfigurations needs
     configurationsWithLabeledEdges = null;
     closureBusy = null;
     _reachableLabels = null;
 }
示例#36
0
 /** EOT (end of token) is a label that indicates when the DFA conversion
  *  algorithm would "fall off the end of a lexer rule".  It normally
  *  means the default clause.  So for ('a'..'z')+ you would see a DFA
  *  with a state that has a..z and EOT emanating from it.  a..z would
  *  jump to a state predicting alt 1 and EOT would jump to a state
  *  predicting alt 2 (the exit loop branch).  EOT implies anything other
  *  than a..z.  If for some reason, the set is "all char" such as with
  *  the wildcard '.', then EOT cannot match anything.  For example,
  *
  *     BLOCK : '{' (.)* '}'
  *
  *  consumes all char until EOF when greedy=true.  When all edges are
  *  combined for the DFA state after matching '}', you will find that
  *  it is all char.  The EOT transition has nothing to match and is
  *  unreachable.  The findNewDFAStatesAndAddDFATransitions() method
  *  must know to ignore the EOT, so we simply remove it from the
  *  reachable labels.  Later analysis will find that the exit branch
  *  is not predicted by anything.  For greedy=false, we leave only
  *  the EOT label indicating that the DFA should stop immediately
  *  and predict the exit branch. The reachable labels are often a
  *  set of disjoint values like: [<EOT>, 42, {0..41, 43..65534}]
  *  due to DFA conversion so must construct a pure set to see if
  *  it is same as Label.ALLCHAR.
  *
  *  Only do this for Lexers.
  *
  *  If EOT coexists with ALLCHAR:
  *  1. If not greedy, modify the labels parameter to be EOT
  *  2. If greedy, remove EOT from the labels set
  */
 protected boolean ReachableLabelsEOTCoexistsWithAllChar(OrderedHashSet labels)
 {
     Label eot = new Label(Label.EOT);
     if ( !labels.containsKey(eot) ) {
         return false;
     }
     [email protected]("### contains EOT");
     bool containsAllChar = false;
     IntervalSet completeVocab = new IntervalSet();
     int n = labels.size();
     for (int i=0; i<n; i++) {
         Label rl = (Label)labels.get(i);
         if ( !rl.Equals(eot) ) {
             completeVocab.addAll(rl.Set());
         }
     }
     [email protected]("completeVocab="+completeVocab);
     if ( completeVocab.Equals(Label.ALLCHAR) ) {
         [email protected]("all char");
         containsAllChar = true;
     }
     return containsAllChar;
 }
示例#37
0
 public virtual void SetNFAConfigurations( OrderedHashSet<NFAConfiguration> configs )
 {
     this.nfaConfigurations = configs;
 }
示例#38
0
        /** Add label uniquely and disjointly; intersection with
         *  another set or int/char forces breaking up the set(s).
         *
         *  Example, if reachable list of labels is [a..z, {k,9}, 0..9],
         *  the disjoint list will be [{a..j,l..z}, k, 9, 0..8].
         *
         *  As we add NFA configurations to a DFA state, we might as well track
         *  the set of all possible transition labels to make the DFA conversion
         *  more efficient.  W/o the reachable labels, we'd need to check the
         *  whole vocabulary space (could be 0..\uFFFF)!  The problem is that
         *  labels can be sets, which may overlap with int labels or other sets.
         *  As we need a deterministic set of transitions from any
         *  state in the DFA, we must make the reachable labels set disjoint.
         *  This operation amounts to finding the character classes for this
         *  DFA state whereas with tools like flex, that need to generate a
         *  homogeneous DFA, must compute char classes across all states.
         *  We are going to generate DFAs with heterogeneous states so we
         *  only care that the set of transitions out of a single state are
         *  unique. :)
         *
         *  The idea for adding a new set, t, is to look for overlap with the
         *  elements of existing list s.  Upon overlap, replace
         *  existing set s[i] with two new disjoint sets, s[i]-t and s[i]&t.
         *  (if s[i]-t is nil, don't add).  The remainder is t-s[i], which is
         *  what you want to add to the set minus what was already there.  The
         *  remainder must then be compared against the i+1..n elements in s
         *  looking for another collision.  Each collision results in a smaller
         *  and smaller remainder.  Stop when you run out of s elements or
         *  remainder goes to nil.  If remainder is non nil when you run out of
         *  s elements, then add remainder to the end.
         *
         *  Single element labels are treated as sets to make the code uniform.
         */
        protected virtual void AddReachableLabel( Label label )
        {
            if ( _reachableLabels == null )
            {
                _reachableLabels = new OrderedHashSet<Label>();
            }
            /*
            [email protected]("addReachableLabel to state "+dfa.decisionNumber+"."+stateNumber+": "+label.getSet().toString(dfa.nfa.grammar));
            [email protected]("start of add to state "+dfa.decisionNumber+"."+stateNumber+": " +
                    "reachableLabels="+reachableLabels.toString());
                    */
            if ( _reachableLabels.Contains( label ) )
            {
                // exact label present
                return;
            }
            IIntSet t = label.Set;
            IIntSet remainder = t; // remainder starts out as whole set to add
            int n = _reachableLabels.Size(); // only look at initial elements
            // walk the existing list looking for the collision
            for ( int i = 0; i < n; i++ )
            {
                Label rl = _reachableLabels.Get( i );
                /*
                [email protected]("comparing ["+i+"]: "+label.toString(dfa.nfa.grammar)+" & "+
                        rl.toString(dfa.nfa.grammar)+"="+
                        intersection.toString(dfa.nfa.grammar));
                */
                if ( !Label.Intersect( label, rl ) )
                {
                    continue;
                }
                //[email protected](label+" collides with "+rl);

                // For any (s_i, t) with s_i&t!=nil replace with (s_i-t, s_i&t)
                // (ignoring s_i-t if nil; don't put in list)

                // Replace existing s_i with intersection since we
                // know that will always be a non nil character class
                IIntSet s_i = rl.Set;
                IIntSet intersection = s_i.And( t );
                _reachableLabels.Set( i, new Label( intersection ) );

                // Compute s_i-t to see what is in current set and not in incoming
                IIntSet existingMinusNewElements = s_i.Subtract( t );
                //[email protected](s_i+"-"+t+"="+existingMinusNewElements);
                if ( !existingMinusNewElements.IsNil )
                {
                    // found a new character class, add to the end (doesn't affect
                    // outer loop duration due to n computation a priori.
                    Label newLabel = new Label( existingMinusNewElements );
                    _reachableLabels.Add( newLabel );
                }

                /*
                [email protected]("after collision, " +
                        "reachableLabels="+reachableLabels.toString());
                        */

                // anything left to add to the reachableLabels?
                remainder = t.Subtract( s_i );
                if ( remainder.IsNil )
                {
                    break; // nothing left to add to set.  done!
                }

                t = remainder;
            }
            if ( !remainder.IsNil )
            {
                /*
                [email protected]("before add remainder to state "+dfa.decisionNumber+"."+stateNumber+": " +
                        "reachableLabels="+reachableLabels.toString());
                [email protected]("remainder state "+dfa.decisionNumber+"."+stateNumber+": "+remainder.toString(dfa.nfa.grammar));
                */
                Label newLabel = new Label( remainder );
                _reachableLabels.Add( newLabel );
            }
            /*
            [email protected]("#END of add to state "+dfa.decisionNumber+"."+stateNumber+": " +
                    "reachableLabels="+reachableLabels.toString());
                    */
        }
		private void InsertTabItem(Status entry, ObservableCollection<TabItem> to, string tabName) {
			Dispatch.Method(() => {
				if (entry != null && (to == UserTabItems || to == QueryTabItems || to == TrendTabItems || to == BuzztterTabItems)) {
					var all = to[0].DataContext as OrderedHashSet<Status>;
					all.Insert(entry);
				}

				TabItem found = null;
				foreach (TabItem tabItem in to) {
					if (tabItem.Header.ToString() == tabName) {
						found = tabItem;
						break;
					}
				}

				OrderedHashSet<Status> statuses;
				if (found == null) {
					statuses = new OrderedHashSet<Status>(OrderPred);
					to.Add(new TabItem {
						Header = tabName,
						Content = new TwitterDataGrid(),
						DataContext = statuses,
					});
				} else {
					statuses = found.DataContext as OrderedHashSet<Status>;
				}
				if (entry != null && statuses != null) {
					statuses.Insert(entry);
				}
			});
		}
示例#40
0
        protected virtual IList<IIntSet> MakeEdgeSetsDisjoint( IList<IIntSet> edges )
        {
            OrderedHashSet<IIntSet> disjointSets = new OrderedHashSet<IIntSet>();
            // walk each incoming edge label/set and add to disjoint set
            int numEdges = edges.Count;
            for ( int e = 0; e < numEdges; e++ )
            {
                IntervalSet t = (IntervalSet)edges[e];
                if ( disjointSets.Contains( t ) )
                { // exact set present
                    continue;
                }

                // compare t with set i for disjointness
                IntervalSet remainder = t; // remainder starts out as whole set to add
                int numDisjointElements = disjointSets.Count;
                for ( int i = 0; i < numDisjointElements; i++ )
                {
                    IntervalSet s_i = (IntervalSet)disjointSets[i];

                    if ( t.And( s_i ).IsNil )
                    { // nothing in common
                        continue;
                    }
                    //[email protected](label+" collides with "+rl);

                    // For any (s_i, t) with s_i&t!=nil replace with (s_i-t, s_i&t)
                    // (ignoring s_i-t if nil; don't put in list)

                    // Replace existing s_i with intersection since we
                    // know that will always be a non nil character class
                    IntervalSet intersection = (IntervalSet)s_i.And( t );
                    disjointSets[i] = intersection;

                    // Compute s_i-t to see what is in current set and not in incoming
                    IIntSet existingMinusNewElements = s_i.Subtract( t );
                    //[email protected](s_i+"-"+t+"="+existingMinusNewElements);
                    if ( existingMinusNewElements != null && !existingMinusNewElements.IsNil )
                    {
                        // found a new character class, add to the end (doesn't affect
                        // outer loop duration due to n computation a priori.
                        disjointSets.Add( existingMinusNewElements );
                    }

                    // anything left to add to the reachableLabels?
                    remainder = (IntervalSet)t.Subtract( s_i );
                    if ( remainder.IsNil )
                    {
                        break; // nothing left to add to set.  done!
                    }

                    t = remainder;
                }
                if ( !remainder.IsNil )
                {
                    disjointSets.Add( remainder );
                }
            }
            return disjointSets.GetElements();
        }