Esempio n. 1
0
 public LinqHashSet(IEnumerable <T> e) : this()
 {
     foreach (var x in e)
     {
         Inner.Add(x, "");
     }
 }
Esempio n. 2
0
        protected void SelectClicked(
            Func <List <MediaCardViewModel> > getSortedItems,
            MediaCardViewModel card,
            MouseEventArgs e)
        {
            if (_selectedItems.Contains(card))
            {
                _selectedItems.Remove(card);
            }
            else
            {
                if (e.ShiftKey && _recentlySelected.IsSome)
                {
                    List <MediaCardViewModel> sorted = getSortedItems();

                    int start  = sorted.IndexOf(_recentlySelected.ValueUnsafe());
                    int finish = sorted.IndexOf(card);
                    if (start > finish)
                    {
                        int temp = start;
                        start  = finish;
                        finish = temp;
                    }

                    for (int i = start; i < finish; i++)
                    {
                        _selectedItems.Add(sorted[i]);
                    }
                }

                _recentlySelected = card;
                _selectedItems.Add(card);
            }
        }
Esempio n. 3
0
        private void Start()
        {
            if (HeadCamera != null && TopCamera != null)
            {
                HeadCamera.enabled = true;
                TopCamera.enabled  = false;
            }

            knownActions.Add("Strafe");
            knownActions.Add("Vertical");
            knownActions.Add("Horizontal");
            knownActions.Add("Action");
            knownActions.Add("");

            RotateTo(m_CurrentDirection, false);

            MapGenerator.getInstance().Initialize();

            new Thread(o =>
            {
                var player = new Player();
                player.Start();
                while (true)
                {
                    player.Tick();
                    Thread.Sleep(1);
                }
            }).Start();
        }
Esempio n. 4
0
        public void ISet_Generic_SymmetricExceptWith_AfterRemovingElements(EnumerableType enumerableType, int setLength, int enumerableLength, int numberOfMatchingElements, int numberOfDuplicateElements)
        {
            ISet <T> set   = GenericISetFactory(setLength);
            T        value = CreateT(532);

            if (!set.Contains(value))
            {
                set.Add(value);
            }
            set.Remove(value);
            IEnumerable <T> enumerable = CreateEnumerable(enumerableType, set, enumerableLength, numberOfMatchingElements, numberOfDuplicateElements);

            Debug.Assert(enumerable != null);

            IEqualityComparer <T> comparer = GetIEqualityComparer();

            System.Collections.Generic.HashSet <T> expected = new System.Collections.Generic.HashSet <T>(comparer);
            foreach (T element in enumerable)
            {
                if (!set.Contains(element, comparer))
                {
                    expected.Add(element);
                }
            }
            foreach (T element in set)
            {
                if (!enumerable.Contains(element, comparer))
                {
                    expected.Add(element);
                }
            }
            set.SymmetricExceptWith(enumerable);
            Assert.Equal(expected.Count, set.Count);
            Assert.True(expected.SetEquals(set));
        }
        public void TryAddLibrary(string AssetPath)
        {
            Active = true;
            if (AssetPath.Contains(".a"))
            {
                //Extract the lib name, generate the registration code.
                var begin   = AssetPath.LastIndexOf('/') + 4;
                var end     = AssetPath.LastIndexOf('.') - begin;
                var LibName = AssetPath.Substring(begin, end);                 //Remove the lib prefix and the .a extension

                if (!LibName.Contains("AkSoundEngine"))
                {
                    string headerFilename = LibName + "Factory.h";

                    string fullPath = System.IO.Path.Combine(UnityEngine.Application.dataPath, WwisePluginFolder + GetWwisePluginRelativeDSPFolder() + headerFilename);

                    if (System.IO.File.Exists(fullPath))
                    {
                        FactoriesHeaderFilenames.Add(headerFilename);
                    }
                    else
                    {
                        UnityEngine.Debug.LogErrorFormat("WwiseUnity: Could not find '{0}', required for building plugin.", WwisePluginFolder + GetWwisePluginRelativeDSPFolder() + headerFilename);
                    }
                }
            }
            else if (AssetPath.Contains("Factory.h"))
            {
                FactoriesHeaderFilenames.Add(System.IO.Path.GetFileName(AssetPath));
            }
        }
Esempio n. 6
0
 public void add_bad_mapping(string p_key)
 {
     if (!FoundPaths.Contains(p_key))
     {
         FoundPaths.Add(p_key);
         BadMappingLog.WriteLine(p_key);
     }
 }
Esempio n. 7
0
 public HashSet<string> HashSet()
 {
     HashSet<string> set = new System.Collections.Generic.HashSet<string>();
     set.Add("wenbin1");
     set.Add("wenbin2");
     set.Add("wenbin3");
     set.Add("wenbin4");
     return set;
 }
Esempio n. 8
0
 private void Cleaning(SplitTree ST, SplitTree tPrime)
 {
     //different from original algorithm 7, since the structure of T' is marked with visited flags, here we don't reset the flags
     //scan T' twice
     System.Collections.Generic.HashSet<MarkerVertex> A = new System.Collections.Generic.HashSet<MarkerVertex>();
     System.Collections.Generic.HashSet<MarkerVertex> B = new System.Collections.Generic.HashSet<MarkerVertex>();
     for (int i = 0, n = tPrime.vertices.Count; i < n; ++i)
     {
         if (tPrime.vertices[i] is DegenerateNode)
         {
             var deg = tPrime.vertices[i] as DegenerateNode;
             A.Clear();//Here A is P* and B is V \ P*
             B.Clear();
             deg.ForEachMarkerVertex((v) =>
                 {
                     if (v.perfect && v != deg.center)
                         A.Add(v);
                     else
                         B.Add(v);
                     return IterationFlag.Continue;
                 });
             if (A.Count > 1 && B.Count > 1)
             {
                 var newNode = SplitNode(deg, B, A);
                 if (newNode.parent == deg)
                     newNode.rootMarkerVertex.opposite.MarkAsPerfect();
                 else
                     deg.rootMarkerVertex.MarkAsPerfect();
                 ST.vertices.Add(newNode);//In this way, the structure of T' is unchanged as the newly forked node contains P*(u)
             }
         }
     }
     //again we don't need to reset flags
     for (int i = 0, n = tPrime.vertices.Count; i < n; ++i)
     {
         if (tPrime.vertices[i] is DegenerateNode)
         {
             var deg = tPrime.vertices[i] as DegenerateNode;
             A.Clear();//Here A is V \ E* and B is E
             B.Clear();
             deg.ForEachMarkerVertex((v) =>
                 {
                     if ((v.perfect && v == deg.center) || (!v.perfect && !deg.GetOppositeGLTVertex(v).visited))//if v is not P and is not incident to a tree edge in T', it is E*
                         B.Add(v);
                     else
                         A.Add(v);
                     return IterationFlag.Continue;
                 });
             if (A.Count > 1 & B.Count > 1)
             {
                 ST.vertices.Add(SplitNode(deg, A, B));//let V \ E* be preserved in T'
             }
         }
     }
     //and we're done with cl(ST(G)) and T_c.
 }
Esempio n. 9
0
        //! Start.
        protected void Start()
        {
            // Reset for start node
            g_score[start] = 0;
            // Recalculate estimate distance.
            f_score[start] = g_score[start] + Heurestic(start, end_);

            initialEstimate = f_score[start];

            // Push starting node
            openSet.Add(start);
            openSetPriority.Push(new NodeTag(f_score[start], start));
        }
Esempio n. 10
0
        public static void Write(TextWriter writer, IEnumerable <Dictionary <string, string> > records)
        {
            if (records == null)
            {
                return;                  //AOT
            }
            var allKeys       = new System.Collections.Generic.HashSet <string>();
            var cachedRecords = new List <IDictionary <string, string> >();

            foreach (var record in records)
            {
                foreach (var key in record.Keys)
                {
                    if (!allKeys.Contains(key))
                    {
                        allKeys.Add(key);
                    }
                }
                cachedRecords.Add(record);
            }

            var headers = allKeys.OrderBy(key => key).ToList();

            if (!CsvConfig <Dictionary <string, string> > .OmitHeaders)
            {
                WriteRow(writer, headers);
            }
            foreach (var cachedRecord in cachedRecords)
            {
                var fullRecord = headers.ConvertAll(header =>
                                                    cachedRecord.ContainsKey(header) ? cachedRecord[header] : null);
                WriteRow(writer, fullRecord);
            }
        }
Esempio n. 11
0
        public List <S> Find_path(S start, S end)
        {
            System.Collections.Generic.HashSet <S> closedSet = new System.Collections.Generic.HashSet <S>();
            IntervalHeap <Node> openSet = new IntervalHeap <Node>();
            Node curr = new Node(start, null);

            while (!curr.state.Equals(end))
            {
                if (!closedSet.Contains(curr.state))
                {
                    foreach (S state in curr.state.AvailableMoves())
                    {
                        if (closedSet.Contains(state))
                        {
                            continue;
                        }
                        openSet.Add(new Node(state, curr));
                    }
                    closedSet.Add(curr.state);
                }
                curr = openSet.DeleteMin();
            }

            Stack <S> stack = new Stack <S>();

            while (curr != null)
            {
                stack.Push(curr.state);
                curr = curr.parent;
            }
            return(stack.ToList <S>());
        }
Esempio n. 12
0
        protected override void SaveChanges(Context context, RecordModel record = null)
        {
            base.SaveChanges(context, record);
            if (record == null)
            {
                return;
            }
            var users = new System.Collections.Generic.HashSet <AspNetUsers>();

            foreach (var group in record.ApplicationGroups)
            {
                foreach (var user in group.AspNetUsers)
                {
                    users.Add(user);
                }
            }
            foreach (var user in users)
            {
                if (AspNetUsersHub.SyncUserRoles(user))
                {
                    AddChange("AspNetUsers", "change", user.Id);
                    base.SaveChanges(context, record);
                }
            }
        }
Esempio n. 13
0
 public Stack <Point> Run()
 {
     while (!Open.IsEmpty)
     {
         var node = Open.DeleteMin();
         // node.State.print();
         if (Game.IsFinishState(node.State))
         {
             var stack = new Stack <Point>();
             while (node.Parent != null)
             {
                 stack.Push(node.Move);
                 node = node.Parent;
             }
             return(stack);
         }
         foreach (var move in ProductionSystem)
         {
             var newNode = new Node(node, Game.MakeMove(node.State, move), move);
             if (!Closed.Contains(newNode))
             {
                 Open.Add(newNode);
             }
         }
         Closed.Add(node);
     }
     System.Console.WriteLine("No solution found.");
     return(null);
 }
        public static System.Collections.Generic.HashSet <string> FindDuplicatePrefabs(IEnumerable <GameObject> prefabs)
        {
            var duplicates = new System.Collections.Generic.HashSet <string>();
            var previous   = new System.Collections.Generic.Dictionary <string, GameObject>();

            foreach (GameObject go in prefabs)
            {
                if (go == null || PrefabUtility.GetPrefabType(go) != PrefabType.Prefab)
                {
                    continue;
                }

                string     name = go.name;
                GameObject previousGo;

                if (previous.TryGetValue(name, out previousGo))
                {
                    if (previousGo != go)
                    {
                        duplicates.Add(name);
                    }
                }
                else
                {
                    previous.Add(name, go);
                }
            }

            return(duplicates);
        }
Esempio n. 15
0
		public static void Write(TextWriter writer, IEnumerable<Dictionary<string, string>> records)
		{
			if (records == null) return; //AOT

		    var allKeys = new System.Collections.Generic.HashSet<string>();
		    var cachedRecords = new List<IDictionary<string, string>>();

			foreach (var record in records) {
                foreach (var key in record.Keys) {
                    if (!allKeys.Contains(key)) {
                        allKeys.Add(key);
                    }
                }
                cachedRecords.Add(record);
			}

		    var headers = allKeys.OrderBy(key => key).ToList();
            if (!CsvConfig<Dictionary<string, string>>.OmitHeaders) {
                WriteRow(writer, headers);
            }
		    foreach (var cachedRecord in cachedRecords) {
                var fullRecord = new List<string>();
                foreach (var header in headers) {
                    fullRecord.Add(cachedRecord.ContainsKey(header)
                                        ? cachedRecord[header]
                                        : null);
                }
                WriteRow(writer, fullRecord);
		    }
		}
        public void RTree_Deletion_Test()
        {
            var nodeCount      = 1000;
            var randomPolygons = new System.Collections.Generic.HashSet <Polygon>();

            for (int i = 0; i < nodeCount; i++)
            {
                randomPolygons.Add(getRandomPointOrPolygon());
            }
            var order = 5;
            var tree  = new RTree(order);

            foreach (var polygon in randomPolygons)
            {
                tree.Insert(polygon);
            }

            int j = randomPolygons.Count;

            foreach (var polygon in randomPolygons)
            {
                tree.Delete(polygon);
                Assert.IsFalse(tree.Exists(polygon));

                j--;

                if (j > 0)
                {
                    var actualMaxHeight = tree.Root.Height;
                    Assert.AreEqual(verifyHeightUniformityAndReturnHeight(tree.Root, order), actualMaxHeight);
                    Assert.AreEqual(j, tree.Count);
                }
            }
        }
Esempio n. 17
0
        public static void LoadXmlDocumentation(Assembly assembly)
        {
            string xmlFilePath;

            if (LoadedAssemblies.Contains(assembly))
            {
                return;
            }

            var directoryPath = assembly.GetDirectoryPath();

            if (!string.IsNullOrEmpty(directoryPath))
            {
                xmlFilePath = Path.Combine(directoryPath, assembly.GetName().Name + ".xml");
            }
            else
            {
                xmlFilePath = assembly.GetName().Name + ".xml";
            }

            if (File.Exists(xmlFilePath))
            {
                using var streamReader = new StreamReader(xmlFilePath);
                LoadXmlDocumentation(streamReader);
            }
            // currently marking assembly as loaded even if the XML file was not found
            // may want to adjust in future, but I think this is good for now
            LoadedAssemblies.Add(assembly);
        }
Esempio n. 18
0
        /// <summary>
        /// Do DFS to find all unique edges.
        /// </summary>
        private void dfs(WeightedGraphVertex <T, TW> currentVertex, System.Collections.Generic.HashSet <T> visitedVertices, Dictionary <T, System.Collections.Generic.HashSet <T> > visitedEdges,
                         List <MSTEdge <T, TW> > result)
        {
            if (!visitedVertices.Contains(currentVertex.Value))
            {
                visitedVertices.Add(currentVertex.Value);

                foreach (var edge in currentVertex.Edges)
                {
                    if (!visitedEdges.ContainsKey(currentVertex.Value) ||
                        !visitedEdges[currentVertex.Value].Contains(edge.Key.Value))
                    {
                        result.Add(new MSTEdge <T, TW>(currentVertex.Value, edge.Key.Value, edge.Value));

                        //update visited edge
                        if (!visitedEdges.ContainsKey(currentVertex.Value))
                        {
                            visitedEdges.Add(currentVertex.Value, new HashSet <T>());
                        }

                        visitedEdges[currentVertex.Value].Add(edge.Key.Value);

                        //update visited back edge
                        if (!visitedEdges.ContainsKey(edge.Key.Value))
                        {
                            visitedEdges.Add(edge.Key.Value, new HashSet <T>());
                        }

                        visitedEdges[edge.Key.Value].Add(currentVertex.Value);
                    }

                    dfs(edge.Key, visitedVertices, visitedEdges, result);
                }
            }
        }
Esempio n. 19
0
        public ListNode DetectCycle(ListNode head)
        {
            /* Dictionary<ListNode, int> tmp = new Dictionary<ListNode, int> ();
             * int pos = -1;
             * while (head != null) {
             *  pos++;
             *  if (tmp.ContainsKey (head)) {
             *      return head;
             *  }
             *  tmp.Add (head, pos);
             *  head = head.next;
             * }
             * return null; */
            HashSet <ListNode> nodeset = new System.Collections.Generic.HashSet <ListNode> ();

            while (head != null)
            {
                if (nodeset.Contains(head))
                {
                    return(head);
                }
                nodeset.Add(head);
                head = head.next;
            }
            return(null);
        }
Esempio n. 20
0
            /// <summary>
            /// Validates this node and all its descendents.
            /// </summary>
            public static void ValidateInternalIntegrity(TRecursiveParent parent)
            {
                // Each node id appears at most once.
                if (parent.Children?.Count > 0)
                {
                    var observedIdentities = new System.Collections.Generic.HashSet <IdentityFieldType>();
                    foreach (var node in parent.GetSelfAndDescendents())
                    {
                        if (!observedIdentities.Add(node.Identity))
                        {
                            throw new RecursiveChildNotUniqueException(node.Identity);
                        }
                    }
                }

                // The lookup table (if any) accurately describes the contents of this tree.
                if (parent.LookupTable != null && parent.LookupTable != LazySentinel)
                {
                    // The table should have one entry for every *descendent* of this node (not this node itself).
                    int expectedCount = parent.GetSelfAndDescendents().Count() - 1;
                    int actualCount   = parent.LookupTable.Count;
                    Assumes.False(actualCount != expectedCount, "Expected {0} entries in lookup table but found {1}.", expectedCount, actualCount);

                    ValidateLookupTable(parent, parent.LookupTable);
                }
            }
Esempio n. 21
0
        private IEnumerable <NewEvent> ProcessEvent(Event evnt)
        {
            var eventValue = evnt.Value;

            List <NewEvent> newEvents = new List <NewEvent>();

            switch (eventValue.Type)
            {
            case EventType.NewStory:
                newEvents.Add(new NewEvent(Distribution.NextStory, new EventValue(EventType.NewStory)));
                var storyId = _storyIdCounter++;
                _storiesInProgress.Add(storyId);
                newEvents.Add(new NewEvent(Distribution.StoryCycleTime, new EventValue(EventType.StoryFinish, storyId)));
                break;

            case EventType.StoryFinish:
                var cycleTime = evnt.Time - evnt.StartTime;
                _simulatedStoryCycleTimes.Add(cycleTime);
                _storiesInProgress.Remove(eventValue.StoryId);
                break;

            case EventType.Sample:
                newEvents.Add(new NewEvent(Distribution.Unit, new EventValue(EventType.Sample)));
                _storiesInProgressSample.Add(_storiesInProgress.Count);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(newEvents);
        }
        public void RTree_Insertion_Test()
        {
            var nodeCount      = 1000;
            var randomPolygons = new System.Collections.Generic.HashSet <Polygon>();

            for (int i = 0; i < nodeCount; i++)
            {
                randomPolygons.Add(getRandomPointOrPolygon());
            }
            var order = 5;
            var tree  = new RTree(order);

            int j = 0;

            foreach (var polygon in randomPolygons)
            {
                tree.Insert(polygon);

                //height should be similar to that of B+ tree.
                //https://en.wikipedia.org/wiki/B-tree#Best_case_and_worst_case_heights
                var theoreticalMaxHeight = Math.Ceiling(Math.Log((j + 2) / 2, (int)Math.Ceiling((double)order / 2))) + 1;

                var actualMaxHeight = tree.Root.Height;
                Assert.AreEqual(verifyHeightUniformityAndReturnHeight(tree.Root, order), actualMaxHeight);
                Assert.IsTrue(actualMaxHeight <= theoreticalMaxHeight);
                j++;

                Assert.IsTrue(tree.Exists(polygon));
            }

            Assert.AreEqual(j, tree.Count);
        }
                //Typical data in navigator: <test weight="5" type="exact" flag="SA" tcpsig="65535:128:1:48:M1460,N,N,S:."/>
                internal Test(XPathNavigator testXPathNavigator, string osClass, string osDetails)
                {
                    testXPathNavigator.MoveToFirstAttribute();
                    //attributeList=new System.Collections.Specialized.NameValueCollection();
                    this.tcpflags = new HashSet <char>();

                    this.p0fFingerprint = null;

                    do
                    {
                        //attributeList.Add(testXPathNavigator.Name, testXPathNavigator.Value);
                        if (testXPathNavigator.Name == "weight")
                        {
                            this.weight = Convert.ToInt32(testXPathNavigator.Value);
                        }
                        if (testXPathNavigator.Name == "tcpsig")
                        {
                            this.p0fFingerprint = new P0fOsFingerprintCollection.P0fFingerprint(testXPathNavigator.Value + ":" + osClass + ":" + osDetails);
                        }
                        if (testXPathNavigator.Name == "tcpflag")
                        {
                            foreach (char c in testXPathNavigator.Value.ToCharArray())
                            {
                                tcpflags.Add(c);
                            }
                        }
                    }while(testXPathNavigator.MoveToNextAttribute());
                }
 internal override void GetResAsset(System.Collections.Generic.HashSet <string> setRes)
 {
     if (mEffectName != string.Empty)
     {
         setRes.Add(mEffectName);
     }
 }
Esempio n. 25
0
 private void Validate_IntersectWith(ISet <T> set, IEnumerable <T> enumerable)
 {
     if (set.Count == 0 || Enumerable.Count(enumerable) == 0)
     {
         set.IntersectWith(enumerable);
         Assert.Equal(0, set.Count);
     }
     else if (set == enumerable)
     {
         System.Collections.Generic.HashSet <T> beforeOperation = new System.Collections.Generic.HashSet <T>(set, GetIEqualityComparer());
         set.IntersectWith(enumerable);
         Assert.True(beforeOperation.SetEquals(set));
     }
     else
     {
         IEqualityComparer <T> comparer = GetIEqualityComparer();
         System.Collections.Generic.HashSet <T> expected = new System.Collections.Generic.HashSet <T>(comparer);
         foreach (T value in set)
         {
             if (enumerable.Contains(value, comparer))
             {
                 expected.Add(value);
             }
         }
         set.IntersectWith(enumerable);
         Assert.Equal(expected.Count, set.Count);
         Assert.True(expected.SetEquals(set));
     }
 }
Esempio n. 26
0
        /// <summary>
        /// Do DFS to pick smallest weight neighbour edges
        /// of current spanning tree one by one
        /// </summary>
        /// <param name="graph"></param>
        /// <param name="currentVertex"></param>
        /// <param name="spanTreeVertices"></param>
        /// <param name="spanTreeNeighbours"> Use Fibornacci Min Heap to pick smallest edge neighbour </param>
        /// <param name="spanTreeEdges">result MST edges</param>
        private void dfs(WeightedGraph <T, W> graph, WeightedGraphVertex <T, W> currentVertex, BMinHeap <MSTEdge <T, W> > spanTreeNeighbours, System.Collections.Generic.HashSet <T> spanTreeVertices, List <MSTEdge <T, W> > spanTreeEdges)
        {
            while (true)
            {
                //add all edges to Fibornacci Heap
                //So that we can pick the min edge in next step
                foreach (var edge in currentVertex.Edges)
                {
                    spanTreeNeighbours.Insert(new MSTEdge <T, W>(currentVertex.Value, edge.Key.Value, edge.Value));
                }

                //pick min edge
                var minNeighbourEdge = spanTreeNeighbours.ExtractMin();

                //skip edges already in MST
                while (spanTreeVertices.Contains(minNeighbourEdge.Source) && spanTreeVertices.Contains(minNeighbourEdge.Destination))
                {
                    minNeighbourEdge = spanTreeNeighbours.ExtractMin();

                    //if no more neighbours to explore
                    //time to end exploring
                    if (spanTreeNeighbours.Count == 0)
                    {
                        return;
                    }
                }

                //keep track of visited vertices
                //do not duplicate vertex
                if (!spanTreeVertices.Contains(minNeighbourEdge.Source))
                {
                    spanTreeVertices.Add(minNeighbourEdge.Source);
                }

                //Destination vertex will never be a duplicate
                //since this is an unexplored Vertex
                spanTreeVertices.Add(minNeighbourEdge.Destination);

                //add edge to result
                spanTreeEdges.Add(minNeighbourEdge);

                //now explore the destination vertex
                var graph1 = graph;
                currentVertex = graph1.Vertices[minNeighbourEdge.Destination];
            }
        }
 public static void CollectMapping(Activity rootActivity1, Activity rootActivity2, Dictionary<object, SourceLocation> mapping, string path)
 {
     Activity activity = (rootActivity1.RootActivity != null) ? rootActivity1.RootActivity : rootActivity1;
     if (!activity.IsRuntimeReady)
     {
         IList<ValidationError> validationErrors = null;
         ActivityUtilities.CacheRootMetadata(activity, new ActivityLocationReferenceEnvironment(), ProcessActivityTreeOptions.ValidationOptions, null, ref validationErrors);
     }
     Activity activity2 = (rootActivity2.RootActivity != null) ? rootActivity2.RootActivity : rootActivity2;
     if (!activity2.IsRuntimeReady)
     {
         IList<ValidationError> list2 = null;
         ActivityUtilities.CacheRootMetadata(activity2, new ActivityLocationReferenceEnvironment(), ProcessActivityTreeOptions.ValidationOptions, null, ref list2);
     }
     Queue<KeyValuePair<Activity, Activity>> queue = new Queue<KeyValuePair<Activity, Activity>>();
     queue.Enqueue(new KeyValuePair<Activity, Activity>(rootActivity1, rootActivity2));
     System.Collections.Generic.HashSet<Activity> set = new System.Collections.Generic.HashSet<Activity>();
     while (queue.Count > 0)
     {
         SourceLocation location;
         KeyValuePair<Activity, Activity> pair = queue.Dequeue();
         Activity key = pair.Key;
         Activity activity4 = pair.Value;
         set.Add(key);
         if (TryGetSourceLocation(activity4, path, out location))
         {
             mapping.Add(key, location);
         }
         else if (!(activity4 is IExpressionContainer) && !(activity4 is IValueSerializableExpression))
         {
             Debugger.Log(2, "Workflow", "WorkflowDebugger: Does not have corresponding Xaml node for: " + activity4.DisplayName + "\n");
         }
         if ((!(key is IExpressionContainer) && !(activity4 is IExpressionContainer)) && (!(key is IValueSerializableExpression) && !(activity4 is IValueSerializableExpression)))
         {
             IEnumerator<Activity> enumerator = WorkflowInspectionServices.GetActivities(key).GetEnumerator();
             IEnumerator<Activity> enumerator2 = WorkflowInspectionServices.GetActivities(activity4).GetEnumerator();
             bool flag = enumerator.MoveNext();
             bool flag2 = enumerator2.MoveNext();
             while (flag && flag2)
             {
                 if (!set.Contains(enumerator.Current))
                 {
                     if (enumerator.Current.GetType() != enumerator2.Current.GetType())
                     {
                         Debugger.Log(2, "Workflow", "Unmatched type: " + enumerator.Current.GetType().FullName + " vs " + enumerator2.Current.GetType().FullName + "\n");
                     }
                     queue.Enqueue(new KeyValuePair<Activity, Activity>(enumerator.Current, enumerator2.Current));
                 }
                 flag = enumerator.MoveNext();
                 flag2 = enumerator2.MoveNext();
             }
             if (flag || flag2)
             {
                 Debugger.Log(2, "Workflow", "Unmatched number of children\n");
             }
         }
     }
 }
Esempio n. 28
0
        private void _Decompose(ParameterSyntax node)
        {
            var kind = node.Type.Kind();

            _Types.Add(node.Type.ToFullString());
            if (kind != SyntaxKind.PredefinedType)
            {
            }
        }
Esempio n. 29
0
 public override bool AddItem(T element)
 {
     if (table.Add(element))
     {
         list.Add(element);
         return(true);
     }
     return(false);
 }
Esempio n. 30
0
        static VisualBasicSettings()
        {
            System.Collections.Generic.HashSet <VisualBasicImportReference> set = new System.Collections.Generic.HashSet <VisualBasicImportReference>();
            VisualBasicImportReference item = new VisualBasicImportReference {
                Import   = "System",
                Assembly = "mscorlib"
            };

            set.Add(item);
            VisualBasicImportReference reference2 = new VisualBasicImportReference {
                Import   = "System.Collections",
                Assembly = "mscorlib"
            };

            set.Add(reference2);
            VisualBasicImportReference reference3 = new VisualBasicImportReference {
                Import   = "System.Collections.Generic",
                Assembly = "mscorlib"
            };

            set.Add(reference3);
            VisualBasicImportReference reference4 = new VisualBasicImportReference {
                Import   = "System",
                Assembly = "system"
            };

            set.Add(reference4);
            VisualBasicImportReference reference5 = new VisualBasicImportReference {
                Import   = "System.Collections.Generic",
                Assembly = "system"
            };

            set.Add(reference5);
            VisualBasicImportReference reference6 = new VisualBasicImportReference {
                Import   = "System.Activities",
                Assembly = "System.Activities"
            };

            set.Add(reference6);
            VisualBasicImportReference reference7 = new VisualBasicImportReference {
                Import   = "System.Activities.Statements",
                Assembly = "System.Activities"
            };

            set.Add(reference7);
            VisualBasicImportReference reference8 = new VisualBasicImportReference {
                Import   = "System.Activities.Expressions",
                Assembly = "System.Activities"
            };

            set.Add(reference8);
            defaultImportReferences = set;
            defaultSettings         = new VisualBasicSettings(defaultImportReferences);
        }
Esempio n. 31
0
    private HashSet <int> getAllItems()
    {
        var result = new System.Collections.Generic.HashSet <int>();

        foreach (var id in Enum.GetValues(typeof(ItemIds)))
        {
            result.Add((int)id);
        }
        return(result);
    }
Esempio n. 32
0
        /// <summary>
        ///     BFS + A-star
        /// </summary>
        /// <returns>First item - first step to end, do not equal start. End included as last item.</returns>
        public TNode[] GetPath(TNode start, TNode end)
        {
            var visited = new System.Collections.Generic.HashSet <TNode>(new[] { start });
            var queue   = new IntervalHeap <TNode>(CreateComparer(end))
            {
                start
            };
            var parents = new Dictionary <TNode, TNode>();

            while (queue.Count > 0)
            {
                var current = queue.DeleteMin();
                foreach (var neighbour in GetNeighbours(current))
                {
                    if (visited.Contains(neighbour))
                    {
                        continue;
                    }

                    parents[neighbour] = current;
                    if (neighbour.Equals(end))
                    {
                        var result = new List <TNode>(new[] { end });
                        while (!current.Equals(start))
                        {
                            result.Add(current);
                            current = parents[current];
                        }

                        result.Reverse();
                        return(result.ToArray());
                    }

                    queue.Add(neighbour);
                    visited.Add(neighbour);
                }

                visited.Add(current);
            }

            return(Array.Empty <TNode>());
        }
            public ListNode deleteDuplication(ListNode pHead)
            {
                if (pHead == null)
                {
                    return(pHead);
                }

                var values    = new System.Collections.Generic.HashSet <int>();
                var dupValues = new System.Collections.Generic.HashSet <int>();
                var node      = pHead;

                values.Add(node.val);
                while (node.next != null)
                {
                    if (values.Contains(node.next.val))
                    {
                        dupValues.Add(node.next.val);
                    }

                    values.Add(node.next.val);

                    node = node.next;
                }

                var temp = new ListNode(1);

                temp.next = pHead;
                node      = temp;
                while (node.next != null)
                {
                    if (dupValues.Contains(node.next.val))
                    {
                        node.next = node.next.next;
                    }
                    else
                    {
                        node = node.next;
                    }
                }

                return(temp.next);
            }
Esempio n. 34
0
        static void Main(string[] args)
        {
            HashSet <int> x = new System.Collections.Generic.HashSet <int>();

            x.Add(1);
            x.Add(2);
            x.Add(1);

            HashSet <Person> p = new HashSet <Person>();

            p.Add(new Person("pawel"));
            p.Add(new Person("pawel"));
            p.Add(new Person("marcin"));
            p.Add(new Person("gosia"));
            p.Add(new Person("magda"));


            Console.WriteLine("Hello World!");
            Console.ReadLine();
        }
 public IEnumerable<IDataObject> BindRdfDataObjects(IGraph graph)
 {
     var distinctSubjects = new System.Collections.Generic.HashSet<INode>();
     foreach (var t in graph.Triples)
     {
         distinctSubjects.Add(t.Subject);
     }
     return distinctSubjects.Select(s =>
         MakeDataObject(s.ToString(),
             graph.GetTriplesWithSubject(s).Select(t =>
                 MakeTriple(t.Subject, t.Predicate, t.Object))));
 } 
Esempio n. 36
0
        private static void setupAsterismGrabbers()
        {
            GameObject starRoot = new GameObject("StarRoot");

              for(int i=0; i < AsterismData.Length; i++) {
            Asterism asterism = AsterismData[i];
            Vector3 centroid = averageStarLocations(asterism.HD_ids);

            GameObject newRoot = new GameObject();
            GameObject rest = new GameObject();
            GameObject jewelcase = new GameObject();

            newRoot.name = asterism.name + "_root";
            newRoot.transform.position = centroid;
            newRoot.transform.rotation = Quaternion.identity;

            rest.name = "rest";
            rest.transform.parent = newRoot.transform;
            rest.transform.localPosition = Vector3.zero;
            rest.transform.localRotation = Quaternion.identity;
            rest.transform.localScale = new Vector3(1.0f,1.0f,1.0f);

            jewelcase.name = "jewelcase";
            jewelcase.transform.parent = newRoot.transform;
            jewelcase.transform.localPosition = Vector3.zero;
            jewelcase.transform.localRotation = Quaternion.identity;
            jewelcase.transform.localScale = new Vector3(1.0f,1.0f,1.0f);
            PullToHold pullscript = jewelcase.AddComponent<PullToHold>();
            pullscript.asterismKey = i;
            pullscript.rest = rest.transform;
            pullscript.maxSpeed = 20.0f;

            newRoot.transform.parent = starRoot.transform;
            asterism.root = newRoot;
            asterism.rest = rest;
            asterism.mover = jewelcase;

            System.Collections.Generic.HashSet<uint> used = new System.Collections.Generic.HashSet<uint>();

            GameObject constellationLabel = GameObject.Instantiate(Stars.StarUpdater.Instance.ConstellationLabelPrototype) as GameObject;
            constellationLabel.SetActive(true);
            ConstellationLabel labelBehavior = constellationLabel.GetComponent<ConstellationLabel>();

            if ( asterism.root != null ) {
              labelBehavior.transform.parent = asterism.root.transform;
            }

            labelBehavior.Label = asterism.name;
            labelBehavior.transform.localPosition = (asterism.root.transform.position.normalized * 500.0f);
            asterism.label = labelBehavior;
            labelBehavior.LabelComp.color = new Color(1.0f, 1.0f, 1.0f, Stars.StarUpdater.Instance.LabelOpacity * 0.8f);

            Stars.StarUpdater.Instance.m_constellationLabels.Add(labelBehavior);

            foreach(uint hdId in asterism.HD_ids) {
              if ( !Stars.StarParser.HD_idToIndex.ContainsKey(hdId) ) {
            continue;
              }

              int index = Stars.StarParser.HD_idToIndex[hdId];
              Stars.StarData star = Stars.StarParser.Instance.Stars[index];

              star.AsterismIndex = i;
              Stars.StarParser.Instance.Stars[index] = star;
              if ( star.GameObjectRepresentation != null ) {
            star.GameObjectRepresentation.name = hdId.ToString();
            star.GameObjectRepresentation.transform.parent = jewelcase.transform;
            if (star.Label != ""){

              if(used.Contains(star.HD_id)) {
                continue;
              }

              Stars.StarUpdater.Instance.GenerateStarLabel(star, star.GameObjectRepresentation.transform);
              used.Add(star.HD_id);
            }
              }
            }

            AsterismData[i] = asterism;
              }
        }
        private void DecorateCodeNamespace(CodeNamespace codeNamespace)
        {
            // Generate the schema set code namespace
            CodeNamespace schemaSetCodeNamespace = GenerateSchemaTypes();
            
            // Add the code namespace to a fast search structure
            //      KeyValuePair<type  , namespace> 
            HashSet<KeyValuePair<string, string>> typeSet = new System.Collections.Generic.HashSet<KeyValuePair<string, string>>();
            
            foreach (CodeTypeDeclaration ctd in codeNamespace.Types)
            {
                XmlQualifiedName typeQn = GetCodeTypeXmlQName(ctd);

                typeSet.Add(new KeyValuePair<string, string>(typeQn.Name, typeQn.Namespace));
            }
            
            // add the missing types from the schema code namespace to the main code namespace
            foreach (CodeTypeDeclaration sctd in schemaSetCodeNamespace.Types)
            {
                XmlQualifiedName typeQn = GetCodeTypeXmlQName(sctd);

                if (!typeSet.Contains(new KeyValuePair<string, String>(typeQn.Name, typeQn.Namespace)))
                {
                    codeNamespace.Types.Add(sctd);
                }
            }
        }
Esempio n. 38
0
        //uPrime is the child of u
        //the result of the join is returned.
        private PrimeNode NodeJoin(SplitTree ST, Node u, Node uPrime)
        {
            MarkerVertex qPrime = uPrime.rootMarkerVertex;
            MarkerVertex q = qPrime.opposite as MarkerVertex;
            PrimeNode ret = null;
            List<GLTVertex> uPrimeChildren = new List<GLTVertex>();

            if (u is DegenerateNode)
            {
                ret = (u as DegenerateNode).ConvertToPrime();
                //u.parentLink = ret;
                //u.unionFind_parent = null;
                u.active = true;
            }
            else
                ret = u as PrimeNode;
            var representative = ret.childSetRepresentative;
            if (uPrime is DegenerateNode && (uPrime as DegenerateNode).isStar && qPrime != (uPrime as DegenerateNode).center)//qPrime has degree 1, not center.
            {
                var center = (uPrime as DegenerateNode).center;
                var centerOpposite = center.GetOppositeGLTVertex();
                //Algorithm 8 says q now represents the center of u', so we have to update the center's opposite..
                if (centerOpposite is Node)
                {
                    (centerOpposite as Node).rootMarkerVertex.opposite = q;
                }
                else
                    (centerOpposite as Leaf).opposite = q;
                uPrimeChildren.Add(centerOpposite);
                //And also copy the center's perfect state, and opposite.
                q.perfect = center.perfect;
                q.opposite = center.opposite;
                (uPrime as DegenerateNode).ForEachMarkerVertex((v) =>
                    {
                        if (v != center && v != qPrime)
                        {
                            ret.AddMarkerVertex(v, new HashSet<MarkerVertex> { q });
                            uPrimeChildren.Add(v.GetOppositeGLTVertex());
                        }
                        return IterationFlag.Continue;
                    });
            }
            else
            {
                List<MarkerVertex> qNeighbor = new List<MarkerVertex>();
                ret.ForEachNeighbor(q, (v) =>
                    {
                        qNeighbor.Add(v);
                        return IterationFlag.Continue;
                    });
                ret.RemoveMarkerVertex(q);
                var qPrimeNeighbor = new System.Collections.Generic.HashSet<MarkerVertex>();
                uPrime.ForEachNeighbor(qPrime, (v) =>
                    {
                        qPrimeNeighbor.Add(v);
                        return IterationFlag.Continue;
                    });
                uPrime.ForEachMarkerVertex((v) =>
                    {
                        if (v != qPrime)
                        {
                            if (qPrimeNeighbor.Contains(v))
                            {
                                HashSet<MarkerVertex> nSet = new HashSet<MarkerVertex>(qNeighbor);
                                uPrime.ForEachNeighbor(v, (w) =>
                                    {
                                        if (w != qPrime)
                                            nSet.Add(w);
                                        return IterationFlag.Continue;
                                    });
                                ret.AddMarkerVertex(v, nSet);
                            }
                            else
                            {
                                HashSet<MarkerVertex> nSet = new HashSet<MarkerVertex>();
                                uPrime.ForEachNeighbor(v, (w) =>
                                    {
                                        if (w != qPrime)
                                            nSet.Add(w);
                                        return IterationFlag.Continue;
                                    });
                                ret.AddMarkerVertex(v, nSet);
                            }
                        }
                        return IterationFlag.Continue;
                    });
                if (uPrime is PrimeNode)
                {
                    uPrimeChildren.Add((uPrime as PrimeNode).childSetRepresentative);
                }
                else
                {
                    uPrime.ForEachChild(v =>
                        {
                            uPrimeChildren.Add(v);
                            return IterationFlag.Continue;
                        }, false);
                }
            }

            //union the children of uPrime

            for (int i = 0, n = uPrimeChildren.Count; i < n; ++i)
            {
                uPrimeChildren[i].parentLink = null;
                uPrimeChildren[i].unionFind_parent = representative;
            }

            //set deletion flag for uPrime, or if it's the child representative, make it a fake node
            uPrime.active = true;
            if (uPrime == representative)
            {
                uPrime.parentLink = ret;//update the parentLink to the new prime node
                //don't touch the unoinFind_parent field. leave it pointing to uPrime itself.
            }
            else//uPrime is not a fake node.
            {
                uPrime.parentLink = ret;
                //uPrime.unionFind_parent = null;
            }
            return ret;
        }
        public void greedySolve()
        {
            timer = new Stopwatch();
            timer.Start();
            Route = new ArrayList(Cities.Length);
            System.Collections.Generic.HashSet<int> unvisitedIndexes = new System.Collections.Generic.HashSet<int>(); // using a city's index in Cities, we can interate through indexes that have yet to be added
            for (int index = 0; index < Cities.Length; index++)
            {
                unvisitedIndexes.Add(index);
            }

            print("\n\nTESTING\n");

            City city;
            for (int i = 0; i < Cities.Length; i++) // keep trying start nodes until a solution is found
            {
                if (Route.Count == Cities.Length)
                {
                    break; // DONE!
                }
                else
                {
                    Route.Clear();
                    for (int index = 0; index < Cities.Length; index++)
                    {
                        unvisitedIndexes.Add(index);
                    }
                    city = Cities[i];
                }

                for (int n = 0; n < Cities.Length; n++) // add nodes n times
                {

                    double shortestDistance = Double.PositiveInfinity;
                    int closestIndex = -1;
                    foreach (int check in unvisitedIndexes) //find the closest city to add to route
                    {
                        double distance = city.costToGetTo(Cities[check]);
                        if (distance < shortestDistance)
                        {
                            shortestDistance = distance;
                            closestIndex = check;
                        }
                    }

                    if (closestIndex != -1)
                    {
                        city = Cities[closestIndex];
                        Route.Add(city);
                        unvisitedIndexes.Remove(closestIndex);
                    }
                    else
                    {
                        break; // try again
                    }
                }
            }

            // call this the best solution so far.  bssf is the route that will be drawn by the Draw method.
            bssf = new TSPSolution(Route);
            // update the cost of the tour.
            Program.MainForm.tbCostOfTour.Text = " " + bssf.costOfRoute();
            TimeSpan ts = timer.Elapsed;
            Program.MainForm.tbElapsedTime.Text = ts.TotalSeconds.ToString();
            // do a refresh.
            Program.MainForm.Invalidate();
        }
        private void VertexInsertion(SplitTree ST, List<int> sigma, int idx)
        {
            #region Bootstrapping
            if (ST.vertices.Count == 0)//initialization
            {
                Leaf v = new Leaf
                {
                    id = sigma[idx],
                    parent = null,
                };
                ST.AddLeaf(v);
                ST.root = v;
            }
            else if (ST.vertices.Count == 1)//only the root, thus we cache the second vertex
            {
                Leaf v = new Leaf
                {
                    id = sigma[idx],
                    parent = null,
                };
                ST.AddLeaf(v);
            }
            else if (ST.vertices.Count == 2)//now we're building the first trinity
            {
                Leaf v = new Leaf
                {
                    id = sigma[idx],
                    parent = null
                };
                ST.AddLeaf(v);
                int missingConnection = -1; //test the missing connection between the cached 3 leave
                if (!storage[(ST.vertices[0] as Leaf).id].Contains((ST.vertices[1] as Leaf).id))
                {
                    missingConnection = 0;
                }
                else if (!storage[(ST.vertices[0] as Leaf).id].Contains((ST.vertices[2] as Leaf).id))
                {
                    missingConnection = 1;
                }
                else if (!storage[(ST.vertices[1] as Leaf).id].Contains((ST.vertices[2] as Leaf).id))
                {
                    missingConnection = 2;
                }
                MarkerVertex v1 = new MarkerVertex()
                {
                    opposite = ST.vertices[0]
                };
                MarkerVertex v2 = new MarkerVertex()
                {
                    opposite = ST.vertices[1]
                };
                MarkerVertex v3 = new MarkerVertex()
                {
                    opposite = ST.vertices[2]
                };
                (ST.vertices[0] as Leaf).opposite = v1;
                (ST.vertices[1] as Leaf).opposite = v2;
                (ST.vertices[2] as Leaf).opposite = v3;
                MarkerVertex center = null;
                switch (missingConnection)
                {
                    case 0:
                        center = v3;
                        break;
                    case 1:
                        center = v2;
                        break;
                    case 2:
                        center = v1;
                        break;
                    default: break;
                }
                var deg = new DegenerateNode()
                {
                    parent = ST.vertices[0],
                    Vu = new List<MarkerVertex> { v1, v2, v3 },
                    center = center,
                    rootMarkerVertex = v1
                };
                v1.node = deg;
                ST.vertices[1].parent = ST.vertices[2].parent = deg;
                ST.vertices.Add(deg);
                ST.lastVertex = ST.vertices[2] as Leaf;
            }
            #endregion
            else
            {
                TreeEdge e; Vertex u; SplitTree tPrime;
                var returnType = SplitTree_CaseIdentification(ST, sigma, idx, out e, out u, out tPrime);
                switch (returnType)
                {
                    case CaseIdentification_ResultType.SingleLeaf:
                        //This case is not discussed in paper. However, if there's only a single leaf in neighbor set,
                        //then a unique PE edge can be found.
                        //Applying proposition 4.17, case 6
                        e.u = (u as Leaf).opposite;
                        e.v = u;
                        ST.SplitEdgeToStar(e, sigma[idx]);
                        break;
                    case CaseIdentification_ResultType.TreeEdge://PP or PE
                        {
                            bool unique = true;
                            bool pp;
                            //testing uniqueness, page 24
                            //check whether pp or pe
                            if (!e.u.Perfect())
                            {
                                var tmp = e.u;
                                e.u = e.v;
                                e.v = tmp;
                            }
                            pp = e.v.Perfect();
                            var u_GLT = e.u_GLT;
                            var v_GLT = e.v_GLT;
                            DegenerateNode degNode = null;
                            if (u_GLT is DegenerateNode)
                                degNode = u_GLT as DegenerateNode;
                            if (v_GLT is DegenerateNode)
                                degNode = v_GLT as DegenerateNode;
                            if (degNode != null)//attached to a clique or a star
                            {
                                if ((pp && degNode.isClique) || (!pp/*pe*/ && degNode.isStar && (e.u == degNode.center || degNode.Degree(e.v as MarkerVertex) == 1)))
                                {
                                    unique = false;
                                }
                            }
                            if (unique)
                            {
                                //Proposition 4.17 case 5 or 6

                                if (pp)//PP
                                {
                                    ST.SplitEdgeToClique(e, sigma[idx]);
                                }
                                else//PE
                                {
                                    ST.SplitEdgeToStar(e, sigma[idx]);
                                }
                            }
                            else
                            {
                                //Proposition 4.15, case 1 or 2
                                var deg = u_GLT;
                                if (v_GLT is DegenerateNode)
                                    deg = v_GLT;
                                ST.AttachToDegenerateNode(deg as DegenerateNode, sigma[idx]);
                            }
                        }
                        break;
                    case CaseIdentification_ResultType.HybridNode:
                        if (u is DegenerateNode)
                        {
                            //Proposition 4.16
                            var uDeg = u as DegenerateNode;
                            System.Collections.Generic.HashSet<MarkerVertex> PStar = new System.Collections.Generic.HashSet<MarkerVertex>();
                            System.Collections.Generic.HashSet<MarkerVertex> EStar = new System.Collections.Generic.HashSet<MarkerVertex>();
                            uDeg.ForEachMarkerVertex((v) =>
                                {
                                    if (v.perfect && v != uDeg.center)
                                        PStar.Add(v);
                                    else
                                        EStar.Add(v);
                                    return IterationFlag.Continue;
                                });
                            //before we split, determine the new perfect states for the two new markers to be generated
                            bool pp = false;
                            if (uDeg.isStar && uDeg.center.perfect)
                            {
                                pp = true;//see figure 7. pp==true iff star and center is perfect.
                            }
                            var newNode = SplitNode(uDeg, PStar, EStar);
                            ST.vertices.Add(newNode);
                            //e.u \in PStar ; e.v \in EStar (thus containing the original center, if star)
                            //PStar in uDeg; EStar in newNode
                            if (newNode.parent == uDeg)
                            {
                                e.u = newNode.rootMarkerVertex.opposite;
                                e.v = newNode.rootMarkerVertex;
                            }
                            else
                            {
                                e.u = uDeg.rootMarkerVertex;
                                e.v = uDeg.rootMarkerVertex.opposite;
                            }
                            //assign perfect state values
                            if (pp)
                            {
                                e.u.MarkAsPerfect();
                                e.v.MarkAsPerfect();
                            }
                            else//PE, and PStar part always has an empty state and EStar part has perfect.
                            {
                                e.u.MarkAsEmpty();
                                e.v.MarkAsPerfect();
                            }
                            //check whether pp or pe
                            if (!e.u.Perfect())
                            {
                                var tmp = e.u;
                                e.u = e.v;
                                e.v = tmp;
                            }
                            if (e.v.Perfect())//PP
                            {
                                ST.SplitEdgeToClique(e, sigma[idx]);
                            }
                            else//PE
                            {
                                ST.SplitEdgeToStar(e, sigma[idx]);
                            }
                        }
                        else
                        {
                            //Proposition 4.15, case 3
                            ST.AttachToPrimeNode(u as PrimeNode, sigma[idx]);
                        }
                        break;
                    case CaseIdentification_ResultType.FullyMixedSubTree:
                        //Proposition 4.20
                        Cleaning(ST, tPrime);
                        //ST.Debug(false);
                        var contractionNode = Contraction(ST, tPrime, sigma[idx]);
                        break;
                }
            }
        }
Esempio n. 41
0
        public void TestMemberFn_GetHashCode ()
        {
            var hs1 = new System.Collections.Generic.HashSet<Matrix44>();
            var hs2 = new System.Collections.Generic.HashSet<Int32>();

            for(Int32 i = 0; i < 10000; ++i)
            {
                var a = GetNextRandomMatrix44 ();

                hs1.Add(a);
                hs2.Add(a.GetHashCode ());
            }

            Assert.That(hs1.Count, Is.EqualTo(hs2.Count).Within(10));
        }