public override void SetExpectations(System.String field, int numTerms, bool storeOffsets, bool storePositions) { currentSet = new System.Collections.Generic.SortedDictionary <object, object>(comparator); currentField = field; fieldToTerms[field] = currentSet; }
public void Build_Topology(Point[][] T) { Min = new Point(double.PositiveInfinity, double.PositiveInfinity, double.PositiveInfinity); Max = new Point(double.NegativeInfinity, double.NegativeInfinity, double.NegativeInfinity); Vertices = new SortedDictionary <ulong, SortedDictionary <ulong, Point> >(); Polys = new List <Polygon>(T.Length); //for (int i = 0; i < T.Length; i++) System.Threading.Tasks.Parallel.For(0, T.Length, i => { List <Point> VertexList = new List <Point>(); for (int p = 0; p < T[i].Length; p++) { VertexList.Add(this.AddGetIndex(T[i][p])); } if (VertexList.Count == 4) { lock (Top_Lock) Polys.Add(new Quadrilateral(ref VertexList, 0, Polys.Count)); } else if (VertexList.Count == 3) { lock (Top_Lock) Polys.Add(new Triangle(ref VertexList, 0, Polys.Count)); } else { throw new NotImplementedException("Hare Does not yet support polygons of more than 4 sides."); } }); }
// CONSTRUCTORS public Dijkstra(Graph graph) { this.graph = graph; this.openSet = new System.Collections.Generic.SortedDictionary <int, int>(); this.closedSet = new System.Collections.Generic.SortedDictionary <int, int>(); this.path = new System.Collections.Generic.List <int>(); }
private void CreateControlsSound(Vector2 controlsOrigin) { AddSeparator(controlsOrigin); Controls.Add(new MyGuiControlLabel(this, controlsOrigin + m_controlsAdded * CONTROLS_DELTA + new Vector2(0.05f, 0), null, MyTextsWrapperEnum.SoundInfluenceSphereType, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_controlsAdded++; m_selectDialogueCombobox = new MyGuiControlCombobox(this, controlsOrigin + m_controlsAdded++ *CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_LONGMEDIUM_SIZE.X / 2.0f, 0), MyGuiControlPreDefinedSize.LONGMEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 6, false, false, false); System.Collections.Generic.SortedDictionary <string, int> dialogues = new System.Collections.Generic.SortedDictionary <string, int>(); foreach (MyDialogueEnum dialogue in Enum.GetValues(typeof(MyDialogueEnum))) { dialogues.Add(dialogue.ToString(), (int)dialogue); } foreach (var dialogue in dialogues) { m_selectDialogueCombobox.AddItem(dialogue.Value, null, new StringBuilder(dialogue.Key)); } m_selectDialogueCombobox.SelectItemByIndex(0); Controls.Add(m_selectDialogueCombobox); }
public override void SetExpectations(System.String field, int numTerms, bool storeOffsets, bool storePositions) { currentSet = new System.Collections.Generic.SortedDictionary<object, object>(comparator); currentField = field; fieldToTerms[field] = currentSet; }
/// <summary> /// A simple constructor which allows the user to choose the precision. /// </summary> /// <param name="Precision">The number of significant digits the vertices will be rounded to.</param> private Topology(int Precision) { //Vertices = new List<Point>(); Max = new Point(double.MinValue, double.MinValue, double.MinValue); Min = new Point(double.MaxValue, double.MaxValue, double.MaxValue); Vertices = new SortedDictionary <ulong, SortedDictionary <ulong, Point> >(); Prec = Precision; }
static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *__ret = ILIntepreter.Minus(__esp, 0); var result_of_this_method = new System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance>(); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
public static System.Collections.Generic.SortedDictionary<string, double> ReadPositionReports(this MemoryBuffer buffer) { int length = buffer.ReadCount(); var result = new System.Collections.Generic.SortedDictionary<string, double>(); for(int index = 0; index < length; ++index) { result.Add(buffer.ReadAString(), buffer.ReadDouble()); } return result; }
public static DiscreteVariable ContinuosToDiscrete(DiscreteVariable veryBigDiscrete) { int r_1 = veryBigDiscrete.r_1; double h = veryBigDiscrete.p / r_1; // calculating new statistical table System.Collections.Generic.SortedDictionary <double, int> newStatisticalTable = new System.Collections.Generic.SortedDictionary <double, int>(); System.Collections.Generic.KeyValuePair <double, int>[] oldStatisticalTable = veryBigDiscrete.GetStatisticalTable(); double leftBorder = oldStatisticalTable.First().Key; double rightBorder = leftBorder + h; int leftIndex = 0; int rightIndex = 0; for (int i = 0; i < r_1 - 1; ++i)// for each class, except last one { // finding left and right index of element that will be summed while (oldStatisticalTable[rightIndex].Key < rightBorder) { ++rightIndex; } int sum = 0; for (int x = leftIndex; x < rightIndex; ++x) { sum += oldStatisticalTable[x].Value; } // set new value newStatisticalTable.Add((leftBorder + rightBorder) / 2, sum); leftIndex = rightIndex; leftBorder = rightBorder; rightBorder = leftBorder + h; } // calculate last class rightBorder = oldStatisticalTable.Last().Key; int lastSum = 0; for (int x = leftIndex; x < oldStatisticalTable.Length; ++x) { lastSum += oldStatisticalTable[x].Value; } // set new value newStatisticalTable.Add((leftBorder + rightBorder) / 2, lastSum); // new discrete variable has been created DiscreteVariable dv = new DiscreteVariable(newStatisticalTable); if (dv.Size != veryBigDiscrete.Size) { throw new System.ArgumentException("Some elements has been lost"); } return(dv); }
/// <summary> /// Resolves a schema-complete address for a usable host. /// </summary> /// <exception cref="URLError"> /// Thrown if resolution fails. /// </exception> public string GetHost() { if(this.srv){ System.Collections.Generic.IDictionary<uint, System.Collections.Generic.IList<Heijden.DNS.RecordSRV>> candidates = new System.Collections.Generic.SortedDictionary<uint, System.Collections.Generic.IList<Heijden.DNS.RecordSRV>>(); try{ foreach(Heijden.DNS.AnswerRR response in new Heijden.DNS.Resolver().Query(this.host, Heijden.DNS.QType.SRV).Answers){ Heijden.DNS.RecordSRV record = (Heijden.DNS.RecordSRV)response.RECORD; System.Collections.Generic.IList<Heijden.DNS.RecordSRV> container; if(candidates.ContainsKey(record.PRIORITY)){ container = candidates[record.PRIORITY]; }else{ container = new System.Collections.Generic.List<Heijden.DNS.RecordSRV>(); candidates.Add(record.PRIORITY, container); } container.Add(record); } }catch(System.Exception e){ throw new MediaStorage.Exceptions.URLError("Unable to resolve SRV record: " + e.Message); } foreach(System.Collections.Generic.KeyValuePair<uint, System.Collections.Generic.IList<Heijden.DNS.RecordSRV>> c in candidates){ while(c.Value.Count > 0){ uint weight_total = 0; foreach(Heijden.DNS.RecordSRV option in c.Value){ weight_total += option.WEIGHT; } uint selection = (uint)((new System.Random()).NextDouble() * weight_total); Heijden.DNS.RecordSRV choice = null; foreach(Heijden.DNS.RecordSRV option in c.Value){ selection -= option.WEIGHT; if(selection <= 0){ choice = option; break; } } if(choice == null){ //Should never happen, but C# is a mystery I don't care to understand. break; } string address = this.Assemble(choice.TARGET, choice.PORT, this.ssl); try{ System.Net.HttpWebRequest request = Libraries.Communication.AssembleRequest(address + Libraries.Communication.SERVER_PING, new System.Collections.Generic.Dictionary<string, object>()); Libraries.Communication.SendRequest(request, timeout:1).ToDictionary(); return address; }catch(System.Exception){ c.Value.Remove(choice); } } } throw new MediaStorage.Exceptions.URLError("Unable to resolve a viable server via SRV lookup"); }else{ return this.Assemble(this.host, this.port, this.ssl); } }
// Use this for initialization void Start() { Debug.Log("QRCodesVisualizer start"); qrCodesObjectsList = new SortedDictionary <System.Guid, GameObject>(); QRCodesManager.Instance.QRCodesTrackingStateChanged += Instance_QRCodesTrackingStateChanged; QRCodesManager.Instance.QRCodeAdded += Instance_QRCodeAdded; QRCodesManager.Instance.QRCodeUpdated += Instance_QRCodeUpdated; QRCodesManager.Instance.QRCodeRemoved += Instance_QRCodeRemoved; if (qrCodePrefab == null) { throw new System.Exception("Prefab not assigned"); } }
public static System.Collections.Generic.Dictionary <int, int> GetAllProcessParentPids() { var childPidToParentPid = new System.Collections.Generic.Dictionary <int, int>(); var processCounters = new System.Collections.Generic.SortedDictionary <string, System.Diagnostics.PerformanceCounter[]>(); var category = new System.Diagnostics.PerformanceCounterCategory("Process"); // As the base system always has more than one process running, // don't special case a single instance return. var instanceNames = category.GetInstanceNames(); foreach (string t in instanceNames) { try { processCounters[t] = category.GetCounters(t); } catch (System.InvalidOperationException) { // Transient processes may no longer exist between // GetInstanceNames and when the counters are queried. } } foreach (var kvp in processCounters) { int childPid = -1; int parentPid = -1; foreach (var counter in kvp.Value) { if ("ID Process".CompareTo(counter.CounterName) == 0) { childPid = (int)(counter.NextValue()); } else if ("Creating Process ID".CompareTo(counter.CounterName) == 0) { parentPid = (int)(counter.NextValue()); } } if (childPid != -1 && parentPid != -1) { childPidToParentPid[childPid] = parentPid; } } return(childPidToParentPid); } // End Function GetAllProcessParentPids
public void TestUpdatePriorityValues() { System.Collections.Generic.Dictionary <int, int> orig_d = ENGINEERINGDataSet.get_priority_values_inner(422); System.Collections.Generic.Dictionary <int, int> d = new System.Collections.Generic.Dictionary <int, int>(); d.Add(16, 3); d.Add(6, 3); d.Add(5, 3); ENGINEERINGDataSet.update_priority_values(422, d); System.Collections.Generic.Dictionary <int, int> dd = ENGINEERINGDataSet.get_priority_values_inner(422); System.Collections.Generic.SortedDictionary <int, int> sorig_d = new System.Collections.Generic.SortedDictionary <int, int>(orig_d); System.Collections.Generic.SortedDictionary <int, int> sdd = new System.Collections.Generic.SortedDictionary <int, int>(dd); System.Collections.Generic.SortedDictionary <int, int> sd = new System.Collections.Generic.SortedDictionary <int, int>(d); Assert.IsTrue(sorig_d != sdd); Assert.IsTrue(sd.Equals(sdd)); }
static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject *ptr_of_this_method, IList <object> __mStack, ref System.Collections.Generic.SortedDictionary <System.Int64, System.Collections.Generic.List <ILRuntime.Runtime.Intepreter.ILTypeInstance> > .Enumerator instance_of_this_method) { ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); switch (ptr_of_this_method->ObjectType) { case ObjectTypes.Object: { __mStack[ptr_of_this_method->Value] = instance_of_this_method; } break; case ObjectTypes.FieldReference: { var ___obj = __mStack[ptr_of_this_method->Value]; if (___obj is ILTypeInstance) { ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { var t = __domain.GetType(___obj.GetType()) as CLRType; t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method); } } break; case ObjectTypes.StaticFieldReference: { var t = __domain.GetType(ptr_of_this_method->Value); if (t is ILType) { ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method); } } break; case ObjectTypes.ArrayReference: { var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Collections.Generic.SortedDictionary <System.Int64, System.Collections.Generic.List <ILRuntime.Runtime.Intepreter.ILTypeInstance> > .Enumerator[]; instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method; } break; } }
public override bool Update() { if (m_rowIndex != null) { return(false); } vc.viewTable.ComputeRowCount(); long rowCount = vc.viewTable.GetRowCount(); if (rowCount >= 0) { m_index = null; m_rowIndex = vc.select.GetIndexFirstMatches(0, rowCount); } return(true); }
public static System.Tuple <int, float>[][] CalculateAveragePrices(int[] counts, int[][] values, CheckList <int> exceptValues) { var valueArray = new System.Collections.Generic.SortedDictionary <int, int> [counts.Length]; for (int i = 0; i < counts.Length; i++) { valueArray[i] = new System.Collections.Generic.SortedDictionary <int, int>(); } int ncount = 0; for (int j = 0; j < values.Length; j++) { if (exceptValues.Contains(j)) { continue; } for (int i = 0; i < valueArray.Length; i++) { int value = values[j][i]; int count = 0; valueArray[i].TryGetValue(value, out count); valueArray[i][value] = count + 1; } ncount++; } System.Tuple <int, float>[][] result = new System.Tuple <int, float> [counts.Length][]; for (int i = 0; i < counts.Length; i++) { result[i] = new System.Tuple <int, float> [valueArray[i].Count]; int count = 0; foreach (var pair in valueArray[i]) { result[i][count] = new System.Tuple <int, float>(pair.Key, pair.Value / (float)ncount); count++; } } return(result); }
public System.Collections.Generic.SortedDictionary <decimal, table_row> GroupByDecimal(T ur_col) { var ret_table = new System.Collections.Generic.SortedDictionary <decimal, table_row>(); foreach (var row_entry in this) { var key_val = row_entry.GetDecimal(ur_col); if (ret_table.ContainsKey(key_val) == false) { ret_table.Add(key_val, new table_row()); } ret_table[key_val].Add(row_entry); } return(ret_table); }
// CONSTRUCTORS public AffineCipher(Classes.Alphabet alphabet, int a, int b) { this.a = a; this.b = b; this.m = alphabet.Lenght; int gcd = Math.Algorithms.GCD(a, m); if (gcd != 1) { throw new System.ArgumentException(string.Format("Numbers \"A\" and \"M\" must be relatively simple\n A: {0} M: {1} GCD: {2}" , a, m, gcd)); } this.letterCipherTable = new System.Collections.Generic.SortedDictionary <char, char>(); this.alphabet = alphabet; this.CreateLetterCipherTable(); }
public void ISortedPartialFunction_Test() { var reference = new System.Collections.Generic.SortedDictionary <string, int>(); var f = Common.Container.GetInstance <ISortedPartialFunction <string, int> >(); var sentence = @"A man a plan a canal panama. That is a palindrome. Blah, donkey's are fun like myopic squid. blah what carl mike time john, 845 the apricot is not an orange, it is an orange not it is the other indeed"; var words = sentence.Split(' '); foreach (var w in words) { f.Add(w, w.Length); reference[w] = w.Length; } Assert.AreEqual(f.Count(), reference.Count); f.Remove("palindrome."); reference.Remove("palindrome."); Assert.AreEqual(f.Count(), reference.Count); int xc; Assert.IsFalse(f.TryApply("palindrome.", out xc)); foreach (var w in words) { int c; var found = f.TryApply(w, out c); Assert.IsTrue(w == "palindrome." || found); if (w != "palindrome.") { Assert.AreEqual(c, w.Length); } } Assert.AreEqual(f.Count(), reference.Count); var rr = string.Join(";", reference.Select(kvp => kvp.Key)); var uu = string.Join(";", f.EnumerateSorted().Select(kvp => kvp.Item1)); Assert.AreEqual(rr, uu); }
public static ComparableComparator GetComparator(Type ta, Type tb) { if (ta == tb) { return(comparableComparatorIdentity); } if (comparableComparators == null) { comparableComparators = new System.Collections.Generic.SortedDictionary <TypePair, ComparableComparator>(); var identity = comparableComparatorIdentity; comparableComparators.Add(new TypePair(typeof(int), typeof(string)), (IComparable a, IComparable b) => a.CompareTo(PromoteToInt((string)b))); comparableComparators.Add(new TypePair(typeof(float), typeof(string)), (IComparable a, IComparable b) => a.CompareTo(PromoteToFloat((string)b))); comparableComparators.Add(new TypePair(typeof(long), typeof(string)), (IComparable a, IComparable b) => a.CompareTo(PromoteToLong((string)b))); comparableComparators.Add(new TypePair(typeof(bool), typeof(string)), (IComparable a, IComparable b) => a.CompareTo(PromoteToBool((string)b))); comparableComparators.Add(new TypePair(typeof(string), typeof(int)), (IComparable a, IComparable b) => PromoteToInt((string)b).CompareTo(a)); comparableComparators.Add(new TypePair(typeof(string), typeof(float)), (IComparable a, IComparable b) => PromoteToFloat((string)b).CompareTo(a)); comparableComparators.Add(new TypePair(typeof(string), typeof(long)), (IComparable a, IComparable b) => PromoteToLong((string)b).CompareTo(a)); comparableComparators.Add(new TypePair(typeof(string), typeof(bool)), (IComparable a, IComparable b) => PromoteToBool((string)b).CompareTo(a)); comparableComparators.Add(new TypePair(typeof(int), typeof(float)), (IComparable a, IComparable b) => ((float)(int)a).CompareTo(b)); comparableComparators.Add(new TypePair(typeof(long), typeof(float)), (IComparable a, IComparable b) => ((float)(long)a).CompareTo(b)); comparableComparators.Add(new TypePair(typeof(bool), typeof(float)), (IComparable a, IComparable b) => ((bool)a).CompareTo(((float)b) != 0.0f)); comparableComparators.Add(new TypePair(typeof(int), typeof(long)), (IComparable a, IComparable b) => ((long)(int)a).CompareTo(b)); comparableComparators.Add(new TypePair(typeof(int), typeof(bool)), (IComparable a, IComparable b) => (((int)a) != 0).CompareTo(b)); comparableComparators.Add(new TypePair(typeof(long), typeof(int)), (IComparable a, IComparable b) => a.CompareTo((long)(int)b)); comparableComparators.Add(new TypePair(typeof(long), typeof(bool)), (IComparable a, IComparable b) => (((long)a) != 0).CompareTo(b)); comparableComparators.Add(new TypePair(typeof(bool), typeof(int)), (IComparable a, IComparable b) => a.CompareTo((int)b != 0)); comparableComparators.Add(new TypePair(typeof(bool), typeof(long)), (IComparable a, IComparable b) => a.CompareTo((long)b != 0)); } ComparableComparator o; if (comparableComparators.TryGetValue(new TypePair(ta, tb), out o)) { return(o); } return(comparableComparatorIdentity); }
internal static void MainFunction() { var windowArgs = new WindowArgs() { Title = "TestKeyEvents" }; window = new Window(windowArgs); window.SetKeyEventHandler(KeyHandler); // test some sorted collections test = new System.Collections.Generic.SortedDictionary <int, string>(); ran = new System.Random(); while (window.IsRunning()) { window.PollEvents(); window.Clear(); window.SwapBuffers(); } }
static void FindTeamAffiliations(string input) { // key=team // value=list of countries that support this team System.Collections.Generic.SortedDictionary<int, System.Collections.Generic.SortedSet<int>> teamSupporters = new System.Collections.Generic.SortedDictionary<int, System.Collections.Generic.SortedSet<int>>(); string[] teamsSupportedByCountries = input.Split(new char[] { '|' }, System.StringSplitOptions.RemoveEmptyEntries); int countryId = 0; foreach( string teamsSupportedByThisCountryString in teamsSupportedByCountries) { countryId++; string[] teamsSupportedByThisCountry = teamsSupportedByThisCountryString.Split(new char[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries); foreach( string teamSupportedByThisCountry in teamsSupportedByThisCountry) { int teamId = System.Int32.Parse(teamSupportedByThisCountry); if (!teamSupporters.ContainsKey(teamId)) { teamSupporters.Add(teamId, new System.Collections.Generic.SortedSet<int>()); } teamSupporters[teamId].Add(countryId); } } System.Collections.Generic.List<string> output = new System.Collections.Generic.List<string>(); foreach( int teamId in teamSupporters.Keys ) { System.Collections.Generic.SortedSet<int> countriesThatSupportTeam = teamSupporters[teamId]; int[] countryList = new int[countriesThatSupportTeam.Count]; countriesThatSupportTeam.CopyTo(countryList); output.Add(teamId + ":" + string.Join(",", countryList) + ";"); } System.Console.WriteLine(string.Join(" ", output.ToArray())); }
public virtual void test() { System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>(); System.Collections.Generic.ICollection <string> collection = list; System.Collections.Generic.HashSet <int> hashSet = new System.Collections.Generic.HashSet <int>(); java.util.TreeSet <int> treeSet = new java.util.TreeSet <int>(); System.Collections.Generic.HashSet <int> set = hashSet; System.Collections.Generic.Dictionary <int, string> hashMap = new System.Collections.Generic.Dictionary <int, string>(); System.Collections.Generic.SortedDictionary <int, string> treeMap = new System.Collections.Generic.SortedDictionary <int, string>(); System.Collections.Generic.IDictionary <int, string> map = hashMap; (list.Count == 0); (collection.Count == 0); (hashSet.Count == 0); (treeSet.Count == 0); (set.Count == 0); (hashMap.Count == 0); (treeMap.Count == 0); (map.Count == 0); }
public SortedTermVectorMapper(bool ignoringPositions, bool ignoringOffsets, System.Collections.Generic.IComparer <System.Object> comparator) : base(ignoringPositions, ignoringOffsets) { currentSet = new System.Collections.Generic.SortedDictionary <System.Object, System.Object>(comparator); }
static StackObject *MoveNext_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> .ValueCollection.Enumerator instance_of_this_method = (System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> .ValueCollection.Enumerator) typeof(System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> .ValueCollection.Enumerator).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 16); var result_of_this_method = instance_of_this_method.MoveNext(); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); __intp.Free(ptr_of_this_method); __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method ? 1 : 0; return(__ret + 1); }
// Remaps all buffered deletes based on a completed // merge internal virtual void Remap(MergeDocIDRemapper mapper, SegmentInfos infos, int[][] docMaps, int[] delCounts, MergePolicy.OneMerge merge, int mergeDocCount) { lock (this) { System.Collections.IDictionary newDeleteTerms; // Remap delete-by-term if (terms.Count > 0) { if (doTermSort) { newDeleteTerms = new System.Collections.Generic.SortedDictionary<object, object>(); } else { newDeleteTerms = new System.Collections.Hashtable(); } System.Collections.IEnumerator iter = new System.Collections.Hashtable(terms).GetEnumerator(); while (iter.MoveNext()) { System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry) iter.Current; Num num = (Num) entry.Value; newDeleteTerms[entry.Key] = new Num(mapper.Remap(num.GetNum())); } } else newDeleteTerms = null; // Remap delete-by-docID System.Collections.ArrayList newDeleteDocIDs; if (docIDs.Count > 0) { newDeleteDocIDs = new System.Collections.ArrayList(docIDs.Count); System.Collections.IEnumerator iter = docIDs.GetEnumerator(); while (iter.MoveNext()) { System.Int32 num = (System.Int32) iter.Current; newDeleteDocIDs.Add((System.Int32) mapper.Remap(num)); } } else newDeleteDocIDs = null; // Remap delete-by-query System.Collections.Hashtable newDeleteQueries; if (queries.Count > 0) { newDeleteQueries = new System.Collections.Hashtable(queries.Count); System.Collections.IEnumerator iter = new System.Collections.Hashtable(queries).GetEnumerator(); while (iter.MoveNext()) { System.Collections.DictionaryEntry entry = (System.Collections.DictionaryEntry) iter.Current; System.Int32 num = (System.Int32) entry.Value; newDeleteQueries[entry.Key] = (System.Int32) mapper.Remap(num); } } else newDeleteQueries = null; if (newDeleteTerms != null) terms = newDeleteTerms; if (newDeleteDocIDs != null) docIDs = newDeleteDocIDs; if (newDeleteQueries != null) queries = newDeleteQueries; } }
public FilterCleaner(FilterManager enclosingInstance) { InitBlock(enclosingInstance); sortedFilterItems = new System.Collections.Generic.SortedDictionary <object, object>(new AnonymousClassComparator(this)); }
public override void OnInspectorGUI() { var style = new GUIStyle(EditorStyles.toolbar); style.fixedHeight = 0f; style.stretchHeight = true; var backStyle = new GUIStyle(EditorStyles.label); backStyle.normal.background = Texture2D.whiteTexture; var dataConfig = (ME.ECS.DataConfigs.DataConfig) this.target; if (DataConfigEditor.worldEditors.TryGetValue(this.target, out var worldEditor) == false) { worldEditor = new WorldsViewerEditor.WorldEditor(); DataConfigEditor.worldEditors.Add(this.target, worldEditor); } GUILayoutExt.Padding(8f, () => { var usedComponents = new System.Collections.Generic.HashSet <System.Type>(); var kz = 0; var registries = dataConfig.structComponents; var sortedRegistries = new System.Collections.Generic.SortedDictionary <int, Registry>(new WorldsViewerEditor.DuplicateKeyComparer <int>()); for (int i = 0; i < registries.Length; ++i) { var registry = registries[i]; if (registry == null) { continue; } var component = registry; usedComponents.Add(component.GetType()); var editor = WorldsViewerEditor.GetEditor(component, out var order); if (editor != null) { sortedRegistries.Add(order, new Registry() { index = i, data = component }); } else { sortedRegistries.Add(0, new Registry() { index = i, data = component }); } } foreach (var registryKv in sortedRegistries) { var registry = registryKv.Value; var component = registry.data; var backColor = GUI.backgroundColor; GUI.backgroundColor = new Color(1f, 1f, 1f, kz++ % 2 == 0 ? 0f : 0.05f); GUILayout.BeginVertical(backStyle); { GUI.backgroundColor = backColor; var editor = WorldsViewerEditor.GetEditor(component); if (editor != null) { EditorGUI.BeginChangeCheck(); editor.OnDrawGUI(); if (EditorGUI.EndChangeCheck() == true) { component = editor.GetTarget <IStructComponent>(); dataConfig.structComponents[registry.index] = component; } } else { var componentName = component.GetType().Name; var fieldsCount = GUILayoutExt.GetFieldsCount(component); if (fieldsCount == 0) { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.Toggle(componentName, true); EditorGUI.EndDisabledGroup(); } else if (fieldsCount == 1) { var changed = GUILayoutExt.DrawFields(worldEditor, component, componentName); if (changed == true) { dataConfig.structComponents[registry.index] = component; } } else { GUILayout.BeginHorizontal(); { GUILayout.Space(18f); GUILayout.BeginVertical(); { var key = "ME.ECS.WorldsViewerEditor.FoldoutTypes." + component.GetType().FullName; var foldout = EditorPrefs.GetBool(key, true); GUILayoutExt.FoldOut(ref foldout, componentName, () => { var changed = GUILayoutExt.DrawFields(worldEditor, component); if (changed == true) { dataConfig.structComponents[registry.index] = component; } }); EditorPrefs.SetBool(key, foldout); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } } } GUILayout.EndVertical(); GUILayoutExt.Separator(); } GUILayoutExt.DrawAddComponentMenu(usedComponents, (addType, isUsed) => { if (isUsed == true) { usedComponents.Remove(addType); for (int i = 0; i < dataConfig.structComponents.Length; ++i) { if (dataConfig.structComponents[i].GetType() == addType) { var list = dataConfig.structComponents.ToList(); list.RemoveAt(i); dataConfig.structComponents = list.ToArray(); dataConfig.OnScriptLoad(); break; } } } else { usedComponents.Add(addType); System.Array.Resize(ref dataConfig.structComponents, dataConfig.structComponents.Length + 1); dataConfig.structComponents[dataConfig.structComponents.Length - 1] = (IStructComponent)System.Activator.CreateInstance(addType); dataConfig.OnScriptLoad(); } }); }); GUILayoutExt.Padding(8f, () => { var usedComponents = new System.Collections.Generic.HashSet <System.Type>(); var kz = 0; var registries = dataConfig.components; var sortedRegistries = new System.Collections.Generic.SortedDictionary <int, RegistryComponent>(new WorldsViewerEditor.DuplicateKeyComparer <int>()); for (int i = 0; i < registries.Length; ++i) { var registry = registries[i]; if (registry == null) { continue; } var component = registry; usedComponents.Add(component.GetType()); var editor = WorldsViewerEditor.GetEditor(component, out var order); if (editor != null) { sortedRegistries.Add(order, new RegistryComponent() { index = i, data = component }); } else { sortedRegistries.Add(0, new RegistryComponent() { index = i, data = component }); } } foreach (var registryKv in sortedRegistries) { var registry = registryKv.Value; var component = registry.data; var backColor = GUI.backgroundColor; GUI.backgroundColor = new Color(1f, 1f, 1f, kz++ % 2 == 0 ? 0f : 0.05f); GUILayout.BeginVertical(backStyle); { GUI.backgroundColor = backColor; var editor = WorldsViewerEditor.GetEditor(component); if (editor != null) { EditorGUI.BeginChangeCheck(); editor.OnDrawGUI(); if (EditorGUI.EndChangeCheck() == true) { component = editor.GetTarget <IComponent>(); dataConfig.components[registry.index] = component; } } else { var componentName = component.GetType().Name; var fieldsCount = GUILayoutExt.GetFieldsCount(component); if (fieldsCount == 0) { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.Toggle(componentName, true); EditorGUI.EndDisabledGroup(); } else if (fieldsCount == 1) { var changed = GUILayoutExt.DrawFields(worldEditor, component, componentName); if (changed == true) { dataConfig.components[registry.index] = component; } } else { GUILayout.BeginHorizontal(); { GUILayout.Space(18f); GUILayout.BeginVertical(); { var key = "ME.ECS.WorldsViewerEditor.FoldoutTypes." + component.GetType().FullName; var foldout = EditorPrefs.GetBool(key, true); GUILayoutExt.FoldOut(ref foldout, componentName, () => { var changed = GUILayoutExt.DrawFields(worldEditor, component); if (changed == true) { dataConfig.components[registry.index] = component; } }); EditorPrefs.SetBool(key, foldout); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } } } GUILayout.EndVertical(); GUILayoutExt.Separator(); } GUILayoutExt.DrawAddComponentMenu(usedComponents, (addType, isUsed) => { if (isUsed == true) { usedComponents.Remove(addType); for (int i = 0; i < dataConfig.components.Length; ++i) { if (dataConfig.components[i].GetType() == addType) { var list = dataConfig.components.ToList(); list.RemoveAt(i); dataConfig.components = list.ToArray(); dataConfig.OnScriptLoad(); break; } } } else { usedComponents.Add(addType); System.Array.Resize(ref dataConfig.components, dataConfig.components.Length + 1); dataConfig.components[dataConfig.components.Length - 1] = (IComponent)System.Activator.CreateInstance(addType); dataConfig.OnScriptLoad(); } }, drawRefComponents: true); }); }
private void CreateControlsSound(Vector2 controlsOrigin) { AddSeparator(controlsOrigin); Controls.Add(new MyGuiControlLabel(this, controlsOrigin + m_controlsAdded * CONTROLS_DELTA + new Vector2(0.05f, 0), null, MyTextsWrapperEnum.SoundInfluenceSphereType, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_controlsAdded++; m_selectDialogueCombobox = new MyGuiControlCombobox(this, controlsOrigin + m_controlsAdded++ * CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_LONGMEDIUM_SIZE.X / 2.0f, 0), MyGuiControlPreDefinedSize.LONGMEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 6, false, false, false); System.Collections.Generic.SortedDictionary<string, int> dialogues = new System.Collections.Generic.SortedDictionary<string, int>(); foreach (MyDialogueEnum dialogue in Enum.GetValues(typeof(MyDialogueEnum))) { dialogues.Add(dialogue.ToString(), (int)dialogue); } foreach (var dialogue in dialogues) { m_selectDialogueCombobox.AddItem(dialogue.Value, null, new StringBuilder(dialogue.Key)); } m_selectDialogueCombobox.SelectItemByIndex(0); Controls.Add(m_selectDialogueCombobox); }
static StackObject *GetEnumerator_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> .ValueCollection instance_of_this_method = (System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> .ValueCollection) typeof(System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> .ValueCollection).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.GetEnumerator(); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
} // end of SetObjectData #endregion static LineCapEx() { _defaultStyle = new DefaultLineCapWrapper(); _registeredStyles = new System.Collections.Generic.SortedDictionary<string, LineCapExtension>(); // first register the predefined styles foreach (LineCap cap in Enum.GetValues(typeof(LineCap))) { if (cap == LineCap.Custom) { continue; } if(cap==LineCap.Flat) { _registeredStyles.Add(_defaultStyle.Name,_defaultStyle); } else { LineCapExtension ex = new KnownLineCapWrapper(cap); _registeredStyles.Add(ex.Name,ex); } } // now the other linecaps LineCapExtension more; more = new LineCaps.ArrowF10LineCap(); _registeredStyles.Add(more.Name, more); more = new LineCaps.ArrowF20LineCap(); _registeredStyles.Add(more.Name, more); more = new LineCaps.LeftBarLineCap(); _registeredStyles.Add(more.Name, more); more = new LineCaps.RightBarLineCap(); _registeredStyles.Add(more.Name, more); more = new LineCaps.SymBarLineCap(); _registeredStyles.Add(more.Name, more); }
static StackObject *get_Count_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Collections.Generic.SortedDictionary <System.Int64, System.Collections.Generic.List <System.Int64> > instance_of_this_method = (System.Collections.Generic.SortedDictionary <System.Int64, System.Collections.Generic.List <System.Int64> >) typeof(System.Collections.Generic.SortedDictionary <System.Int64, System.Collections.Generic.List <System.Int64> >).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.Count; __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method; return(__ret + 1); }
static StackObject *TryGetValue_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 3); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> @value = (System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance>) typeof(System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Int32 @key = ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 3); System.Collections.Generic.Dictionary <System.Int32, System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> > instance_of_this_method = (System.Collections.Generic.Dictionary <System.Int32, System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> >) typeof(System.Collections.Generic.Dictionary <System.Int32, System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> >).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); var result_of_this_method = instance_of_this_method.TryGetValue(@key, out @value); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); switch (ptr_of_this_method->ObjectType) { case ObjectTypes.StackObjectReference: { var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method); object ___obj = @value; if (___dst->ObjectType >= ObjectTypes.Object) { if (___obj is CrossBindingAdaptorType) { ___obj = ((CrossBindingAdaptorType)___obj).ILInstance; } __mStack[___dst->Value] = ___obj; } else { ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain); } } break; case ObjectTypes.FieldReference: { var ___obj = __mStack[ptr_of_this_method->Value]; if (___obj is ILTypeInstance) { ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @value; } else { var ___type = __domain.GetType(___obj.GetType()) as CLRType; ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @value); } } break; case ObjectTypes.StaticFieldReference: { var ___type = __domain.GetType(ptr_of_this_method->Value); if (___type is ILType) { ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @value; } else { ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @value); } } break; case ObjectTypes.ArrayReference: { var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance>[]; instance_of_arrayReference[ptr_of_this_method->ValueLow] = @value; } break; } __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); __intp.Free(ptr_of_this_method); __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method ? 1 : 0; return(__ret + 1); }
static StackObject *Add_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 3); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> @value = (System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance>) typeof(System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Int32 @key = ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 3); System.Collections.Generic.Dictionary <System.Int32, System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> > instance_of_this_method = (System.Collections.Generic.Dictionary <System.Int32, System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> >) typeof(System.Collections.Generic.Dictionary <System.Int32, System.Collections.Generic.SortedDictionary <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> >).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); instance_of_this_method.Add(@key, @value); return(__ret); }
//Displays Course history, Course Selections and Guidance Messages protected void DisplayCourseData(DataTable dtbPlannerData, DataTable dtbSubmitMessages) { string sRowStyle = ""; Int16 iMsgCounter = 0; Int16 iMsgCreditRecovery = 0; //Hashtable htbMessages = new Hashtable(); System.Collections.Generic.SortedDictionary<int, string> htbMessages = new System.Collections.Generic.SortedDictionary<int, string>(); iMsgCounter = 0; //Re-initialize foreach (DataRow drRow in dtbPlannerData.Rows) { sRowStyle = (sRowStyle == "") ? "class='DarkRow'" : ""; //History Courses if (drRow["CType"].ToString() == "Taken" && intShowHistoryOnSignOff == 1) { sbrHistory.Append("<tr " + sRowStyle + ">"); sbrHistory.Append("<td>" + drRow["CourseCode"].ToString() + "</td>"); sbrHistory.Append("<td>" + drRow["CourseName"].ToString() + " </td>"); sbrHistory.Append("<td align='center'>" + (drRow["GradeMark"] != DBNull.Value ? drRow["GradeMark"].ToString() : "-") + "</td>"); sbrHistory.Append("<td>" + ((DateTime)drRow["CourseCompletedDate"]).ToString("MM/yy") + "</td></tr>"); } //Current year's Course Selection if (drRow["CType"].ToString() == "Planned" && Convert.ToInt32(drRow["GradeColumn"]) == Convert.ToInt32(CPStudentInfo["GradeNumber"]) + 1) { sbrSelection.Append("<tr " + sRowStyle + ">"); sbrSelection.Append("<td><b>" + drRow["CourseCode"].ToString() + "</b></td>"); sbrSelection.Append("<td>" + drRow["CourseName"].ToString() + "</td>"); if (drRow["AlertType"] != DBNull.Value || drRow["CourseExportType"].ToString()=="3") { iMsgCounter += 1; htbMessages.Add(iMsgCounter, drRow["ID"].ToString()); sbrSelection.Append("<td align='center'><b>" + iMsgCounter.ToString() + "</b></td>"); if (drRow["CourseExportType"].ToString() == "3") iMsgCreditRecovery = iMsgCounter; } else { sbrSelection.Append("<td> </td>"); } if (drRow["AlternateId"] != DBNull.Value) { sbrSelection.Append("<td>" + drRow["AlternateCode"].ToString() + " - " + drRow["AlternateName"].ToString() + "</td>"); } else if (Convert.ToInt16(drRow["CourseExportType"]) == 2) sbrSelection.Append("<td><b>X</b></td>"); else { sbrSelection.Append("<td> </td>"); } } } //Load Alerts for courses IDictionaryEnumerator enumerator = htbMessages.GetEnumerator(); while(enumerator.MoveNext()) { foreach (DataRow drRow in dtbSubmitMessages.Rows) { if (drRow["ID"] != DBNull.Value) { if (enumerator.Value.ToString() == drRow["ID"].ToString()) { sbrMessages.Append("<tr " + sRowStyle + "><td valign='top' style='font-weight: bold; font-size: 12px;'>" + enumerator.Key.ToString() + "</td><td>" + drRow["MessageText"].ToString() + "</td></tr>"); } } } } #region Credit Recovery Message /*strSQL = "DECLARE @strTemp VARCHAR(2000);SET @strTemp = dbo.CP_GetWarningFromType(" + strSchoolID + ",154,'" + strUserLang.ToString() + "');SELECT @strTemp"; string strCreditRecoveryMsg = CareerCruisingWeb.CCLib.Common.DataAccess.GetValue(strSQL).ToString(); DataView dvCreditRecovery = dtbPlannerData.DefaultView; dvCreditRecovery.RowFilter = "CourseExportType=3"; DataTable dt = dvCreditRecovery.ToTable(); foreach (DataRow drRow in dt.Rows) { sbrMessages.Append("<tr " + sRowStyle + "><td valign='top' style='font-weight: bold; font-size: 12px;'>" + iMsgCreditRecovery.ToString() + "</td><td>" + strCreditRecoveryMsg + "</td></tr>"); }*/ #endregion //Load generic alerts not assigned to any course foreach (DataRow drRow in dtbSubmitMessages.Rows) { sRowStyle = (sRowStyle == "") ? "class='DarkRow'" : ""; if (drRow["ID"] == DBNull.Value ) { iMsgCounter += 1; sbrMessages.Append("<tr " + sRowStyle + "><td valign='top' style='font-weight: bold; font-size: 12px;'>" + iMsgCounter.ToString() + "</td><td>" + drRow["MessageText"].ToString() + " " + Strings.GenerateLanguageText(Convert.ToInt32(drRow["CourseCode"]),strLanguage, "0") + "</td></tr>"); } } }
public SortedTermVectorMapper(bool ignoringPositions, bool ignoringOffsets, System.Collections.Generic.IComparer<System.Object> comparator):base(ignoringPositions, ignoringOffsets) { currentSet = new System.Collections.Generic.SortedDictionary<System.Object, System.Object>(comparator); }
public virtual void TestKnownSetOfDocuments() { System.String test1 = "eating chocolate in a computer lab"; //6 terms System.String test2 = "computer in a computer lab"; //5 terms System.String test3 = "a chocolate lab grows old"; //5 terms System.String test4 = "eating chocolate with a chocolate lab in an old chocolate colored computer lab"; //13 terms System.Collections.IDictionary test4Map = new System.Collections.Hashtable(); test4Map["chocolate"] = 3; test4Map["lab"] = 2; test4Map["eating"] = 1; test4Map["computer"] = 1; test4Map["with"] = 1; test4Map["a"] = 1; test4Map["colored"] = 1; test4Map["in"] = 1; test4Map["an"] = 1; test4Map["computer"] = 1; test4Map["old"] = 1; Document testDoc1 = new Document(); SetupDoc(testDoc1, test1); Document testDoc2 = new Document(); SetupDoc(testDoc2, test2); Document testDoc3 = new Document(); SetupDoc(testDoc3, test3); Document testDoc4 = new Document(); SetupDoc(testDoc4, test4); Directory dir = new MockRAMDirectory(); try { IndexWriter writer = new IndexWriter(dir, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); Assert.IsTrue(writer != null); writer.AddDocument(testDoc1); writer.AddDocument(testDoc2); writer.AddDocument(testDoc3); writer.AddDocument(testDoc4); writer.Close(); IndexSearcher knownSearcher = new IndexSearcher(dir); TermEnum termEnum = knownSearcher.reader_ForNUnit.Terms(); TermDocs termDocs = knownSearcher.reader_ForNUnit.TermDocs(); //System.out.println("Terms: " + termEnum.size() + " Orig Len: " + termArray.length); Similarity sim = knownSearcher.GetSimilarity(); while (termEnum.Next() == true) { Term term = termEnum.Term(); //System.out.println("Term: " + term); termDocs.Seek(term); while (termDocs.Next()) { int docId = termDocs.Doc(); int freq = termDocs.Freq(); //System.out.println("Doc Id: " + docId + " freq " + freq); TermFreqVector vector = knownSearcher.reader_ForNUnit.GetTermFreqVector(docId, "field"); float tf = sim.Tf(freq); float idf = sim.Idf(term, knownSearcher); //float qNorm = sim.queryNorm() //This is fine since we don't have stop words float lNorm = sim.LengthNorm("field", vector.GetTerms().Length); //float coord = sim.coord() //System.out.println("TF: " + tf + " IDF: " + idf + " LenNorm: " + lNorm); Assert.IsTrue(vector != null); System.String[] vTerms = vector.GetTerms(); int[] freqs = vector.GetTermFrequencies(); for (int i = 0; i < vTerms.Length; i++) { if (term.Text().Equals(vTerms[i])) { Assert.IsTrue(freqs[i] == freq); } } } //System.out.println("--------"); } Query query = new TermQuery(new Term("field", "chocolate")); ScoreDoc[] hits = knownSearcher.Search(query, null, 1000).scoreDocs; //doc 3 should be the first hit b/c it is the shortest match Assert.IsTrue(hits.Length == 3); float score = hits[0].score; /*System.out.println("Hit 0: " + hits.id(0) + " Score: " + hits.score(0) + " String: " + hits.doc(0).toString()); * System.out.println("Explain: " + knownSearcher.explain(query, hits.id(0))); * System.out.println("Hit 1: " + hits.id(1) + " Score: " + hits.score(1) + " String: " + hits.doc(1).toString()); * System.out.println("Explain: " + knownSearcher.explain(query, hits.id(1))); * System.out.println("Hit 2: " + hits.id(2) + " Score: " + hits.score(2) + " String: " + hits.doc(2).toString()); * System.out.println("Explain: " + knownSearcher.explain(query, hits.id(2)));*/ Assert.IsTrue(hits[0].doc == 2); Assert.IsTrue(hits[1].doc == 3); Assert.IsTrue(hits[2].doc == 0); TermFreqVector vector2 = knownSearcher.reader_ForNUnit.GetTermFreqVector(hits[1].doc, "field"); Assert.IsTrue(vector2 != null); //System.out.println("Vector: " + vector); System.String[] terms = vector2.GetTerms(); int[] freqs2 = vector2.GetTermFrequencies(); Assert.IsTrue(terms != null && terms.Length == 10); for (int i = 0; i < terms.Length; i++) { System.String term = terms[i]; //System.out.println("Term: " + term); int freq = freqs2[i]; Assert.IsTrue(test4.IndexOf(term) != -1); System.Int32 freqInt = -1; try { freqInt = (System.Int32)test4Map[term]; } catch (Exception) { Assert.IsTrue(false); } Assert.IsTrue(freqInt == freq); } SortedTermVectorMapper mapper = new SortedTermVectorMapper(new TermVectorEntryFreqSortedComparator()); knownSearcher.reader_ForNUnit.GetTermFreqVector(hits[1].doc, mapper); System.Collections.Generic.SortedDictionary <object, object> vectorEntrySet = mapper.GetTermVectorEntrySet(); Assert.IsTrue(vectorEntrySet.Count == 10, "mapper.getTermVectorEntrySet() Size: " + vectorEntrySet.Count + " is not: " + 10); TermVectorEntry last = null; foreach (TermVectorEntry tve in vectorEntrySet.Keys) { if (tve != null && last != null) { Assert.IsTrue(last.GetFrequency() >= tve.GetFrequency(), "terms are not properly sorted"); System.Int32 expectedFreq = (System.Int32)test4Map[tve.GetTerm()]; //we expect double the expectedFreq, since there are two fields with the exact same text and we are collapsing all fields Assert.IsTrue(tve.GetFrequency() == 2 * expectedFreq, "Frequency is not correct:"); } last = tve; } FieldSortedTermVectorMapper fieldMapper = new FieldSortedTermVectorMapper(new TermVectorEntryFreqSortedComparator()); knownSearcher.reader_ForNUnit.GetTermFreqVector(hits[1].doc, fieldMapper); System.Collections.IDictionary map = fieldMapper.GetFieldToTerms(); Assert.IsTrue(map.Count == 2, "map Size: " + map.Count + " is not: " + 2); vectorEntrySet = (System.Collections.Generic.SortedDictionary <Object, Object>)map["field"]; Assert.IsTrue(vectorEntrySet != null, "vectorEntrySet is null and it shouldn't be"); Assert.IsTrue(vectorEntrySet.Count == 10, "vectorEntrySet Size: " + vectorEntrySet.Count + " is not: " + 10); knownSearcher.Close(); } catch (System.IO.IOException e) { System.Console.Error.WriteLine(e.StackTrace); Assert.IsTrue(false); } }
static StackObject *get_Current_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); System.Collections.Generic.SortedDictionary <System.Int64, System.Collections.Generic.List <ILRuntime.Runtime.Intepreter.ILTypeInstance> > .Enumerator instance_of_this_method = (System.Collections.Generic.SortedDictionary <System.Int64, System.Collections.Generic.List <ILRuntime.Runtime.Intepreter.ILTypeInstance> > .Enumerator) typeof(System.Collections.Generic.SortedDictionary <System.Int64, System.Collections.Generic.List <ILRuntime.Runtime.Intepreter.ILTypeInstance> > .Enumerator).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 16); var result_of_this_method = instance_of_this_method.Current; ptr_of_this_method = ILIntepreter.Minus(__esp, 1); WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); __intp.Free(ptr_of_this_method); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
internal System.Collections.Generic.List <com.epl.geometry.Geometry> Collect_geometries_to_union(int dim) { System.Collections.Generic.List <com.epl.geometry.Geometry> batch_to_union = new System.Collections.Generic.List <com.epl.geometry.Geometry>(); System.Collections.Generic.List <System.Collections.Generic.KeyValuePair <int, com.epl.geometry.OperatorUnionCursor.Bin_type> > entriesToRemove = new System.Collections.Generic.List <System.Collections.Generic.KeyValuePair <int, com.epl.geometry.OperatorUnionCursor.Bin_type> >(); System.Collections.Generic.SortedDictionary <int, com.epl.geometry.OperatorUnionCursor.Bin_type> set = m_union_bins[dim]; foreach (System.Collections.Generic.KeyValuePair <int, com.epl.geometry.OperatorUnionCursor.Bin_type> e in set) { //int level = e.getKey(); com.epl.geometry.OperatorUnionCursor.Bin_type bin = e.Value; int binVertexThreshold = 10000; if (m_b_done || (bin.bin_vertex_count > binVertexThreshold && bin.Geom_count() > 1)) { m_dim_geom_counts[dim] -= bin.Geom_count(); m_added_geoms -= bin.Geom_count(); while (bin.geometries.Count > 0) { // empty geometries will be unioned too. batch_to_union.Add(bin.Back_pair().geom); bin.Pop_pair(); } entriesToRemove.Add(e); } } entriesToRemove.ForEach(e => set.Remove(e.Key)); return(batch_to_union); }