当前位置: 首页>>代码示例>>C#>>正文


C# Book.RunSearch方法代码示例

本文整理汇总了C#中Book.RunSearch方法的典型用法代码示例。如果您正苦于以下问题:C# Book.RunSearch方法的具体用法?C# Book.RunSearch怎么用?C# Book.RunSearch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Book的用法示例。


在下文中一共展示了Book.RunSearch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            List<SimpleEdge> edges = new List<SimpleEdge>();
            /*edges.Add(new SimpleEdge(0, 1));
            edges.Add(new SimpleEdge(1, 2));
            edges.Add(new SimpleEdge(2, 0));
            edges.Add(new SimpleEdge(1, 3));

            Book book = new Book("book1", 4, edges);

            ItemType it = new ItemType("item1", true);
            book.AddNewItem(it);

            var x = book.GetEdges(1, 3).First();
            x.AddRequestedItem(new RequestedItemUnit(it));

            book.GetParagraph(2).AddRecievedItem(new ItemUnit(it));*/

            edges.Add(new SimpleEdge(0, 1));
            edges.Add(new SimpleEdge(0, 2));
            edges.Add(new SimpleEdge(1, 3));
            edges.Add(new SimpleEdge(2, 3));
            edges.Add(new SimpleEdge(2, 4));
            edges.Add(new SimpleEdge(4, 3));
            edges.Add(new SimpleEdge(3, 5));
            edges.Add(new SimpleEdge(5, 3));
            edges.Add(new SimpleEdge(3, 6));

            Book book = new Book("book1", 7, edges);

            ItemType gold = new ItemType("gold", false);
            ItemType am = new ItemType("am", true);

            book.GetEdges(0, 1).First().AddRequestedItem(new RequestedItemUnit(gold, 2));
            book.GetEdges(3, 5).First().AddRequestedItem(new RequestedItemUnit(gold, 1));
            book.GetEdges(3, 6).First().AddRequestedItem(new RequestedItemUnit(am, 4));

            book.GetParagraph(1).AddRecievedItem(new ItemUnit(am, 1));
            book.GetParagraph(4).AddRecievedItem(new ItemUnit(am, 1));
            book.GetParagraph(5).AddRecievedItem(new ItemUnit(am, 1));

            var searchResults = book.RunSearch(new PersonState(0, new List<ItemUnit> { new ItemUnit(gold, 3) }));

            using (TextWriter writer = File.CreateText("output.txt"))
            {
                foreach (var result in searchResults)
                {
                    writer.WriteLine("{0} Distance: {1}", result.Key, result.Value);
                }
            }
        }
开发者ID:quercitron,项目名称:questbook,代码行数:51,代码来源:Program.cs


注:本文中的Book.RunSearch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。