Exemplo n.º 1
0
        /// <summary>
        /// This funciton is deprecated. Return -1
        /// </summary>
        /// <param name="value"></param>
        /// <param name="comparer"></param>
        /// <returns></returns>
        public override int BinarySearch(object value, System.Collections.IComparer comparer)
        {
                        #if DEBUG
                        #endif

            return((int)-1);
        }
Exemplo n.º 2
0
 public override int CompareTo(object other, System.Collections.IComparer comparer)
 {
     if (other == null)
     {
         return(0);
     }
     if (other is Cons <T> )
     {
         var cons = (Cons <T>)other;
         int headComparisonResult = comparer.Compare(this.head, cons.head);
         if (headComparisonResult != 0)
         {
             return(headComparisonResult);
         }
         else
         {
             return(this.tail.CompareTo(cons.tail, comparer));
         }
     }
     if (other is Nil <T> )
     {
         return(1);
     }
     else
     {
         return(0);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Sorts an IList collections
        /// </summary>
        /// <param name="list">The System.Collections.IList instance that will be sorted</param>
        /// <param name="Comparator">The Comparator criteria, null to use natural comparator.</param>
        public static void Sort(System.Collections.IList list, System.Collections.IComparer Comparator)
        {
            if (((System.Collections.ArrayList)list).IsReadOnly)
            {
                throw new System.NotSupportedException();
            }

            if ((Comparator == null) || (Comparator is System.Collections.Comparer))
            {
                try
                {
                    ((System.Collections.ArrayList)list).Sort();
                }
                catch (System.InvalidOperationException e)
                {
                    throw new System.InvalidCastException(e.Message);
                }
            }
            else
            {
                try
                {
                    ((System.Collections.ArrayList)list).Sort(Comparator);
                }
                catch (System.InvalidOperationException e)
                {
                    throw new System.InvalidCastException(e.Message);
                }
            }
        }
Exemplo n.º 4
0
        public override void Sort(System.Collections.IComparer comparer)
        {
            if (dataSource == null) // if no datasource is set, then bind to the grid itself
                dataSource = new DataSourceManager(this, null);

            dataSource.Sort(comparer);
            FillGrid(groupTemplate);
        }
Exemplo n.º 5
0
 public override void Sort(System.Collections.IComparer comparer)
 {
     base.Sort(comparer);
     if (dataSource == null)
     {
         dataSource = new DataSourceManager(this, null);
     }
     dataSource.Sort(comparer);
     FillGrid(groupTemplate);
 }
Exemplo n.º 6
0
 public static bool ArrayContains(Array array, object value, System.Collections.IComparer comparer)
 {
     foreach (object item in array)
     {
         if (comparer.Compare(item, value) == 0)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 7
0
 public void Sort(System.Collections.IComparer comparer)
 {
     try
     {
         Rows.Sort(new DataSourceRowComparer(comparer));
     }
     catch (Exception Ex)
     {
         //   throw;
     }
 }
Exemplo n.º 8
0
 public bool Equals(object other, System.Collections.IComparer comparer)
 {
     if (comparer.Compare(other, this) == 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public void Sort(String comparerName)
        {
            Type type = GetType().GetNestedType(comparerName);

            if (type == null)
            {
                throw new System.ArgumentException(String.Format("Comparer {0} not found in class {1}.", comparerName, GetType().Name));
            }

            System.Collections.IComparer comparer = Activator.CreateInstance(type) as System.Collections.IComparer;
            if (comparer == null)
            {
                throw new System.ArgumentException("compareName must be the name of class that implements IComparer.");
            }

            this.InnerList.Sort(comparer);
        }
Exemplo n.º 10
0
Arquivo: Maybe.cs Projeto: forki/Funcy
 public override int CompareTo(object other, System.Collections.IComparer comparer)
 {
     if (other == null)
     {
         return(0);
     }
     if (other is Some <T> )
     {
         var some = (Some <T>)other;
         return(comparer.Compare(this.value, some.value));
     }
     else if (other is None <T> )
     {
         return(1);
     }
     else
     {
         return(0);
     }
 }
Exemplo n.º 11
0
Arquivo: Maybe.cs Projeto: forki/Funcy
 public override int CompareTo(object other, System.Collections.IComparer comparer)
 {
     if (other == null)
     {
         return(0);
     }
     if (other is Some <T> )
     {
         return(-1);
     }
     else if (other is None <T> )
     {
         var none = (None <T>)other;
         return(comparer.Compare(this.GetType().DeclaringType, none.GetType().DeclaringType));
     }
     else
     {
         return(comparer.Compare(this, other));
     }
 }
 public void Sort(System.Collections.IComparer comparer)
 {
     this.InnerList.Sort(comparer);
 }
Exemplo n.º 13
0
 public void Sort(System.Collections.IComparer cmp)
 {
     list.Sort(cmp);
 }
Exemplo n.º 14
0
 public SdodWrapper(File.IFile file, System.Collections.IComparer comparer, string name,
                    bool isDataInKeySegment)
 {
     RealDictionary = new SortedDictionaryOnDisk(file, comparer, name, isDataInKeySegment);
 }
Exemplo n.º 15
0
 public RecordComparer(System.Collections.IComparer comparer)
 {
     _comparer = comparer;
 }
Exemplo n.º 16
0
 public void Sort(System.Collections.IComparer comparer)
 {
     Rows.Sort(new DataSourceRowComparer(comparer));
 }
Exemplo n.º 17
0
			public RecordComparer(System.Collections.IComparer comparer)
			{
				_comparer = comparer;
			}
Exemplo n.º 18
0
Arquivo: Maybe.cs Projeto: forki/Funcy
 int System.Collections.IStructuralComparable.CompareTo(object other, System.Collections.IComparer comparer)
 {
     return(this.CompareTo(other, comparer));
 }
Exemplo n.º 19
0
Arquivo: Maybe.cs Projeto: forki/Funcy
 public abstract int CompareTo(object other, System.Collections.IComparer comparer);
Exemplo n.º 20
0
        public void RangeConstructorComparerThrowExceptionIfFromIsLessThanTo(object testObj, object from, object to, System.Collections.IComparer comparer)
        {
            RangeConstraint test = new RangeConstraint(from, to);

            test.Using(comparer);
            test.ApplyTo(testObj);
        }
Exemplo n.º 21
0
            /// <summary>
            /// Obtain the minimum element of the given collection with the specified comparator.
            /// </summary>
            /// <param name="Collection">Collection from which the minimum value will be obtained.</param>
            /// <param name="Comparator">The comparator with which to determine the minimum element.</param>
            /// <returns></returns>
            public static System.Object Min(System.Collections.ICollection Collection, System.Collections.IComparer Comparator)
            {
                System.Collections.ArrayList tempArrayList;

                if (((System.Collections.ArrayList)Collection).IsReadOnly)
                {
                    throw new System.NotSupportedException();
                }

                if ((Comparator == null) || (Comparator is System.Collections.Comparer))
                {
                    try
                    {
                        tempArrayList = new System.Collections.ArrayList(Collection);
                        tempArrayList.Sort();
                    }
                    catch (System.InvalidOperationException e)
                    {
                        throw new System.InvalidCastException(e.Message);
                    }
                    return((System.Object)tempArrayList[0]);
                }
                else
                {
                    try
                    {
                        tempArrayList = new System.Collections.ArrayList(Collection);
                        tempArrayList.Sort(Comparator);
                    }
                    catch (System.InvalidOperationException e)
                    {
                        throw new System.InvalidCastException(e.Message);
                    }
                    return((System.Object)tempArrayList[0]);
                }
            }