public void ExampleTest()
        {
            _multiMap.Add("a", "a");
            _multiMap.Add("a", "b");
            _multiMap.Add("a", "c");

            var set = _multiMap.Get("a");

            set.Size.Should().Be(3);
            set.Get("a").Should().NotBeNull();
            set.Get("b").Should().NotBeNull();
            set.Get("c").Should().NotBeNull();

            _multiMap.Delete("a", "b");

            set = _multiMap.Get("a");
            set.Size.Should().Be(2);
            set.Get("a").Should().NotBeNull();
            set.Get("b").Should().BeNull();
            set.Get("c").Should().NotBeNull();

            _multiMap.DeleteAll("a");

            _multiMap.Get("a").Should().BeNull();
        }
示例#2
0
        public virtual IParseTree Get(string label)
        {
            IList <IParseTree> parseTrees = labels.Get(label);

            if (parseTrees == null || parseTrees.Count == 0)
            {
                return(null);
            }
            return(parseTrees[parseTrees.Count - 1]);
        }
        public void SetItems(MultiMap <string, PDFDocument> items)
        {
            // Clear our items
            PanelItems.Children.Clear();

            bool alternator = false;

            foreach (string author in items.Keys)
            {
                TextBlock text_author = new TextBlock();
                text_author.ToolTip = text_author.Text = author;

                text_author.FontWeight = FontWeights.Bold;
                PanelItems.Children.Add(text_author);

                List <PDFDocument> pdf_documents_sorted = new List <PDFDocument>(items.Get(author).OrderBy(x => x.YearCombined));
                foreach (PDFDocument pdf_document in pdf_documents_sorted)
                {
                    TextBlock text_doc = ListFormattingTools.GetDocumentTextBlock(pdf_document, ref alternator, Features.SimilarAuthor_OpenDoc);
                    PanelItems.Children.Add(text_doc);
                }
            }

            if (0 == PanelItems.Children.Count)
            {
                TextBlock text_doc = new TextBlock();
                text_doc.Text = "None in this library.";
                PanelItems.Children.Add(text_doc);
            }
        }
示例#4
0
        private static void MakeLeanMSG2(Store msg, ResSet predicates, StatementSink removed,
                                         ResSet nodesremoved, BNode startingnode)
        {
            // Find every pair of two distinct outgoing edges from startingnode
            // with the same predicate, targeting entities only.

            MultiMap edges = new MultiMap();

            foreach (Statement s in msg.Select(new Statement(startingnode, null, null)))
            {
                if (s.Object is Entity)
                {
                    edges.Put(new Edge(true, startingnode, s.Predicate, null), s.Object);
                }
            }
            foreach (Statement s in msg.Select(new Statement(null, null, startingnode)))
            {
                edges.Put(new Edge(false, startingnode, s.Predicate, null), s.Subject);
            }

            foreach (Edge e in edges.Keys)
            {
                // Make sure we have a distinct set of targets.
                ResSet targets_set = new ResSet();
                foreach (Entity r in edges.Get(e))
                {
                    targets_set.Add(r);
                }
                if (targets_set.Count == 1)
                {
                    continue;
                }

                IList targets = targets_set.ToEntityArray();

                // Take every pair of targets, provided
                // one is a bnode that can be a variable.
                for (int i = 0; i < targets.Count; i++)
                {
                    if (!(targets[i] is BNode) || predicates.Contains((BNode)targets[i]))
                    {
                        continue;
                    }
                    if (nodesremoved.Contains((BNode)targets[i]))
                    {
                        continue;
                    }
                    for (int j = 0; j < targets.Count; j++)
                    {
                        if (i == j)
                        {
                            continue;
                        }
                        // Create a new synchronous-path object.
                        SyncPath p = new SyncPath();
                        p.FixedNodes.Add((Resource)targets[j]);
                        p.FrontierVariables.Add((Resource)targets[i]);
                        p.Mapping[targets[i]] = targets[j];
                        p.Path[new Edge(e.Direction, e.Start, e.Predicate, (BNode)targets[i])] = p.Path;
                        if (MakeLeanMSG3(msg, predicates, removed, nodesremoved, p))
                        {
                            break;                             // the target was removed
                        }
                    }
                }
            }
        }