本文整理汇总了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();
}
示例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();
}
示例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();
}