Пример #1
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);
            }
        }
Пример #2
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);
        }
Пример #3
0
 public override void CollectTableNamesForRead(OrderedHashSet <QNameManager.QName> set)
 {
     if (base.BaseTable.IsView())
     {
         this.GetTriggerTableNames(set, false);
     }
     else if (!base.BaseTable.IsTemp())
     {
         for (int m = 0; m < base.BaseTable.FkConstraints.Length; m++)
         {
             Constraint constraint = base.BaseTable.FkConstraints[m];
             if ((base.type == 0x52) || (base.type == 0x80))
             {
                 if (ArrayUtil.HaveCommonElement(constraint.GetRefColumns(), base.UpdateColumnMap))
                 {
                     set.Add(base.BaseTable.FkConstraints[m].GetMain().GetName());
                 }
             }
             else if (base.type == 50)
             {
                 set.Add(base.BaseTable.FkConstraints[m].GetMain().GetName());
             }
         }
         if ((base.type == 0x52) || (base.type == 0x80))
         {
             base.BaseTable.CollectFkReadLocks(base.UpdateColumnMap, set);
         }
         else if (base.type == 0x13)
         {
             base.BaseTable.CollectFkReadLocks(null, set);
         }
         this.GetTriggerTableNames(set, false);
     }
     for (int i = 0; i < base.RangeVariables.Length; i++)
     {
         Table rangeTable       = base.RangeVariables[i].RangeTable;
         QNameManager.QName key = rangeTable.GetName();
         if ((!rangeTable.IsReadOnly() && !rangeTable.IsTemp()) && (key.schema != SqlInvariants.SystemSchemaQname))
         {
             set.Add(key);
         }
     }
     for (int j = 0; j < base.Subqueries.Length; j++)
     {
         if (base.Subqueries[j].queryExpression != null)
         {
             base.Subqueries[j].queryExpression.GetBaseTableNames(set);
         }
     }
     for (int k = 0; k < base.Routines.Length; k++)
     {
         set.AddAll(base.Routines[k].GetTableNamesForRead());
     }
 }
Пример #4
0
        public InvokeRule(ParserFactory factory, GrammarAST ast, GrammarAST labelAST)
            : base(factory, ast)
        {
            if (ast.atnState != null)
            {
                RuleTransition ruleTrans = (RuleTransition)ast.atnState.Transition(0);
                stateNumber = ast.atnState.stateNumber;
            }

            this.name = ast.Text;
            Rule r = factory.GetGrammar().GetRule(name);

            ctxName = factory.GetTarget().GetRuleFunctionContextStructName(r);

            // TODO: move to factory
            RuleFunction rf = factory.GetCurrentRuleFunction();

            if (labelAST != null)
            {
                // for x=r, define <rule-context-type> x and list_x
                string label = labelAST.Text;
                if (labelAST.Parent.Type == ANTLRParser.PLUS_ASSIGN)
                {
                    factory.DefineImplicitLabel(ast, this);
                    string listLabel      = factory.GetTarget().GetListLabel(label);
                    RuleContextListDecl l = new RuleContextListDecl(factory, listLabel, ctxName);
                    rf.AddContextDecl(ast.GetAltLabel(), l);
                }
                else
                {
                    RuleContextDecl d = new RuleContextDecl(factory, label, ctxName);
                    labels.Add(d);
                    rf.AddContextDecl(ast.GetAltLabel(), d);
                }
            }

            ActionAST arg = (ActionAST)ast.GetFirstChildWithType(ANTLRParser.ARG_ACTION);

            if (arg != null)
            {
                argExprsChunks = ActionTranslator.TranslateAction(factory, rf, arg.Token, arg);
            }

            // If action refs rule as rulename not label, we need to define implicit label
            if (factory.GetCurrentOuterMostAlt().ruleRefsInActions.ContainsKey(ast.Text))
            {
                string          label = factory.GetTarget().GetImplicitRuleLabel(ast.Text);
                RuleContextDecl d     = new RuleContextDecl(factory, label, ctxName);
                labels.Add(d);
                rf.AddContextDecl(ast.GetAltLabel(), d);
            }
        }
 static UnityEventFunctionComparer()
 {
     ourSpecialNames.Add("Awake");
     ourSpecialNames.Add("Reset");
     ourSpecialNames.Add("Start");
     ourSpecialNames.Add("Update");
     ourSpecialNames.Add("FixedUpdate");
     ourSpecialNames.Add("LateUpdate");
     ourSpecialNames.Add("OnEnable");
     ourSpecialNames.Add("OnDisable");
     ourSpecialNames.Add("OnDestroy");
     ourSpecialNames.Add("OnGUI");
 }
Пример #6
0
        public void OrderedHashSet_Test()
        {
            var hashSet = new OrderedHashSet <int>();

            int nodeCount = 1000;

            //insert test
            for (int i = 0; i <= nodeCount; i++)
            {
                hashSet.Add(i);
                Assert.AreEqual(true, hashSet.Contains(i));
            }

            //IEnumerable test using linq
            Assert.AreEqual(hashSet.Count, hashSet.Count());
            Assert.AreEqual(hashSet.Count, hashSet.AsEnumerableDesc().Count());

            for (int i = 0; i <= nodeCount; i++)
            {
                hashSet.Remove(i);
                Assert.AreEqual(false, hashSet.Contains(i));
            }

            //IEnumerable test using linq
            Assert.AreEqual(hashSet.Count, hashSet.Count());
            Assert.AreEqual(hashSet.Count, hashSet.AsEnumerableDesc().Count());

            var rnd        = new Random();
            var testSeries = Enumerable.Range(1, nodeCount).OrderBy(x => rnd.Next()).ToList();

            foreach (var item in testSeries)
            {
                hashSet.Add(item);
                Assert.AreEqual(true, hashSet.Contains(item));
            }

            //IEnumerable test using linq
            Assert.AreEqual(hashSet.Count, hashSet.Count());
            Assert.AreEqual(hashSet.Count, hashSet.AsEnumerableDesc().Count());

            for (int i = 1; i <= nodeCount; i++)
            {
                hashSet.Remove(i);
                Assert.AreEqual(false, hashSet.Contains(i));
            }

            //IEnumerable test using linq
            Assert.AreEqual(hashSet.Count, hashSet.Count());
            Assert.AreEqual(hashSet.Count, hashSet.AsEnumerableDesc().Count());
        }
Пример #7
0
        /// <summary>
        /// Get all grammar symbols, including terminals and variables.
        /// </summary>
        /// <returns>Grammar symbols</returns>
        public OrderedHashSet <string> Symbols()
        {
            OrderedHashSet <string> symbols = new OrderedHashSet <string>();

            foreach (Production production in productions)
            {
                symbols.Add(production.lhs);
                foreach (string rhsItem in production.rhs)
                {
                    symbols.Add(rhsItem);
                }
            }
            return(symbols);
        }
        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);
            }
        }
Пример #9
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>());
        }
Пример #10
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}");
            }
        }
Пример #11
0
        public void Contains_ReturnsTrue()
        {
            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);


            Assert.IsTrue(ohs.Contains(s_1));
        }
Пример #12
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());
        }
Пример #13
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()));
        }
Пример #14
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);
                }
            }
        }
Пример #15
0
        private static void ProcessAlterView(Session session, SchemaManager schemaManager, View view)
        {
            CheckSchemaUpdateAuthorisation(session, view.GetSchemaName());
            View schemaObject = (View)schemaManager.GetSchemaObject(view.GetName());

            if (schemaObject == null)
            {
                throw Error.GetError(0x157d, view.GetName().Name);
            }
            view.SetName(schemaObject.GetName());
            view.Compile(session, null);
            if (schemaManager.GetReferencingObjectNames(schemaObject.GetName()).GetCommonElementCount(view.GetReferences()) > 0)
            {
                throw Error.GetError(0x157e);
            }
            int tableIndex = schemaManager.GetTableIndex(schemaObject);

            schemaManager.SetTable(tableIndex, view);
            OrderedHashSet <Table> tableSet = new OrderedHashSet <Table>();

            tableSet.Add(view);
            try
            {
                schemaManager.RecompileDependentObjects(tableSet);
            }
            catch (CoreException)
            {
                schemaManager.SetTable(tableIndex, schemaObject);
                schemaManager.RecompileDependentObjects(tableSet);
            }
        }
Пример #16
0
        public OrderedHashSet <QNameManager.QName> GetReferences()
        {
            OrderedHashSet <QNameManager.QName> set1 = new OrderedHashSet <QNameManager.QName>();

            set1.Add(this.BaseName);
            return(set1);
        }
Пример #17
0
 internal static void InitializeAreas(Func <DisplayBase> GetCurrentDisplay, IEnumerable <Func <LocationBase> > locations)
 {
     foreach (var item in locations)
     {
         TriggeredEncounter trigger = new LocationUnlockEncounter(GetCurrentDisplay, item);
         areaUnlocks.Add(trigger);
     }
 }
Пример #18
0
 public Both Add(int item)
 {
     if (!List.Contains(item))
     {
         List.AddLast(item);
     }
     Set.Add(item); Validate(); return(this);
 }
Пример #19
0
        public OrderedHashSet <Grantee> GetGranteeAndAllRolesWithPublic()
        {
            OrderedHashSet <Grantee> set = new OrderedHashSet <Grantee>();

            this.AddGranteeAndRoles(set);
            set.Add(this.granteeManager.PublicRole);
            return(set);
        }
Пример #20
0
 public void TestAddOrderedHashSet()
 {
     m_warmOrderedSet.Clear();
     for (int i = 0; i < IterCount; i++)
     {
         m_warmOrderedSet.Add(i);
     }
 }
Пример #21
0
        internal static void DeduplicateFiles()
        {
            foreach (var f in UsedFiles)
            {
                var n       = f.FileName;
                var removed = 0;
                var scanned = new OrderedHashSet <string>();
                var first   = true;
                using (var reader = new StreamReader(n))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (first)
                        {
                            first = false;
                            if (!line.Equals(CsvContainer.GetFileTypeHeader(f.FileType)))
                            {
                                scanned.Add(CsvContainer.GetFileTypeHeader(f.FileType));
                            }
                        }
                        try
                        {
                            scanned.Add(line);
                        }
                        catch
                        {
                            removed++;
                        }
                    }
                }

                using (var writer = new StreamWriter(f.FileName, false))
                {
                    foreach (var line in scanned)
                    {
                        writer.WriteLine(line);
                    }
                }
                if (removed > 0)
                {
                    Console.WriteLine($"Removed {removed} duplicate lines from {f.FileName}");
                }
            }
        }
Пример #22
0
 /** Add local var decl */
 public virtual void AddLocalDecl(Decl.Decl d)
 {
     if (locals == null)
     {
         locals = new OrderedHashSet <Decl.Decl>();
     }
     locals.Add(d);
     d.isLocal = true;
 }
Пример #23
0
 public bool CheckAdd(string fullNameWithExtension)
 {
     if (ToCheck.Contains(fullNameWithExtension))
     {
         return(false);
     }
     ToCheck.Add(fullNameWithExtension);
     return(true);
 }
Пример #24
0
        void IAlphaMemory <TFact> .Add(TFact fact)
        {
            var added = _facts.Add(fact);

            if (added)
            {
                _log.LogDebug("Fact Added: {0}", fact);
            }
        }
Пример #25
0
        /// <returns>Grammar variables</returns>
        public OrderedHashSet <string> Variables()
        {
            OrderedHashSet <string> variables = new OrderedHashSet <string>();

            foreach (Production production in productions)
            {
                variables.Add(production.lhs);
            }
            return(variables);
        }
Пример #26
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"));
        }
Пример #27
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"));
        }
Пример #28
0
        public override void Compile(Session session, ISchemaObject parentObject)
        {
            using (Scanner scanner = new Scanner(this.statement))
            {
                ParserDQL rdql = new ParserDQL(session, scanner);
                rdql.Read();
                this.ViewSubQuery    = rdql.XreadViewSubquery(this);
                base.queryExpression = this.ViewSubQuery.queryExpression;
                if (base.GetColumnCount() == 0)
                {
                    if (this.ColumnNames == null)
                    {
                        this.ColumnNames = this.ViewSubQuery.queryExpression.GetResultColumnNames();
                    }
                    if (this.ColumnNames.Length != this.ViewSubQuery.queryExpression.GetColumnCount())
                    {
                        throw Error.GetError(0x15d9, this.GetName().StatementName);
                    }
                    TableUtil.SetColumnsInSchemaTable(this, this.ColumnNames, base.queryExpression.GetColumnTypes(), base.queryExpression.GetColumnNullability());
                }
                OrderedHashSet <SubQuery> set = OrderedHashSet <SubQuery> .AddAll(OrderedHashSet <SubQuery> .Add(base.queryExpression.GetSubqueries(), this.ViewSubQuery), this.ViewSubQuery.GetExtraSubqueries());

                this.ViewSubqueries = new SubQuery[set.Size()];
                set.ToArray(this.ViewSubqueries);
                ArraySort.Sort <SubQuery>(this.ViewSubqueries, 0, this.ViewSubqueries.Length, this.ViewSubqueries[0]);
                foreach (SubQuery query in this.ViewSubqueries)
                {
                    if (query.ParentView == null)
                    {
                        query.ParentView = this;
                    }
                    query.PrepareTable(session);
                }
                this.ViewSubQuery.GetTable().view       = this;
                this.ViewSubQuery.GetTable().ColumnList = base.ColumnList;
                this._schemaObjectNames = rdql.compileContext.GetSchemaObjectNames();
                this._baseTable         = base.queryExpression.GetBaseTable();
            }
            if (this._baseTable != null)
            {
                switch (this._check)
                {
                case 0:
                case 2:
                    return;

                case 1:
                    base.queryExpression.GetCheckCondition();
                    return;
                }
                throw Error.RuntimeError(0xc9, "View");
            }
        }
Пример #29
0
 private void AddGranteeAndRoles(OrderedHashSet <Grantee> set)
 {
     set.Add(this);
     for (int i = 0; i < this.Roles.Size(); i++)
     {
         Grantee key = this.Roles.Get(i);
         if (!set.Contains(key))
         {
             key.AddGranteeAndRoles(set);
         }
     }
 }
Пример #30
0
        public override void Resolve(Session session, RangeVariable[] rangeVars)
        {
            base.References = new OrderedHashSet <QNameManager.QName>();
            switch (this._operationType)
            {
            case 1:
                for (int i = 0; i < base.UpdateExpressions.Length; i++)
                {
                    base.UpdateExpressions[i].CollectObjectNames(base.References);
                }
                return;

            case 2:
            case 3:
                if (this._expression != null)
                {
                    this._expression.CollectObjectNames(base.References);
                }
                if (base.queryExpression != null)
                {
                    base.queryExpression.CollectObjectNames(base.References);
                }
                return;

            case 4:
            {
                OrderedHashSet <string> colNames = new OrderedHashSet <string>();
                string name = this._expression.GetColumn().ColumnName.Name;
                colNames.Add(name);
                int[]          indexes   = new int[colNames.Size()];
                ColumnSchema[] variables = new ColumnSchema[colNames.Size()];
                SetVariables(rangeVars, colNames, indexes, variables);
                this.cursorVariableNameIndex = indexes[0];
                if (this.cursorVariableNameIndex < 0)
                {
                    throw Error.GetError(0xe10);
                }
                if (variables[0] == null)
                {
                    throw Error.GetError(0xe10);
                }
                Cursor defaultValue = this._expression.GetColumn().GetDefaultValue(session) as Cursor;
                if (defaultValue == null)
                {
                    throw Error.GetError(0xe10);
                }
                defaultValue.CollectObjectNames(base.References);
                return;
            }
            }
            throw Error.RuntimeError(0xc9, "StatementSet");
        }
Пример #31
0
        public void Keeps_First()
        {
            var list  = new OrderedHashSet <MyClass>(keepOldest: true);
            var items = new MyClass[] { new MyClass("test"), new MyClass("test"), new MyClass("test") };

            foreach (var item in items)
            {
                list.Add(item);
            }

            Assert.AreEqual(1, list.Count);
            Assert.AreEqual(items[0].Id, list[0].Id);
        }
Пример #32
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();
        }
Пример #33
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);
     }
 }