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


C# System.Collections.Hashtable.Contains方法代码示例

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


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

示例1: LoadFullSummary

        public static DataTable LoadFullSummary(int locationId, int thermostatId, DateTime startDate, DateTime endDate, int timezoneDifference)
        {
            DataTable cycles = LoadSummary(thermostatId, startDate, endDate,timezoneDifference);
            DataTable weather = OutsideConditions.LoadSummary(locationId, startDate, endDate, timezoneDifference);

            DataTable result = new DataTable();
            result.Columns.Add("LogDate", typeof(DateTime));
            result.Columns.Add("OutsideMin", typeof(int));
            result.Columns.Add("OutsideMax", typeof(int));
            System.Collections.Hashtable cycleTypes = new System.Collections.Hashtable();
            foreach (DataRow row in cycles.Rows)
            {
                string cycleType = Convert.ToString(row["cycle_type"]);
                if (!cycleTypes.Contains(cycleType)) cycleTypes.Add(cycleType, cycleType);
            }
            foreach (string cycleType in cycleTypes.Keys)
            {
                result.Columns.Add(cycleType + "_CycleCount", typeof(int));
                result.Columns.Add(cycleType + "_TotalSeconds", typeof(double));
                result.Columns.Add(cycleType + "_AverageSeconds", typeof(double));
            }

            System.Collections.Hashtable dateHash = new System.Collections.Hashtable();

            foreach (DataRow row in cycles.Rows)
            {
                string cycleType = Convert.ToString(row["cycle_type"]);
                int cycleCount = Convert.ToInt32(row["cycle_count"]);
                int totalSeconds = Convert.ToInt32(row["total_seconds"]);
                double averageSeconds = Convert.ToDouble(totalSeconds) / Convert.ToDouble(cycleCount);
                DateTime logDate = Convert.ToDateTime(row["log_date"]);

                bool newDate = !dateHash.Contains(logDate);
                DataRow resultRow=null;
                if (newDate) resultRow = result.NewRow(); else resultRow = result.Rows[Convert.ToInt32(dateHash[logDate])];
                resultRow[cycleType + "_CycleCount"] = cycleCount;
                resultRow[cycleType + "_TotalSeconds"] = totalSeconds;
                resultRow[cycleType + "_AverageSeconds"] = averageSeconds;
                if (newDate)
                {
                    resultRow["LogDate"] = logDate;
                    result.Rows.Add(resultRow);
                    dateHash.Add(logDate, result.Rows.Count - 1);
                }
            }

            foreach (DataRow row in weather.Rows)
            {
                DateTime logDate = Convert.ToDateTime(row["log_date"]);
                bool newDate = !dateHash.Contains(logDate);
                if (!newDate)
                {
                    DataRow resultRow = result.Rows[Convert.ToInt32(dateHash[logDate])];
                    resultRow["OutsideMin"] = Convert.ToInt32(row["MinDegrees"]);
                    resultRow["OutsideMax"] = Convert.ToInt32(row["MaxDegrees"]);
                }
            }

            return result;
        }
开发者ID:AndroidThermostat,项目名称:ThermostatMonitor-Net,代码行数:60,代码来源:Cycles.cs

示例2: TestStopList

		public virtual void  TestStopList()
		{
			System.Collections.Hashtable stopWordsSet = new System.Collections.Hashtable();
			stopWordsSet.Add("good", "good");
			stopWordsSet.Add("test", "test");
			stopWordsSet.Add("analyzer", "analyzer");

            // {{Aroush  how can we copy 'stopWordsSet' to 'System.String[]'?
            System.String[] arrStopWordsSet = new System.String[3];
            arrStopWordsSet[0] = "good";
            arrStopWordsSet[1] = "test";
            arrStopWordsSet[2] = "analyzer";
            // Aroush}}

			StopAnalyzer newStop = new StopAnalyzer(arrStopWordsSet);
			System.IO.StringReader reader = new System.IO.StringReader("This is a good test of the english stop analyzer");
			TokenStream stream = newStop.TokenStream("test", reader);
			Assert.IsTrue(stream != null);
			Token token = null;
			try
			{
				while ((token = stream.Next()) != null)
				{
					System.String text = token.TermText();
					Assert.IsTrue(stopWordsSet.Contains(text) == false);
				}
			}
			catch (System.IO.IOException e)
			{
				Assert.IsTrue(false);
			}
		}
开发者ID:runefs,项目名称:Marvin,代码行数:32,代码来源:TestStopAnalyzer.cs

示例3: setDisplay

        /// <summary>
        /// �]�wCMS���
        /// </summary>
        /// <param name="devNames"></param>
        /// <returns></returns>        
        protected override System.Collections.Hashtable setDisplay(RemoteInterface.HC.FetchDeviceData[] devNames, int maxSegId, MegType megType)
        {
            System.Collections.Hashtable displayht = new System.Collections.Hashtable();

            List<object> outputs = new List<object>();
            if (devNames == null || devNames.Length == 0) return displayht;

            foreach (RemoteInterface.HC.FetchDeviceData devName in devNames)
            {
                int distance = getDeviceDistance(devName.SegId, maxSegId);
                DevStartMile = devName.Mileage;
                DevLineID = devName.LineId;
                CMSDevName = devName.DevName;

                outputs = (List<object>)com.select(DBConnect.DataType.CmsCategory, Command.GetSelectCmd.getCMSCategory(Convert.ToInt32(DevRange["RULEID"]), (int)secType, devType.ToString(), distance, devName.DevName, megType.ToString(), ht["INC_LINEID"].ToString().Trim(),devName.Location,devName.LineId));
                foreach (object obj in outputs)
                {
                    List<object> output=new List<object>();
                    output.AddRange(new object[] { getPriority(), obj });
                    if (!displayht.Contains(devName.DevName))
                        displayht.Add(devName.DevName, output);
                    else if (devName.Location == "L")
                    {
                        displayht[devName.DevName] = output;
                    }
                }
            }
            return displayht;
        }
开发者ID:ufjl0683,项目名称:Center,代码行数:34,代码来源:CMS.cs

示例4: TestBasic

		public virtual void  TestBasic()
		{
			System.Collections.Hashtable fileExtensions = new System.Collections.Hashtable();
			SupportClass.CollectionsHelper.AddIfNotContains(fileExtensions, "fdt");
			SupportClass.CollectionsHelper.AddIfNotContains(fileExtensions, "fdx");
			
			Directory primaryDir = new MockRAMDirectory();
			RAMDirectory secondaryDir = new MockRAMDirectory();
			
			FileSwitchDirectory fsd = new FileSwitchDirectory(fileExtensions, primaryDir, secondaryDir, true);
			IndexWriter writer = new IndexWriter(fsd, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
			writer.SetUseCompoundFile(false);
			TestIndexWriterReader.CreateIndexNoClose(true, "ram", writer);
			IndexReader reader = writer.GetReader();
			Assert.AreEqual(100, reader.MaxDoc());
			writer.Commit();
			// we should see only fdx,fdt files here
			System.String[] files = primaryDir.ListAll();
			Assert.IsTrue(files.Length > 0);
			for (int x = 0; x < files.Length; x++)
			{
				System.String ext = FileSwitchDirectory.GetExtension(files[x]);
				Assert.IsTrue(fileExtensions.Contains(ext));
			}
			files = secondaryDir.ListAll();
			Assert.IsTrue(files.Length > 0);
			// we should not see fdx,fdt files here
			for (int x = 0; x < files.Length; x++)
			{
				System.String ext = FileSwitchDirectory.GetExtension(files[x]);
				Assert.IsFalse(fileExtensions.Contains(ext));
			}
			reader.Close();
			writer.Close();
			
			files = fsd.ListAll();
			for (int i = 0; i < files.Length; i++)
			{
				Assert.IsNotNull(files[i]);
			}
			fsd.Close();
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:42,代码来源:TestFileSwitchDirectory.cs

示例5: InterfaceMethod1

 public override string InterfaceMethod1(string _string)
 {
     string text = Test.Integration.Interface_Fields.Default + Test.Integration.Interface_Fields._params.ToString();
     text = text.Substring(1).Trim() + typeof(Test.Integration.Interface[]) + typeof(Class1) + this.GetType();
     string _lock = "";
     Test.Integration.InterfaceInnerClass anonymousClass = new AnonymousClassInterface_InterfaceInnerClass1(text, this, _lock);
     System.Collections.IDictionary map = new System.Collections.Hashtable();
     if (map.Contains(text) && ExistSimilarFieldAndMethod())
     {
         lock (text) {
             System.Collections.IEnumerator it = new System.Collections.ArrayList(map.Keys).GetEnumerator();
             System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry)it.Current;
             object key = entry.Key;
         }
     }
     return text[0] + System.Text.RegularExpressions.Regex.Replace(text, "\\s", "&nbsp");
 }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:17,代码来源:Class1.cs

示例6: TestStopList

		public virtual void  TestStopList()
		{
			System.Collections.Hashtable stopWordsSet = new System.Collections.Hashtable();
			stopWordsSet.Add("good", "good");
			stopWordsSet.Add("test", "test");
			stopWordsSet.Add("analyzer", "analyzer");
			StopAnalyzer newStop = new StopAnalyzer(stopWordsSet);
			System.IO.StringReader reader = new System.IO.StringReader("This is a good test of the english stop analyzer");
			TokenStream stream = newStop.TokenStream("test", reader);
			Assert.IsNotNull(stream);
			Token token = null;
			while ((token = stream.Next()) != null)
			{
				System.String text = token.TermText();
				Assert.IsFalse(stopWordsSet.Contains(text));
				Assert.AreEqual(1, token.GetPositionIncrement()); // by default stop tokenizer does not apply increments.
			}
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:18,代码来源:TestStopAnalyzer.cs

示例7: CheckNoMatchExplanations

		public static float EXPLAIN_SCORE_TOLERANCE_DELTA = 0.00025f;   // {{See: LUCENENET-288}} Intentional diversion from Java Lucene per above comment
		
		/// <summary> Tests that all documents up to maxDoc which are *not* in the
		/// expected result set, have an explanation which indicates no match
		/// (ie: Explanation value of 0.0f)
		/// </summary>
		public static void  CheckNoMatchExplanations(Query q, System.String defaultFieldName, Searcher searcher, int[] results)
		{
			
			System.String d = q.ToString(defaultFieldName);
			System.Collections.Hashtable ignore = new System.Collections.Hashtable();
			for (int i = 0; i < results.Length; i++)
			{
				SupportClass.CollectionsHelper.AddIfNotContains(ignore, (System.Int32) results[i]);
			}
			
			int maxDoc = searcher.MaxDoc();
			for (int doc = 0; doc < maxDoc; doc++)
			{
				if (ignore.Contains((System.Int32) doc))
					continue;
				
				Explanation exp = searcher.Explain(q, doc);
				Assert.IsNotNull(exp, "Explanation of [[" + d + "]] for #" + doc + " is null");
				Assert.AreEqual(0.0f, exp.GetValue(), 0.0f, "Explanation of [[" + d + "]] for #" + doc + " doesn't indicate non-match: " + exp.ToString());
			}
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:27,代码来源:CheckHits.cs

示例8: 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;
		}
开发者ID:zweib730,项目名称:beagrep,代码行数:64,代码来源:Query.cs

示例9: GetRangeBrachCMS

        private RemoteInterface.HC.FetchDeviceData[] GetRangeBrachCMS(string Line, int mile_s, int mile_e)
        {
            if ((int)DevRange["NORMAL"] == 0)
            {
                return new RemoteInterface.HC.FetchDeviceData[0];
            }

            if (mile_s > mile_e)
            {
                int k = mile_e;
                mile_e = mile_s;
                mile_s = k;
            }

            RemoteInterface.HC.I_HC_FWIS hobj = EasyClient.getHost();
            System.Data.DataTable DivDT = RSPGlobal.GetDivisionDT();
            System.Data.DataTable CloverleafDT = RSPGlobal.GetCloverleafDT();
            System.Collections.Hashtable tmpHT = new System.Collections.Hashtable();
            //List<System.Data.DataRow> DRList = new List<System.Data.DataRow>();
            foreach (System.Data.DataRow dr in DivDT.Rows)
            {
                if ((string)dr[1] == "C" && (string)dr[3] == Line && (int)dr[2] >= mile_s && (int)dr[2] <= mile_e)
                {
                    int k = 0;
                    foreach (System.Data.DataRow CloverDR in CloverleafDT.Rows)
                    {
                        if ((string)CloverDR[0] == Line && (int)CloverDR[1] == (int)dr[2])
                        {
                            k++;
                            RemoteInterface.HC.FetchDeviceData[] fetDevs
                                = hobj.Fetch(new string[] { "CMS","RGS" }, (string)CloverDR[2], (string)CloverDR[4], (int)CloverDR[3], (int)DevRange["NORMAL"] - 1, 0, false);
                            foreach (RemoteInterface.HC.FetchDeviceData dev in fetDevs)
                            {
                                if (!tmpHT.Contains(dev.DevName))
                                {
                                    tmpHT.Add(dev.DevName, dev);
                                }
                                if (dev.SegId == (int)DevRange["NORMAL"] -1)
                                    break;
                            }
                            if (k == 2)
                            {
                                break;
                            }
                        }
                    }
                }
            }

            List<RemoteInterface.HC.FetchDeviceData> DevList = new List<RemoteInterface.HC.FetchDeviceData>(tmpHT.Count);
            foreach (System.Collections.DictionaryEntry de in tmpHT)
            {
                if (((RemoteInterface.HC.FetchDeviceData)de.Value).DeviceType == devType.ToString())
                {
                    DevList.Add((RemoteInterface.HC.FetchDeviceData)de.Value);
                }
            }
            return DevList.ToArray();
        }
开发者ID:ufjl0683,项目名称:Center,代码行数:59,代码来源:ADevice.cs

示例10: setDisplay


//.........这里部分代码省略.........
                {
                    if (maxSegId != -99
                        && ((j == 0 && (Math.Abs(devNames[j].Mileage - Convert.ToInt32(ht["FROM_MILEPOST1"])) > range
                            && Math.Abs(devNames[j].Mileage - Convert.ToInt32(ht["TO_MILEPOST1"])) > range))
                        || (j > 0 && devNames[j-1].Location != "D" && Math.Abs(devNames[j].Mileage - devNames[j - 1].Mileage) > range)))
                        break;

                    if (maxSegId == -99) //�d�� �̧C�t��
                    {
                        SetSpped = SpeedList[0];
                    }
                    else                //�d��~
                    {
                        if (i >= SpeedList.Count || SpeedList[i].Equals(-1))
                        {
                            break;
                        }
                        else
                        {
                            if (SectionMaxSpeed < SpeedList[i])
                                SetSpped = SectionMaxSpeed;
                            else
                                SetSpped = SpeedList[i];
                        }
                    }
                    i++;
                }

                System.Data.DataSet DS = hobj.getSendDs("CSLS", "set_speed");
                DS.Tables[0].Rows[0]["speed"] = SetSpped;
                DS.AcceptChanges();
                List<object> output = new List<object>();
                output.AddRange(new object[] { SetSpped / 10, new RemoteInterface.HC.CSLSOutputData(DS) });
                if (!displayht.Contains(devNames[j].DevName))
                {
                    displayht.Add(devNames[j].DevName, output);
                }

            }

            #region OLD Function
            //if (maxSegId == -99)
            //{
            //    foreach (RemoteInterface.HC.FetchDeviceData devName in devNames)
            //    {
            //        System.Data.DataSet DS = hobj.getSendDs("CSLS", "set_speed");
            //        if (devName.minSpd > minSpeed)
            //            DS.Tables[0].Rows[0]["speed"] = devName.minSpd;  //�t��
            //        else
            //            DS.Tables[0].Rows[0]["speed"] = minSpeed;  //�t��
            //        DS.AcceptChanges();
            //        List<object> output = new List<object>();
            //        output.AddRange(new object[] { (int)(Convert.ToInt32(DS.Tables[0].Rows[0]["speed"]) / 10), new RemoteInterface.HC.CSLSOutputData(DS) });
            //        displayht.Add(devName.DevName, output);
            //    }
            //}
            //else
            //{
            //    int speed = minSpeed - decrease;
            //    foreach (RemoteInterface.HC.FetchDeviceData devName in devNames)
            //    {
            //        System.Data.DataSet DS = hobj.getSendDs("CSLS", "set_speed");
            //        if (range == -1)
            //        {
            //            if (speed < maxSpeed) speed += decrease;
            //            if (devName.maxSpd >= speed)
开发者ID:ufjl0683,项目名称:Center,代码行数:67,代码来源:CSLS.cs

示例11: FormSimilarQuery

        /// <summary> Simple similarity query generators.
        /// Takes every unique word and forms a boolean query where all words are optional.
        /// After you get this you'll use to to query your {@link IndexSearcher} for similar docs.
        /// The only caveat is the first hit returned <b>should be</b> your source document - you'll
        /// need to then ignore that.
        /// 
        /// <p>
        /// 
        /// So, if you have a code fragment like this:
        /// <br>
        /// <code>
        /// Query q = formSimilaryQuery( "I use Lucene to search fast. Fast searchers are good", new StandardAnalyzer(), "contents", null);
        /// </code>
        /// 
        /// <p>
        /// 
        /// </summary>
        /// <summary> The query returned, in string form, will be <code>'(i use lucene to search fast searchers are good')</code>.
        /// 
        /// <p>
        /// The philosophy behind this method is "two documents are similar if they share lots of words".
        /// Note that behind the scenes, Lucenes scoring algorithm will tend to give two documents a higher similarity score if the share more uncommon words.
        /// 
        /// <P>
        /// This method is fail-safe in that if a long 'body' is passed in and
        /// {@link BooleanQuery#add BooleanQuery.add()} (used internally)
        /// throws
        /// {@link org.apache.lucene.search.BooleanQuery.TooManyClauses BooleanQuery.TooManyClauses}, the
        /// query as it is will be returned.
        /// 
        /// 
        /// 
        /// 
        /// 
        /// </summary>
        /// <param name="body">the body of the document you want to find similar documents to
        /// </param>
        /// <param name="a">the analyzer to use to parse the body
        /// </param>
        /// <param name="field">the field you want to search on, probably something like "contents" or "body"
        /// </param>
        /// <param name="stop">optional set of stop words to ignore
        /// </param>
        /// <returns> a query with all unique words in 'body'
        /// </returns>
        /// <throws>  IOException this can't happen... </throws>
        public static Query FormSimilarQuery(System.String body, Analyzer a, System.String field, System.Collections.Hashtable stop)
        {
            TokenStream ts = a.TokenStream(field, new System.IO.StringReader(body));
            TermAttribute termAtt = (TermAttribute)ts.AddAttribute(typeof(TermAttribute));

            BooleanQuery tmp = new BooleanQuery();
            System.Collections.Hashtable already = new System.Collections.Hashtable(); // ignore dups
            while (ts.IncrementToken())
            {
                String word = termAtt.Term();
                // ignore opt stop words
                if (stop != null && stop.Contains(word))
                    continue;
                // ignore dups
                if (already.Contains(word) == true)
                    continue;
                already.Add(word, word);
                // add to query
                TermQuery tq = new TermQuery(new Term(field, word));
                try
                {
                    tmp.Add(tq, BooleanClause.Occur.SHOULD);
                }
                catch (BooleanQuery.TooManyClauses)
                {
                    // fail-safe, just return what we have, not the end of the world
                    break;
                }
            }
            return tmp;
        }
开发者ID:VirtueMe,项目名称:ravendb,代码行数:77,代码来源:SimilarityQueries.cs

示例12: getLocalizedTextString

		// todo - this is a pretty specialized helper function, hoist up to client code?
		public virtual String getLocalizedTextString(CultureInfo locale, Object obj)
		{
			String id = obj.GetType().FullName.Replace("$", ".");
			
			System.Collections.IDictionary parameters = new System.Collections.Hashtable();
			Type c = obj.GetType();
			
			while (c != typeof(Object))
			{
				FieldInfo[] fields = c.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Static);

				foreach (FieldInfo f in fields)
				{
					if (!f.IsPublic || f.IsStatic)
					{
						continue;
					}
					
					try
					{
						parameters[f.Name] = f.GetValue(obj);
					}
					catch (Exception)
					{
					}
				}
				c = c.BaseType;
			}
			
			String s = null;
			if ((parameters.Contains("id") && parameters["id"] != null))
			{
				String subid = parameters["id"].ToString();
				if (subid.Length > 0)
				{
					// fixme - Formalize?
					s = getLocalizedTextString(locale, id + "." + subid, parameters);
				}
			}
			if (s == null)
			{
				s = getLocalizedTextString(locale, id, parameters);
			}
			
			if (s == null)
			{
				s = id;
				
				if (parameters != null)
				{
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();

                    foreach (System.Collections.DictionaryEntry e in parameters)
					{
                        if (sb.Length > 0)
                        {
							sb.Append(", ");
                        }

						sb.Append(e.Key.ToString());
						if (e.Value != null)
						{
							sb.Append("='" + e.Value.ToString() + "'");
						}
					}
					s += "[" + sb.ToString() + "]";
				}
				return s;
			}
			
			return s;
		}
开发者ID:CamWiseOwl,项目名称:flashdevelop,代码行数:73,代码来源:LocalizationManager.cs

示例13: CalculateCachedData

		/// <summary>
		/// Internal function to set up the cached data for the fitting procedure.
		/// </summary>
		/// <param name="paraSet">The set of parameters (the information which parameters are fixed is mainly used here).</param>
		private void CalculateCachedData(ParameterSet paraSet)
		{
			// Preparation: Store the parameter names by name and index, and store
			// all parameter values in _constantParameters
			System.Collections.Hashtable paraNames = new System.Collections.Hashtable();
			System.Collections.Hashtable varyingParaNames = new System.Collections.Hashtable();

			_constantParameters = new double[paraSet.Count];
			int numberOfVaryingParameters = 0;
			for (int i = 0; i < paraSet.Count; ++i)
			{
				paraNames.Add(paraSet[i].Name, i);
				_constantParameters[i] = paraSet[i].Parameter;
				if (paraSet[i].Vary)
					++numberOfVaryingParameters;
			}
			_cachedVaryingParameters = new double[numberOfVaryingParameters];
			for (int i = 0, k = 0; i < paraSet.Count; ++i)
			{
				if (paraSet[i].Vary)
				{
					varyingParaNames.Add(paraSet[i].Name, k);
					_cachedVaryingParameters[k++] = paraSet[i].Parameter;
				}
			}

			_cachedNumberOfData = 0;
			_cachedFitElementInfo = new CachedFitElementInfo[_fitEnsemble.Count];
			for (int i = 0; i < _fitEnsemble.Count; i++)
			{
				CachedFitElementInfo info = new CachedFitElementInfo();
				_cachedFitElementInfo[i] = info;
				FitElement fitEle = _fitEnsemble[i];

				info.ValidRows = fitEle.CalculateValidNumericRows();

				info.Xs = new double[fitEle.NumberOfIndependentVariables];
				info.Parameters = new double[fitEle.NumberOfParameters];
				info.Ys = new double[fitEle.NumberOfDependentVariables];

				// Calculate the number of used variables
				int numVariablesUsed = 0;
				for (int j = 0; j < fitEle.NumberOfDependentVariables; ++j)
				{
					if (fitEle.DependentVariables(j) != null)
						++numVariablesUsed;
				}
				info.DependentVariablesInUse = new int[numVariablesUsed];
				for (int j = 0, used = 0; j < fitEle.NumberOfDependentVariables; ++j)
				{
					if (fitEle.DependentVariables(j) != null)
						info.DependentVariablesInUse[used++] = j;
				}

				// calculate the total number of data points
				_cachedNumberOfData += numVariablesUsed * info.ValidRows.Count;

				// now create the parameter mapping
				info.ParameterMapping = new int[fitEle.NumberOfParameters];

				for (int j = 0; j < info.ParameterMapping.Length; ++j)
				{
					if (!paraNames.Contains(fitEle.ParameterName(j)))
						throw new ArgumentException(string.Format("ParameterSet does not contain parameter {0}, which is used by function[{1}]", fitEle.ParameterName(j), i));

					int idx = (int)paraNames[fitEle.ParameterName(j)];
					if (paraSet[idx].Vary)
					{
						info.ParameterMapping[j] = (int)varyingParaNames[fitEle.ParameterName(j)];
					}
					else
					{
						info.ParameterMapping[j] = -idx - 1;
					}
				}
			}

			_cachedDependentValues = new double[_cachedNumberOfData];
			GetDependentValues(_cachedDependentValues);

			if (this.HasToUseWeights())
			{
				_cachedWeights = new double[_cachedNumberOfData];
				GetWeights(_cachedWeights);
			}
			else
				_cachedWeights = null;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:92,代码来源:LevMarAdapter.cs

示例14: 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;
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:33,代码来源:TestIndexFileDeleter.cs

示例15: TestNoDupCommitFileNames

		public virtual void  TestNoDupCommitFileNames()
		{
			
			Directory dir = new MockRAMDirectory();

            IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
			
			writer.SetMaxBufferedDocs(2);
			writer.AddDocument(CreateDocument("a"));
			writer.AddDocument(CreateDocument("a"));
			writer.AddDocument(CreateDocument("a"));
			writer.Close();
			
			var commits = IndexReader.ListCommits(dir);
			var it = commits.GetEnumerator();
			while (it.MoveNext())
			{
				IndexCommit commit = it.Current;
				System.Collections.Generic.ICollection<string> files = commit.FileNames;
				System.Collections.Hashtable seen = new System.Collections.Hashtable();
				System.Collections.IEnumerator it2 = files.GetEnumerator();
				while (it2.MoveNext())
				{
					System.String fileName = (System.String) it2.Current;
					Assert.IsTrue(!seen.Contains(fileName), "file " + fileName + " was duplicated");
					seen.Add(fileName, fileName);
				}
			}
			
			dir.Close();
		}
开发者ID:raol,项目名称:lucene.net,代码行数:31,代码来源:TestIndexReader.cs


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