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


C# Random.Close方法代码示例

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


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

示例1: TestCommitUserData

		public virtual void  TestCommitUserData()
		{
			Directory dir = new MockRAMDirectory();
			IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
			w.SetMaxBufferedDocs(2);
			for (int j = 0; j < 17; j++)
				AddDoc(w);
			w.Close();
			
			Assert.AreEqual(0, IndexReader.GetCommitUserData(dir).Count);
			
			IndexReader r = IndexReader.Open(dir);
			// commit(Map) never called for this index
			Assert.AreEqual(0, r.GetCommitUserData().Count);
			r.Close();
			
			w = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
			w.SetMaxBufferedDocs(2);
			for (int j = 0; j < 17; j++)
				AddDoc(w);
            System.Collections.Generic.IDictionary<string, string> data = new System.Collections.Generic.Dictionary<string,string>();
			data["label"] = "test1";
			w.Commit(data);
			w.Close();
			
			Assert.AreEqual("test1", IndexReader.GetCommitUserData(dir)["label"]);
			
			r = IndexReader.Open(dir);
			Assert.AreEqual("test1", r.GetCommitUserData()["label"]);
			r.Close();
			
			w = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
			w.Optimize();
			w.Close();
			
			Assert.AreEqual("test1", IndexReader.GetCommitUserData(dir)["label"]);
			
			dir.Close();
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:39,代码来源:TestIndexWriter.cs

示例2: TestRandomIWReader

		public virtual void  TestRandomIWReader()
		{
			this.r = NewRandom();
			Directory dir = new MockRAMDirectory();
			
			// TODO: verify equals using IW.getReader
			DocsAndWriter dw = IndexRandomIWReader(10, 100, 100, dir);
			IndexReader r = dw.writer.GetReader();
			dw.writer.Commit();
			VerifyEquals(r, dir, "id");
			r.Close();
			dw.writer.Close();
			dir.Close();
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:14,代码来源:TestStressIndexing2.cs

示例3: TestFutureCommit

        public void TestFutureCommit()
        {
            Directory dir = new MockRAMDirectory();

            IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(), new NoDeletionPolicy(), IndexWriter.MaxFieldLength.UNLIMITED);
            Document doc = new Document();
            w.AddDocument(doc);

            // commit to "first"
            System.Collections.Generic.Dictionary<string, string> commitData = new System.Collections.Generic.Dictionary<string, string>();
            commitData["tag"]="first";
            w.Commit(commitData);

            // commit to "second"
            w.AddDocument(doc);
            commitData["tag"]="second";
            w.Commit(commitData);
            w.Close();

            // open "first" with IndexWriter
            IndexCommit commit = null;
            System.Collections.IEnumerator it = IndexReader.ListCommits(dir).GetEnumerator();
            while (it.MoveNext())
            {
                IndexCommit c = (IndexCommit)it.Current;
                string tag = (String)c.GetUserData()["tag"];
                if ("first".Equals(tag))
                {
                    commit = c;
                    break;
                }
            }

            Assert.NotNull(commit);

            w = new IndexWriter(dir, new WhitespaceAnalyzer(), new NoDeletionPolicy(), IndexWriter.MaxFieldLength.UNLIMITED, commit);

            Assert.AreEqual(1, w.NumDocs());

            // commit IndexWriter to "third"
            w.AddDocument(doc);
            commitData["tag"]="third";
            w.Commit(commitData);
            w.Close();

            // make sure "second" commit is still there
            commit = null;
            it = IndexReader.ListCommits(dir).GetEnumerator();
            while (it.MoveNext())
            {
                IndexCommit c = (IndexCommit)it.Current;
                string tag = (String)c.GetUserData()["tag"];
                if ("second".Equals(tag))
                {
                    commit = c;
                    break;
                }
            }

            Assert.NotNull(commit);

            IndexReader r = IndexReader.Open(commit, true);
            Assert.AreEqual(2, r.NumDocs());
            r.Close();

            // open "second", w/ writeable IndexReader & commit
            r = IndexReader.Open(commit, new NoDeletionPolicy(), false);
            Assert.AreEqual(2, r.NumDocs());
            r.DeleteDocument(0);
            r.DeleteDocument(1);
            commitData["tag"]="fourth";
            r.Commit(commitData);
            r.Close();

            // make sure "third" commit is still there
            commit = null;
            it = IndexReader.ListCommits(dir).GetEnumerator();
            while (it.MoveNext())
            {
                IndexCommit c = (IndexCommit)it.Current;
                string tag = (String)c.GetUserData()["tag"];
                if ("third".Equals(tag))
                {
                    commit = c;
                    break;
                }
            }
            Assert.NotNull(commit);

            dir.Close();
        }
开发者ID:Mpdreamz,项目名称:lucene.net,代码行数:91,代码来源:TestIndexWriter.cs


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