/// <summary> /// Create/Get Data Store for both IPersistent Typed Key and Value /// </summary> /// <typeparam name="TKey"></typeparam> /// <typeparam name="TValue"></typeparam> /// <param name="createIfNotExist"></param> /// <param name="container"></param> /// <param name="comparer"></param> /// <param name="name"></param> /// <param name="isDataInKeySegment"> </param> /// <param name="mruManaged"> </param> /// <returns></returns> public ISortedDictionary <TKey, TValue> GetPersistent <TKey, TValue>(object container, string name, System.Collections.Generic.IComparer <TKey> comparer = null, bool createIfNotExist = true, bool isDataInKeySegment = true, bool mruManaged = true, bool isUnique = false) where TKey : IPersistent, new() where TValue : IPersistent, new() { BTreeAlgorithm.CurrentOnValueUnpack = PersistentTypeKeyValue <TKey, TValue> .Collection_OnValueUnpack; //BTreeAlgorithm.CurrentOnValueUnpack = // PersistentTypeKeyValue<TKey, TValue>.Collection_OnKeyUnpack; var resolvedContainer = GetContainer(container); var r2 = CreateDictionary <PersistentTypeKeyValue <TKey, TValue>, TKey, TValue>(createIfNotExist, resolvedContainer, name, containerDod => { var r = new PersistentTypeKeyValue <TKey, TValue>( resolvedContainer, comparer, name, DataStoreType.SopOndisk, null, isDataInKeySegment); containerDod.SetCurrentValueInMemoryData (r); return(r); }, mruManaged, isUnique); BTreeAlgorithm.CurrentOnValueUnpack = null; return(r2); }
public static void Sort <T>(T[] array, int index, int length, System.Collections.Generic.IComparer <T>?comparer) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (index < 0) { ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); } if (length < 0) { ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); } if (array.Length - index < length) { ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); } if (length > 1) { #if CORECLR if (comparer == null || comparer == Comparer <T> .Default) { if (TrySZSort(array, null, index, index + length - 1)) { return; } } #endif ArraySortHelper <T> .Default.Sort(array, index, length, comparer); } }
public void Sort(System.Collections.Generic.IComparer <ICompletionData> comparison) { lock (sortedList) { sortedList.Sort(comparison); sorted = true; } }
public static void Sort <T>(T[] array, System.Collections.Generic.IComparer <T> comparer) { if (array == null) { throw new ArgumentNullException("array"); } Sort <T>(array, 0, array.Length, comparer); }
public static int BinarySearch <T>(T[] array, T value, System.Collections.Generic.IComparer <T> comparer) { if (array == null) { throw new ArgumentNullException("array"); } return(BinarySearch <T>(array, 0, array.Length, value, comparer)); }
public static int BinarySearch <T>(T[] array, T value, System.Collections.Generic.IComparer <T>?comparer) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } return(BinarySearch <T>(array, 0, array.Length, value, comparer)); }
public static void Sort <T>(T[] array, System.Collections.Generic.IComparer <T>?comparer) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } Sort <T>(array, 0, array.Length, comparer); }
public static void Sort <TKey, TValue>(TKey[] keys, TValue[] items, System.Collections.Generic.IComparer <TKey> comparer) { if (keys == null) { throw new ArgumentNullException("keys"); } Sort <TKey, TValue>(keys, items, 0, keys.Length, comparer); }
static int _m_Sort(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); System.Collections.Generic.List <int> __cl_gen_to_be_invoked = (System.Collections.Generic.List <int>)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); if (__gen_param_count == 1) { __cl_gen_to_be_invoked.Sort( ); return(0); } if (__gen_param_count == 2 && translator.Assignable <System.Collections.Generic.IComparer <int> >(L, 2)) { System.Collections.Generic.IComparer <int> comparer = (System.Collections.Generic.IComparer <int>)translator.GetObject(L, 2, typeof(System.Collections.Generic.IComparer <int>)); __cl_gen_to_be_invoked.Sort(comparer); return(0); } if (__gen_param_count == 2 && translator.Assignable <System.Comparison <int> >(L, 2)) { System.Comparison <int> comparison = translator.GetDelegate <System.Comparison <int> >(L, 2); __cl_gen_to_be_invoked.Sort(comparison); return(0); } if (__gen_param_count == 4 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && translator.Assignable <System.Collections.Generic.IComparer <int> >(L, 4)) { int index = LuaAPI.xlua_tointeger(L, 2); int count = LuaAPI.xlua_tointeger(L, 3); System.Collections.Generic.IComparer <int> comparer = (System.Collections.Generic.IComparer <int>)translator.GetObject(L, 4, typeof(System.Collections.Generic.IComparer <int>)); __cl_gen_to_be_invoked.Sort(index, count, comparer); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to System.Collections.Generic.List<int>.Sort!")); }
// ml: added Sort routine as there's no other way to sort the managed node collection. public void Sort(System.Collections.Generic.IComparer <Node> comparer) { List <Node> list = Items as List <Node>; list.Sort(comparer); for (int i = 0; i < Count; i++) { this[i]._index = i; } }
static int _m_BinarySearch(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); System.Collections.Generic.List <int> __cl_gen_to_be_invoked = (System.Collections.Generic.List <int>)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); if (__gen_param_count == 2 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)) { int item = LuaAPI.xlua_tointeger(L, 2); int __cl_gen_ret = __cl_gen_to_be_invoked.BinarySearch(item); LuaAPI.xlua_pushinteger(L, __cl_gen_ret); return(1); } if (__gen_param_count == 3 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && translator.Assignable <System.Collections.Generic.IComparer <int> >(L, 3)) { int item = LuaAPI.xlua_tointeger(L, 2); System.Collections.Generic.IComparer <int> comparer = (System.Collections.Generic.IComparer <int>)translator.GetObject(L, 3, typeof(System.Collections.Generic.IComparer <int>)); int __cl_gen_ret = __cl_gen_to_be_invoked.BinarySearch(item, comparer); LuaAPI.xlua_pushinteger(L, __cl_gen_ret); return(1); } if (__gen_param_count == 5 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 4) && translator.Assignable <System.Collections.Generic.IComparer <int> >(L, 5)) { int index = LuaAPI.xlua_tointeger(L, 2); int count = LuaAPI.xlua_tointeger(L, 3); int item = LuaAPI.xlua_tointeger(L, 4); System.Collections.Generic.IComparer <int> comparer = (System.Collections.Generic.IComparer <int>)translator.GetObject(L, 5, typeof(System.Collections.Generic.IComparer <int>)); int __cl_gen_ret = __cl_gen_to_be_invoked.BinarySearch(index, count, item, comparer); LuaAPI.xlua_pushinteger(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to System.Collections.Generic.List<int>.BinarySearch!")); }
static int _m_BinarySearch(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); System.Collections.Generic.List <string> gen_to_be_invoked = (System.Collections.Generic.List <string>)translator.FastGetCSObj(L, 1); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { string _item = LuaAPI.lua_tostring(L, 2); int gen_ret = gen_to_be_invoked.BinarySearch(_item); LuaAPI.xlua_pushinteger(L, gen_ret); return(1); } if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <System.Collections.Generic.IComparer <string> >(L, 3)) { string _item = LuaAPI.lua_tostring(L, 2); System.Collections.Generic.IComparer <string> _comparer = (System.Collections.Generic.IComparer <string>)translator.GetObject(L, 3, typeof(System.Collections.Generic.IComparer <string>)); int gen_ret = gen_to_be_invoked.BinarySearch(_item, _comparer); LuaAPI.xlua_pushinteger(L, gen_ret); return(1); } if (gen_param_count == 5 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && (LuaAPI.lua_isnil(L, 4) || LuaAPI.lua_type(L, 4) == LuaTypes.LUA_TSTRING) && translator.Assignable <System.Collections.Generic.IComparer <string> >(L, 5)) { int _index = LuaAPI.xlua_tointeger(L, 2); int _count = LuaAPI.xlua_tointeger(L, 3); string _item = LuaAPI.lua_tostring(L, 4); System.Collections.Generic.IComparer <string> _comparer = (System.Collections.Generic.IComparer <string>)translator.GetObject(L, 5, typeof(System.Collections.Generic.IComparer <string>)); int gen_ret = gen_to_be_invoked.BinarySearch(_index, _count, _item, _comparer); LuaAPI.xlua_pushinteger(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to System.Collections.Generic.List<string>.BinarySearch!")); }
public static void Sort <T>(T[] array, int index, int length, System.Collections.Generic.IComparer <T> comparer) { if (array == null) { throw new ArgumentNullException("array"); } if (length > 1) { ArraySortHelper <T> .Default.Sort(array, index, length, comparer); } }
private void ApplySort(System.Collections.Generic.IComparer <T> comparer) { T[] items = this.ToArray(); Array.Sort(items, comparer); try { IsSorting = true; this.Clear(); Array.ForEach(items, this.Add); } finally { IsSorting = false; _isSorted = true; } }
/// <summary> /// Create/Get Data Store for IPersistent typed Key and "Simple typed" Value. /// NOTE: Simple type means one of the integer, numeric(decimals,...), char data types, byte array /// or a string /// </summary> /// <typeparam name="TKey"></typeparam> /// <typeparam name="TValue"></typeparam> /// <param name="createIfNotExist"></param> /// <param name="container"></param> /// <param name="comparer"></param> /// <param name="name"></param> /// <param name="isDataInKeySegment"> </param> /// <param name="mruManaged"> </param> /// <returns></returns> public ISortedDictionary <TKey, TValue> GetPersistentKey <TKey, TValue>(object container, string name, System.Collections.Generic.IComparer <TKey> comparer = null, bool createIfNotExist = true, bool isDataInKeySegment = true, bool mruManaged = true) where TKey : IPersistent, new() { if (!CollectionOnDisk.IsSimpleType(typeof(TValue))) { throw new ArgumentException(string.Format("Type of TValue ({0}) isn't an SOP simple type.", typeof(TValue))); } BTreeAlgorithm.CurrentOnValueUnpack = PersistentTypeKeySimpleValue <TKey, TValue> .Collection_OnKeyUnpack; var r2 = CreateDictionary <PersistentTypeKeySimpleValue <TKey, TValue>, TKey, TValue>(createIfNotExist, container, name, containerDod => { var r = new PersistentTypeKeySimpleValue <TKey, TValue >( container, comparer, name, DataStoreType . SopOndisk, null, isDataInKeySegment); containerDod. SetCurrentValueInMemoryData (r); return(r); }, mruManaged); return(r2); }
private void ascSort(System.Collections.Generic.IComparer<MyButton> comp) { List<MyButton> myButtonListNoArrow = new List<MyButton>(); List<MyButton> myButtonListHaveArrow = new List<MyButton>(); double _thumbInterval = _videoAnnotation.ThumbInterval; double _thumbWidth = _videoAnnotation.ThumbWidth; foreach (MyButton mb in _inkFrame.InkCollector.Sketch.MyButtons) { foreach (MyArrow ma in _inkFrame.InkCollector.Sketch.MyArrows) { if (ma.IsDeleted == false && (ma.PreMyButton == mb || ma.NextMyButton == mb) && mb.IsDeleted == false) { myButtonListHaveArrow.Add(mb); } } } double maxTop = 0; double maxHeight = 0; if (myButtonListHaveArrow.Count > 0) { maxTop = myButtonListHaveArrow[0].Top; maxHeight = myButtonListHaveArrow[0].Height; } foreach (MyButton mb in myButtonListHaveArrow) { maxTop = Math.Max(maxTop, mb.Top); maxHeight = Math.Max(maxHeight, mb.Height); } foreach (MyButton mb in _inkFrame.InkCollector.Sketch.MyButtons) { if (mb.IsDeleted == false && mb.Button.Visibility == Visibility.Collapsed) { Command vmbc = new VisibleMyButtonCommand(_inkFrame.InkCollector, mb); vmbc.execute(); } if (myButtonListHaveArrow.IndexOf(mb) == -1 && mb.IsDeleted == false) { myButtonListNoArrow.Add(mb); } } myButtonListNoArrow.Sort(comp); int ThumbIndex = 0; double _thumbVerticalInterval = _videoAnnotation.ThumbVerticalInterval; //foreach (MyButton mb in myButtonListNoArrow) int _thumbCountPerLine = _videoAnnotation.ThumbCountPerLine; for (int i = 0; i < myButtonListNoArrow.Count; i++) { double Left = _thumbInterval + (_thumbWidth + _thumbInterval) * (i % _thumbCountPerLine); double Top; if (i < _thumbCountPerLine) { Top = _thumbVerticalInterval; } else { if (i % _thumbCountPerLine == 0) { double maxTopButtonListNoArrow = myButtonListNoArrow[i - _thumbCountPerLine].Top + myButtonListNoArrow[i - _thumbCountPerLine].Height; for (int j = i - 5; j < i; j++) { double newTop = myButtonListNoArrow[j].Top + myButtonListNoArrow[j].Height; if (newTop > maxTopButtonListNoArrow) { maxTopButtonListNoArrow = newTop; } } Top = _thumbVerticalInterval + maxTopButtonListNoArrow; } else { Top = myButtonListNoArrow[(i / _thumbCountPerLine) * _thumbCountPerLine].Top; } } //double Top = _thumbInterval + maxTop + maxHeight + (_thumbWidth * (mb.Height / mb.Width) + _thumbInterval) * (ThumbIndex / 6); ButtonMoveCommand bmc = new ButtonMoveCommand(myButtonListNoArrow[i], Left - myButtonListNoArrow[i].Left, Top - myButtonListNoArrow[i].Top, _inkFrame.InkCollector); bmc.execute(); _inkFrame.InkCollector.CommandStack.Push(bmc); ThumbIndex++; } }
public SingleSortedLinkedTable(System.Collections.Generic.IComparer <T> comparer) { System.Diagnostics.Debug.Assert(comparer != null); _Comparer = comparer; }
public static int BinarySearch <T>(T[] array, int index, int length, T value, System.Collections.Generic.IComparer <T>?comparer) { if (array == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); } if (index < 0) { ThrowHelper.ThrowIndexArgumentOutOfRange_NeedNonNegNumException(); } if (length < 0) { ThrowHelper.ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum(); } if (array.Length - index < length) { ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); } return(ArraySortHelper <T> .Default.BinarySearch(array, index, length, value, comparer)); }
public void sortVertices(System.Collections.Generic.IComparer <Vertex> c) { vertices.Sort(c); }
public void sortEdges(System.Collections.Generic.IComparer <EdgeIfc> c) { edges.Sort(c); }
/// <summary> /// Constructor to use if you want to provide number of slots per node and your comparer object /// </summary> /// <param name="slotLen">Number of slots per node</param> /// <param name="comparer">compare object defining how records will be sorted</param> public SortedDictionary(byte slotLen, System.Collections.Generic.IComparer <TKey> comparer) { Btree = new Sop.Collections.Generic.BTree.BTreeAlgorithm <TKey, TValue>(slotLen, comparer); }
/// <summary> /// Constructor to use if you want to provide your own Comparer object that defines /// how your records will be sorted/arranged /// </summary> /// <param name="comparer">IComparer implementation that defines how records will be sorted</param> public SortedDictionary(System.Collections.Generic.IComparer <TKey> comparer) { Btree = new BTree.BTreeAlgorithm <TKey, TValue>(comparer); }
/// <summary> /// Create an entry comparer for a item comparer of the keys /// </summary> /// <param name="comparer">Comparer of keys</param> public KeyValuePairComparer(System.Collections.Generic.IComparer <K> comparer) { this.comparer = comparer ?? throw new NullReferenceException(); }
public SortedList(System.Collections.Generic.IComparer <object> comparer, int capacity) : base(capacity, comparer) { }
/// <summary> /// Initializes a new instance of the <see cref="T:IndexedSortedList<TKey, TValue>"/> class. /// </summary> /// <param name="comparer">The comparer.</param> public IndexedSortedList(System.Collections.Generic.IComparer <TKey> comparer) { _table = new SortedList <TKey, KeyValuePair <int, TValue> > (comparer); _index = new List <KeyValuePair <TKey, TValue> >(); }
public static int BinarySearch <T>(T[] array, int index, int length, T value, System.Collections.Generic.IComparer <T> comparer) { if (array == null) { throw new ArgumentNullException("array"); } if (index < 0 || length < 0) { throw new ArgumentOutOfRangeException((index < 0 ? "index" : "length"), "NeedNonNegNum"); } if (array.Length - index < length) { throw new ArgumentException("Argument_InvalidOffLen"); } return(ArraySortHelper <T> .Default.BinarySearch(array, index, length, value, comparer)); }
public static void Sort <TKey, TValue>(TKey[] keys, TValue[] items, int index, int length, System.Collections.Generic.IComparer <TKey> comparer) { if (keys == null) { throw new ArgumentNullException("keys"); } if (index < 0 || length < 0) { if (length > 1) { if (items == null) { Sort <TKey>(keys, index, length, comparer); return; } ArraySortHelper <TKey, TValue> .Default.Sort(keys, items, index, length, comparer); } } }
public BTreeSlotComparer(System.Collections.Generic.IComparer <TKey> Comparer) { KeyComparer = Comparer; }
/// <summary> /// Inserts a new element in a sorted collection /// </summary> /// <typeparam name="TC"></typeparam> /// <typeparam name="TI"></typeparam> /// <param name="col"></param> /// <param name="item"></param> /// <param name="comparer"></param> public static void InsertSorted <TC>(this Collection <TC> collection, TC item, System.Collections.Generic.IComparer <TC> comparer) { // Find right position and insert int i = 0; for (; i < collection.Count(); ++i) { if (comparer.Compare(item, collection.ElementAt(i)) < 0) { break; } } // Not yet inserted, insert at the end collection.Insert(i, item); }