本文整理汇总了C#中System.Collections.Hashtable.GetEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Hashtable.GetEnumerator方法的具体用法?C# System.Collections.Hashtable.GetEnumerator怎么用?C# System.Collections.Hashtable.GetEnumerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Hashtable
的用法示例。
在下文中一共展示了System.Collections.Hashtable.GetEnumerator方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckHits_
public static void CheckHits_(Query query, System.String defaultFieldName, Searcher searcher, int[] results, TestCase testCase)
{
Hits hits = searcher.Search(query);
System.Collections.Hashtable correct = new System.Collections.Hashtable();
for (int i = 0; i < results.Length; i++)
{
correct.Add((System.Int32) results[i], null);
}
System.Collections.Hashtable actual = new System.Collections.Hashtable();
for (int i = 0; i < hits.Length(); i++)
{
actual.Add((System.Int32) hits.Id(i), null);
}
//Assert.AreEqual(correct, actual, query.ToString(defaultFieldName));
if (correct.Count != 0)
{
System.Collections.IDictionaryEnumerator iter = correct.GetEnumerator();
bool status = false;
while (iter.MoveNext())
{
status = actual.ContainsKey(iter.Key);
if (status == false)
break;
}
Assert.IsTrue(status, query.ToString(defaultFieldName));
}
}
示例2: MergeBooleanQueries
private float boost = 1.0f; // query boost factor
#endregion Fields
#region Methods
/// <summary>Expert: merges the clauses of a set of BooleanQuery's into a single
/// BooleanQuery.
///
/// <p/>A utility for use by <see cref="Combine(Query[])" /> implementations.
/// </summary>
public static Query MergeBooleanQueries(BooleanQuery[] queries)
{
System.Collections.Hashtable allClauses = new System.Collections.Hashtable();
for (int i = 0; i < queries.Length; i++)
{
BooleanClause[] clauses = queries[i].GetClauses();
for (int j = 0; j < clauses.Length; j++)
{
SupportClass.CollectionsHelper.AddIfNotContains(allClauses, clauses[j]);
}
}
bool coordDisabled = queries.Length == 0?false:queries[0].IsCoordDisabled();
BooleanQuery result = new BooleanQuery(coordDisabled);
System.Collections.IEnumerator i2 = allClauses.GetEnumerator();
while (i2.MoveNext())
{
result.Add((BooleanClause) i2.Current);
}
return result;
}
示例3: Combine
/// <summary>Expert: called when re-writing queries under MultiSearcher.
///
/// Create a single query suitable for use by all subsearchers (in 1-1
/// correspondence with queries). This is an optimization of the OR of
/// all queries. We handle the common optimization cases of equal
/// queries and overlapping clauses of boolean OR queries (as generated
/// by MultiTermQuery.rewrite() and RangeQuery.rewrite()).
/// Be careful overriding this method as queries[0] determines which
/// method will be called and is not necessarily of the same type as
/// the other queries.
/// </summary>
public virtual Query Combine(Query[] queries)
{
System.Collections.Hashtable uniques = new System.Collections.Hashtable();
for (int i = 0; i < queries.Length; i++)
{
Query query = queries[i];
BooleanClause[] clauses = null;
// check if we can split the query into clauses
bool splittable = (query is BooleanQuery);
if (splittable)
{
BooleanQuery bq = (BooleanQuery) query;
splittable = bq.IsCoordDisabled();
clauses = bq.GetClauses();
for (int j = 0; splittable && j < clauses.Length; j++)
{
splittable = (clauses[j].GetOccur() == BooleanClause.Occur.SHOULD);
}
}
if (splittable)
{
for (int j = 0; j < clauses.Length; j++)
{
Query tmp = clauses[j].GetQuery();
if (uniques.Contains(tmp) == false)
{
uniques.Add(tmp, tmp);
}
}
}
else
{
if (uniques.Contains(query) == false)
{
uniques.Add(query, query);
}
}
}
// optimization: if we have just one query, just return it
if (uniques.Count == 1)
{
System.Collections.IDictionaryEnumerator iter = uniques.GetEnumerator();
iter.MoveNext();
return iter.Value as Query;
}
System.Collections.IDictionaryEnumerator it = uniques.GetEnumerator();
BooleanQuery result = new BooleanQuery(true);
while (it.MoveNext())
{
result.Add((Query) it.Value, BooleanClause.Occur.SHOULD);
}
return result;
}
示例4: createInitialHosts
/* -------------------------- Private methods ---------------------------- */
/// <summary> Input is "daddy[8880],sindhu[8880],camille[5555]. Return List of IpAddresses</summary>
private System.Collections.ArrayList createInitialHosts(System.String l)
{
Global.Tokenizer tok = new Global.Tokenizer(l, ",");
System.String t;
Address addr;
int port;
System.Collections.ArrayList retval = new System.Collections.ArrayList();
System.Collections.Hashtable hosts = new System.Collections.Hashtable();
//to be removed later on
while (tok.HasMoreTokens())
{
try
{
t = tok.NextToken();
System.String host = t.Substring(0, (t.IndexOf((System.Char)'[')) - (0));
host = host.Trim();
port = System.Int32.Parse(t.Substring(t.IndexOf((System.Char)'[') + 1, (t.IndexOf((System.Char)']')) - (t.IndexOf((System.Char)'[') + 1)));
hosts.Add(host, port);
}
catch (System.FormatException e)
{
Stack.NCacheLog.Error("exeption is " + e);
}
catch (Exception e)
{
Stack.NCacheLog.Error("TcpPing.createInitialHosts", "Error: " + e.ToString());
throw new Exception("Invalid initial members list");
}
}
try
{
System.Collections.IDictionaryEnumerator ide;
for(int i = 0; i< port_range; i++)
{
ide = hosts.GetEnumerator();
while(ide.MoveNext())
{
port = Convert.ToInt32(ide.Value);
addr = new Address((String)ide.Key, port + i);
retval.Add(addr);
}
}
}
catch(Exception ex)
{
Stack.NCacheLog.Error("TcpPing.CreateInitialHosts()", "Error :" + ex);
throw new Exception("Invalid initial memebers list");
}
return retval;
}
示例5: CheckHitCollector
/// <summary> Tests that a query matches the an expected set of documents using a
/// HitCollector.
///
/// <p>
/// Note that when using the HitCollector API, documents will be collected
/// if they "match" regardless of what their score is.
/// </p>
/// </summary>
/// <param name="query">the query to test
/// </param>
/// <param name="searcher">the searcher to test the query against
/// </param>
/// <param name="defaultFieldName">used for displaing the query in assertion messages
/// </param>
/// <param name="results">a list of documentIds that must match the query
/// </param>
/// <seealso cref="Searcher.Search(Query,HitCollector)">
/// </seealso>
/// <seealso cref="checkHits">
/// </seealso>
public static void CheckHitCollector(Query query, System.String defaultFieldName, Searcher searcher, int[] results)
{
System.Collections.ArrayList correct = new System.Collections.ArrayList(results.Length);
for (int i = 0; i < results.Length; i++)
{
correct.Add(results[i]);
}
System.Collections.Hashtable actual = new System.Collections.Hashtable();
searcher.Search(query, new AnonymousClassHitCollector(actual));
System.Collections.IDictionaryEnumerator e = actual.GetEnumerator();
while (e.MoveNext())
{
Assert.Contains(e.Key, correct, query.ToString(defaultFieldName));
}
QueryUtils.Check(query, searcher);
}
示例6: TestShrinkToAfterShortestMatch3
public virtual void TestShrinkToAfterShortestMatch3()
{
RAMDirectory directory = new RAMDirectory();
IndexWriter writer = new IndexWriter(directory, new TestPayloadAnalyzer(this), IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
doc.Add(new Field("content", new System.IO.StreamReader(new System.IO.MemoryStream(System.Text.Encoding.ASCII.GetBytes("j k a l f k k p a t a k l k t a")))));
writer.AddDocument(doc);
writer.Close();
IndexSearcher is_Renamed = new IndexSearcher(directory);
SpanTermQuery stq1 = new SpanTermQuery(new Term("content", "a"));
SpanTermQuery stq2 = new SpanTermQuery(new Term("content", "k"));
SpanQuery[] sqs = new SpanQuery[]{stq1, stq2};
SpanNearQuery snq = new SpanNearQuery(sqs, 0, true);
Spans spans = snq.GetSpans(is_Renamed.GetIndexReader());
TopDocs topDocs = is_Renamed.Search(snq, 1);
System.Collections.Hashtable payloadSet = new System.Collections.Hashtable();
for (int i = 0; i < topDocs.ScoreDocs.Length; i++)
{
while (spans.Next())
{
System.Collections.Generic.ICollection<byte[]> payloads = spans.GetPayload();
for (System.Collections.IEnumerator it = payloads.GetEnumerator(); it.MoveNext(); )
{
Support.CollectionsHelper.AddIfNotContains(payloadSet, new System.String(System.Text.UTF8Encoding.UTF8.GetChars((byte[]) it.Current)));
}
}
}
Assert.AreEqual(2, payloadSet.Count);
if (DEBUG)
{
System.Collections.IEnumerator pit = payloadSet.GetEnumerator();
while (pit.MoveNext())
{
System.Console.Out.WriteLine("match:" + pit.Current);
}
}
Assert.IsTrue(payloadSet.Contains("a:Noise:10"));
Assert.IsTrue(payloadSet.Contains("k:Noise:11"));
}
示例7: DifFiles
private static System.Collections.Hashtable DifFiles(System.String[] files1, System.String[] files2)
{
System.Collections.Hashtable set1 = new System.Collections.Hashtable();
System.Collections.Hashtable set2 = new System.Collections.Hashtable();
System.Collections.Hashtable extra = new System.Collections.Hashtable();
for (int x = 0; x < files1.Length; x++)
{
Support.CollectionsHelper.AddIfNotContains(set1, files1[x]);
}
for (int x = 0; x < files2.Length; x++)
{
Support.CollectionsHelper.AddIfNotContains(set2, files2[x]);
}
System.Collections.IEnumerator i1 = set1.GetEnumerator();
while (i1.MoveNext())
{
System.Object o = i1.Current;
if (!set2.Contains(o))
{
Support.CollectionsHelper.AddIfNotContains(extra, o);
}
}
System.Collections.IEnumerator i2 = set2.GetEnumerator();
while (i2.MoveNext())
{
System.Object o = i2.Current;
if (!set1.Contains(o))
{
Support.CollectionsHelper.AddIfNotContains(extra, o);
}
}
return extra;
}
示例8: Main
//.........这里部分代码省略.........
for (x = i; x < strGPResultXMLFile.Length; x++)
{
int posString = strGPResultXMLFile[x].IndexOf(STR_SETTINGSTART);
int posNumber = strGPResultXMLFile[x].IndexOf(STR_NUMBERSTART);
int max = Math.Max(posNumber, posString);
string strComp = STR_NUMBERSTART;
string strComp2 = STR_SETTINGEND;
if (posNumber < posString)
{
strComp = STR_SETTINGSTART;
strComp2 = STR_NUMBEREND;
}
string strTemp = strGPResultXMLFile[x];
int endPosMax = strTemp.IndexOf(strComp2);
if (max >= 0)
{
string strValue = strTemp.Substring(max + strComp.Length, endPosMax - max - strComp.Length);
htRegistryValues.Add(strAdd, strValue);
break;
}
}
i = x;
}
}
// Read the .inf-file that has been exported from the template.
bool bRegistryMode = false;
for (int i = 0; i < strFile.Length; i++)
{
if (bRegistryMode)
{
if (strFile[i].IndexOf("[") >= 0)
{
bRegistryMode = false;
}
else
{
int pos = 0;
int endPos = strFile[i].IndexOf("=");
if (endPos > 0)
{
string strAdd = strFile[i].Substring(pos, endPos - pos);
string strValue = strFile[i].Substring(endPos + 3);
htCurrentRegistrySettings.Add(strAdd, strValue);
}
else
{
throw new FormatException();
}
}
}
else
{
if (strFile[i].IndexOf("[Registry Values]") >= 0)
{
bRegistryMode = true;
}
}
}
// Print out the difference between settings
System.Collections.IDictionaryEnumerator en = htRegistryValues.GetEnumerator();
while(en.MoveNext())
{
string strKey = (string) en.Key;
string strVal = (string) en.Value;
Console.Write(en.Key + "|");
if (htCurrentRegistrySettings.ContainsKey(strKey))
{
string strCurrentVal = (string)htCurrentRegistrySettings[strKey];
bool bEqual = (strCurrentVal == (string)htRegistryValues[strKey]);
Console.WriteLine((string)htRegistryValues[strKey] + "|" + strCurrentVal + "|" + bEqual.ToString());
}
else
{
Console.WriteLine("||Missing");
}
}
}
示例9: ByVendorsPerMonth
private void ByVendorsPerMonth(object sender, EventArgs e)
{
try
{
if( this.lbxObjects.SelectedItems.Count > 0 ){
List<Guid> ids = new List<Guid>();
//foreach( ListViewItem obj in this.lbxObjects.SelectedItems ){
foreach( DataRowView obj in this.lbxObjects.SelectedItems ){
if (!System.Convert.IsDBNull(obj["VendorID"]))
ids.Add((Guid)obj["VendorID"]);
}
System.Data.SqlClient.SqlCommand mnth = Statistics.Purchases.ByVendorsPerMonth(ids);
mnth.Connection = this.connection;
System.Data.SqlClient.SqlDataAdapter sda = new System.Data.SqlClient.SqlDataAdapter(mnth);
System.Data.DataTable st = new System.Data.DataTable("Summary");
sda.Fill(st);
ZedGraph.GraphPane pane = this.zgcStatistics.GraphPane;
pane.CurveList.Clear();
pane.GraphObjList.Clear();
pane.YAxis.Title.Text = "Сумма, р";
System.Collections.Hashtable lsts = new System.Collections.Hashtable();
foreach (System.Data.DataRow row in st.Rows)
{
ZedGraph.PointPairList list = null;
string v_name = (string)row["VendorName"];
if (lsts.ContainsKey(v_name))
{
list = (ZedGraph.PointPairList)lsts[v_name];
}
else
{
list = new ZedGraph.PointPairList();
lsts.Add(v_name, list);
}
int year = 1970;
int month = 1;
if (!System.Convert.IsDBNull(row["Year"]) &&
!System.Convert.IsDBNull(row["Month"]))
{
year = (int)row["Year"];
month = (int)row["Month"];
System.DateTime dt = new DateTime(year, month, 1);
ZedGraph.XDate xDate = new ZedGraph.XDate(dt);
decimal val = (decimal)row["Summary"];
list.Add(xDate.XLDate, (double)val);
}
}
Random rand = new Random();
System.Collections.IEnumerator lenum = lsts.GetEnumerator();
while(lenum.MoveNext() )
{
int r = rand.Next(255);
int g = rand.Next(255);
int b = rand.Next(255);
Color clr = Color.FromArgb(r, g, b);
System.Collections.DictionaryEntry lde = (System.Collections.DictionaryEntry)lenum.Current;
ZedGraph.BarItem curve = pane.AddBar((string)lde.Key, (ZedGraph.PointPairList)lde.Value, clr);
}
// Для оси X установим календарный тип
pane.XAxis.Type = ZedGraph.AxisType.Date;
// pretty it up a little
pane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.LightGoldenrodYellow, 45.0f);
pane.Fill = new ZedGraph.Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0f);
// Tell ZedGraph to calculate the axis ranges
this.zgcStatistics.AxisChange();
this.zgcStatistics.Invalidate();
}
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
return;
}
示例10: GetTerms
//fieldname MUST be interned prior to this call
private static void GetTerms(Query query, System.Collections.Hashtable terms, bool prohibited, System.String fieldName)
{
try
{
if (query is BooleanQuery)
GetTermsFromBooleanQuery((BooleanQuery) query, terms, prohibited, fieldName);
else if (query is FilteredQuery)
GetTermsFromFilteredQuery((FilteredQuery) query, terms, prohibited, fieldName);
else
{
System.Collections.Hashtable nonWeightedTerms = new System.Collections.Hashtable();
query.ExtractTerms(nonWeightedTerms);
System.Collections.IDictionaryEnumerator iter = nonWeightedTerms.GetEnumerator();
while (iter.MoveNext())
{
Term term = (Term)iter.Value;
if ((fieldName == null) || (term.Field() == fieldName))
{
WeightedTerm temp = new WeightedTerm(query.GetBoost(), term.Text());
terms.Add(temp, temp);
}
}
}
}
catch (System.NotSupportedException ignore)
{
//this is non-fatal for our purposes
}
}
示例11: detect
/**
* <p>Detects a Data Matrix Code in an image.</p>
*
* @return {@link DetectorResult} encapsulating results of detecting a QR Code
* @throws ReaderException if no Data Matrix Code can be found
*/
public DetectorResult detect() {
if (!BlackPointEstimationMethod.TWO_D_SAMPLING.Equals(image.getLastEstimationMethod())) {
image.estimateBlackPoint(BlackPointEstimationMethod.TWO_D_SAMPLING, 0);
}
int height = image.getHeight();
int width = image.getWidth();
int halfHeight = height >> 1;
int halfWidth = width >> 1;
int iSkip = Math.Max(1, height / (MAX_MODULES << 3));
int jSkip = Math.Max(1, width / (MAX_MODULES << 3));
int minI = 0;
int maxI = height;
int minJ = 0;
int maxJ = width;
ResultPoint pointA = findCornerFromCenter(halfHeight, -iSkip, minI, maxI, halfWidth, 0, minJ, maxJ, halfWidth >> 1);
minI = (int) pointA.getY() - 1;
ResultPoint pointB = findCornerFromCenter(halfHeight, 0, minI, maxI, halfWidth, -jSkip, minJ, maxJ, halfHeight >> 1);
minJ = (int) pointB.getX() - 1;
ResultPoint pointC = findCornerFromCenter(halfHeight, 0, minI, maxI, halfWidth, jSkip, minJ, maxJ, halfHeight >> 1);
maxJ = (int) pointC.getX() + 1;
ResultPoint pointD = findCornerFromCenter(halfHeight, iSkip, minI, maxI, halfWidth, 0, minJ, maxJ, halfWidth >> 1);
maxI = (int) pointD.getY() + 1;
// Go try to find point A again with better information -- might have been off at first.
pointA = findCornerFromCenter(halfHeight, -iSkip, minI, maxI, halfWidth, 0, minJ, maxJ, halfWidth >> 2);
// Point A and D are across the diagonal from one another,
// as are B and C. Figure out which are the solid black lines
// by counting transitions
System.Collections.ArrayList transitions = new System.Collections.ArrayList(4);
transitions.Add(transitionsBetween(pointA, pointB));
transitions.Add(transitionsBetween(pointA, pointC));
transitions.Add(transitionsBetween(pointB, pointD));
transitions.Add(transitionsBetween(pointC, pointD));
Collections.insertionSort(transitions, new ResultPointsAndTransitionsComparator());
// Sort by number of transitions. First two will be the two solid sides; last two
// will be the two alternating black/white sides
ResultPointsAndTransitions lSideOne = (ResultPointsAndTransitions) transitions[0];
ResultPointsAndTransitions lSideTwo = (ResultPointsAndTransitions) transitions[1];
// Figure out which point is their intersection by tallying up the number of times we see the
// endpoints in the four endpoints. One will show up twice.
System.Collections.Hashtable pointCount = new System.Collections.Hashtable();
increment(pointCount, lSideOne.getFrom());
increment(pointCount, lSideOne.getTo());
increment(pointCount, lSideTwo.getFrom());
increment(pointCount, lSideTwo.getTo());
ResultPoint maybeTopLeft = null;
ResultPoint bottomLeft = null;
ResultPoint maybeBottomRight = null;
System.Collections.IEnumerator points = pointCount.GetEnumerator();
while (points.MoveNext()) {
ResultPoint point = (ResultPoint) points.Current;
int value = (int) pointCount[point];
if (value == 2) {
bottomLeft = point; // this is definitely the bottom left, then -- end of two L sides
} else {
// Otherwise it's either top left or bottom right -- just assign the two arbitrarily now
if (maybeTopLeft == null) {
maybeTopLeft = point;
} else {
maybeBottomRight = point;
}
}
}
if (maybeTopLeft == null || bottomLeft == null || maybeBottomRight == null) {
throw new ReaderException();
}
// Bottom left is correct but top left and bottom right might be switched
ResultPoint[] corners = { maybeTopLeft, bottomLeft, maybeBottomRight };
// Use the dot product trick to sort them out
GenericResultPoint.orderBestPatterns(corners);
// Now we know which is which:
ResultPoint bottomRight = corners[0];
bottomLeft = corners[1];
ResultPoint topLeft = corners[2];
// Which point didn't we find in relation to the "L" sides? that's the top right corner
ResultPoint topRight;
if (!pointCount.ContainsKey(pointA)) {
topRight = pointA;
} else if (!pointCount.ContainsKey(pointB)) {
topRight = pointB;
} else if (!pointCount.ContainsKey(pointC)) {
topRight = pointC;
} else {
//.........这里部分代码省略.........