コード例 #1
0
        /// <summary>
        /// Creates a new instance of a DynamicPropertyReader
        /// </summary>
        /// <param name="sourceType">The assembly qualified name of the type against which the property should be invoked</param>
        /// <param name="propertyName">The name of the property to be 'gotten' and evaluated against</param>
        /// <exception cref="System.ArgumentNullException">Thrown if the sourceType or propertyName arguments are null or empty strings</exception>
        /// <exception cref="System.TypeLoadException">Thrown if the sourceType is not a valid .NET type, or cannot be loaded</exception>
        public DynamicPropertyReader(string sourceType, string propertyName)
        {
            if (string.IsNullOrEmpty(sourceType))
            {
                throw new ArgumentNullException("sourceType");
            }
            if (string.IsNullOrEmpty(propertyName))
            {
                throw new ArgumentNullException("propertyName");
            }

            // Attmpt to get the type, and throw a TypeLoadException if not found
            Type type = Type.GetType(sourceType, true);

            _fastPropertyGetter = new FastPropertyGetter(propertyName, type);

            if (_fastPropertyGetter.PropertyType == typeof(string))
            {
                _comparator = StringComparator.Instance;
            }
            else if (typeof(IConvertible).IsAssignableFrom(_fastPropertyGetter.PropertyType) &&
                     typeof(IComparable).IsAssignableFrom(_fastPropertyGetter.PropertyType))
            {
                _comparator = NumericComparator.Instance;
            }
            else
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
                                                                  Resources.DoesNotImplementRightInterfaces,
                                                                  propertyName, sourceType));
            }
        }
コード例 #2
0
        public TreeMap(IComparator <K> comparator)
        {
            m_comparator = comparator;

            m_root  = null;
            m_count = 0;
        }
コード例 #3
0
        /// <summary>
        /// Creates a new instance of a DynamicPropertyReader
        /// </summary>
        /// <param name="sourceType">The assembly qualified name of the type against which the property should be invoked</param>
        /// <param name="propertyName">The name of the property to be 'gotten' and evaluated against</param>
        /// <exception cref="System.ArgumentNullException">Thrown if the sourceType or propertyName arguments are null or empty strings</exception>
        /// <exception cref="System.TypeLoadException">Thrown if the sourceType is not a valid .NET type, or cannot be loaded</exception>
        public DynamicPropertyReader(string sourceType, string propertyName)
        {
            if (string.IsNullOrEmpty(sourceType))
                throw new ArgumentNullException("sourceType");
            if (string.IsNullOrEmpty(propertyName))
                throw new ArgumentNullException("propertyName");

            // Attmpt to get the type, and throw a TypeLoadException if not found
            Type type = Type.GetType(sourceType, true);

            _fastPropertyGetter = new FastPropertyGetter(propertyName, type);

            if (_fastPropertyGetter.PropertyType == typeof (string))
            {
                _comparator = StringComparator.Instance;
            }
            else if (typeof (IConvertible).IsAssignableFrom(_fastPropertyGetter.PropertyType) &&
                     typeof (IComparable).IsAssignableFrom(_fastPropertyGetter.PropertyType))
            {
                _comparator = NumericComparator.Instance;
            }
            else
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
                                                                  Resources.DoesNotImplementRightInterfaces,
                                                                  propertyName, sourceType));
            }
        }
コード例 #4
0
        /// <summary>Return the items of an Iterable as a sorted list.</summary>
        /// <?/>
        /// <param name="items">The collection to be sorted.</param>
        /// <returns>A list containing the same items as the Iterable, but sorted.</returns>
        public static IList <T> Sorted <T>(IEnumerable <T> items, IComparator <T> comparator)
        {
            IList <T> result = ToList(items);

            result.Sort(comparator);
            return(result);
        }
コード例 #5
0
 /**
  * Appends to the <code>builder</code> the deep comparison of
  * two <code>Object</code> arrays.
  *
  * <ol>
  *  <li>Check if arrays are the same using <code>==</code></li>
  *  <li>Check if for <code>null</code>, <code>null</code> is less than non-<code>null</code></li>
  *  <li>Check array length, a short length array is less than a long length array</li>
  *  <li>Check array contents element by element using {@link #Append(Object, Object, IComparator)}</li>
  * </ol>
  *
  * This method will also will be called for the top level of multi-dimensional,
  * ragged, and multi-typed arrays.
  *
  * @param lhs  left-hand array
  * @param rhs  right-hand array
  * @param comparator  <code>IComparator</code> to use to compare the array elements,
  *  <code>null</code> means to treat <code>lhs</code> elements as <code>Comparable</code>.
  * @return this - used to chain append calls
  * @throws ClassCastException  if <code>rhs</code> is not assignment-compatible
  *  with <code>lhs</code>
  * @since 2.0
  */
 public CompareToBuilder Append(Object[] lhs, Object[] rhs, IComparator comparator)
 {
     if (comparison != 0)
     {
         return(this);
     }
     if (lhs == rhs)
     {
         return(this);
     }
     if (lhs == null)
     {
         comparison = -1;
         return(this);
     }
     if (rhs == null)
     {
         comparison = +1;
         return(this);
     }
     if (lhs.Length != rhs.Length)
     {
         comparison = (lhs.Length < rhs.Length) ? -1 : +1;
         return(this);
     }
     for (int i = 0; i < lhs.Length && comparison == 0; i++)
     {
         Append(lhs[i], rhs[i], comparator);
     }
     return(this);
 }
コード例 #6
0
        public virtual void TestGroup()
        {
            string[]             input    = new string[] { "0 ab", "0 bb", "0 cc", "1 dd", "2 dd", "2 kj", "3 kj", "3 kk" };
            int[]                counts   = new int[] { 3, 1, 2, 2 };
            IComparator <string> fieldOne = IComparer.Comparing(null);
            int index = 0;
            int group = 0;

            foreach (IEnumerable <string> set in Iterables.Group(Arrays.AsList(input), fieldOne))
            {
                string sharedKey = null;
                int    thisCount = 0;
                foreach (string line in set)
                {
                    string thisKey = line.Split(" ")[0];
                    if (sharedKey == null)
                    {
                        sharedKey = thisKey;
                    }
                    else
                    {
                        NUnit.Framework.Assert.AreEqual(sharedKey, thisKey, "Wrong key");
                    }
                    NUnit.Framework.Assert.AreEqual(line, input[index++], "Wrong input line");
                    thisCount++;
                }
                NUnit.Framework.Assert.AreEqual(counts[group++], thisCount, "Wrong number of items in this iterator");
            }
            NUnit.Framework.Assert.AreEqual(input.Length, index, "Didn't get all inputs");
            NUnit.Framework.Assert.AreEqual(counts.Length, group, "Wrong number of groups");
        }
コード例 #7
0
        /// <summary>
        /// search on searchable using DFS algorithm
        /// </summary>
        /// <param name="searchable">obj that can be searched on</param>
        /// <param name="comparator">irrelevant</param>
        /// <returns>the solution of the DFS algorithm:
        /// path to the goal and the number of state that evaluated</returns>
        public override Solution <T> Search(ISearchable <T> searchable, IComparator <T> comparator = null)
        {
            HashSet <T> labeled = new HashSet <T>();
            State <T>   state   = searchable.GetInitializeState();

            state.Cost     = 1;
            state.CameFrom = null;
            AddToOpenList(state);
            while (OpenListSize > 0)
            {
                state = PopOpenList();
                if (state.Equals(searchable.GetGoalState()))
                {
                    return(BackTrace(ref state));
                }
                if (!labeled.Contains(state.Getstate()))
                {
                    labeled.Add(state.Getstate());
                    List <State <T> > succerssors = searchable.GetAllPossibleStates(state);
                    foreach (State <T> s in succerssors)
                    {
                        if (!labeled.Contains(s.Getstate()))
                        {
                            s.Cost     = state.Cost + 1;
                            s.CameFrom = state;
                            AddToOpenList(s);
                        }
                    }
                }
            }
            return(null);
        }
コード例 #8
0
		public IIterator CreateIterator(IComparator comparator)
		{
			if (RestartsCount == 0)
				return new EmptyIterator();
			IncrementUsage(); // make sure that this object won't be disposed before its iterator
			return new BlockIterator(comparator, this);
		}
コード例 #9
0
ファイル: Detected.cs プロジェクト: petrushevskiApps/TankWars
 public Detected(GameObject detected, string detectedName, GameObject agent, IComparator comparator)
 {
     this.detected     = detected;
     this.agent        = agent;
     this.detectedName = detectedName;
     this.comparator   = comparator;
     status            = true;
 }
コード例 #10
0
 public IComparator <TEvaluatedFeatureVector, TTemplate, TTemplatedFeatureVector> getComparator()
 {
     if (this.comparator == null)
     {
         this.comparator = this.createComparator();
     }
     return(comparator);
 }
コード例 #11
0
ファイル: Property.cs プロジェクト: donners77/DukeSharp
 public Property(String name, IComparator comparator, double low, double high)
 {
     Name = name;
     Comparator = comparator;
     LowProbability = low;
     HighProbability = high;
     IsAnalyzed = comparator.IsTokenized();
     IsIdProperty = false;
 }
コード例 #12
0
        public virtual void TestArrayComparator()
        {
            IComparator <bool[]> ac = Comparators.GetArrayComparator();

            NUnit.Framework.Assert.IsTrue(ac.Compare(new bool[] { true, false, true }, new bool[] { true, false, true }) == 0);
            NUnit.Framework.Assert.IsTrue(ac.Compare(new bool[] { true, false, true }, new bool[] { true, false }) > 0);
            NUnit.Framework.Assert.IsTrue(ac.Compare(new bool[] { true, false, true }, new bool[] { true, false, true, false }) < 0);
            NUnit.Framework.Assert.IsTrue(ac.Compare(new bool[] { false, false, true }, new bool[] { true, false, true }) < 0);
        }
コード例 #13
0
		public int CompareTo(Slice other, IComparator comparator = null)
		{
			if (comparator == null)
			{
				comparator = ByteWiseComparator.Default;
			}

			return comparator.Compare(this, other);
		}
コード例 #14
0
ファイル: GameEntity.cs プロジェクト: backviet/winengine
        public void SortChildren(IComparator <IEntity> compare)
        {
            if (children == null)
            {
                return;
            }

            ZIndexSorter.Instance().Sort(children, compare);
        }
コード例 #15
0
ファイル: DefaultFilterField.cs プロジェクト: oklacoder/sqee
 public DefaultFilterField(
     IComparator comparator,
     string value,
     string fieldName)
 {
     Comparator = comparator;
     Value      = value;
     FieldName  = fieldName;
 }
コード例 #16
0
ファイル: Property.cs プロジェクト: tobiaszuercher/DukeSharp
 public Property(String name, IComparator comparator, double low, double high)
 {
     Name            = name;
     Comparator      = comparator;
     LowProbability  = low;
     HighProbability = high;
     IsAnalyzed      = comparator.IsTokenized();
     IsIdProperty    = false;
 }
コード例 #17
0
        public virtual void TestNullSafeComparator()
        {
            IComparator <int> comp = Comparators.NullSafeNaturalComparator();

            NUnit.Framework.Assert.AreEqual(0, comp.Compare(null, null));
            NUnit.Framework.Assert.AreEqual(-1, comp.Compare(null, int.Parse(42)));
            NUnit.Framework.Assert.AreEqual(1, comp.Compare(int.Parse(42), null));
            NUnit.Framework.Assert.AreEqual(-1, comp.Compare(11, 18));
            NUnit.Framework.Assert.AreEqual(0, comp.Compare(11, 11));
        }
コード例 #18
0
		public MergingIterator(IComparator comparator, IList<IIterator> children)
		{
			if (children == null)
				 throw new ArgumentNullException("children");
			
			this.comparator = comparator;
			this.children = children;
			direction = Direction.Forward;
			current = null;
		}
コード例 #19
0
        public void EnsureComparator(IComparator comparator)
        {
            var a = AdditionalComparators.ToList();

            if (!a.Any(x => comparator.Value.Equals(x.Value, StringComparison.OrdinalIgnoreCase)))
            {
                a.Add(comparator);
            }
            AdditionalComparators = a;
        }
コード例 #20
0
        public virtual void TestMerge3()
        {
            IList <string>       a          = Arrays.AsList("a", "b", "d", "e");
            IList <string>       b          = Arrays.AsList("b", "c", "d", "e");
            IList <string>       c          = Arrays.AsList("a", "b", "c", "e", "f");
            IComparator <string> comparator = IComparer.NaturalOrder();
            IEnumerator <Triple <string, string, string> > iter = Iterables.Merge(a, b, c, comparator).GetEnumerator();

            NUnit.Framework.Assert.AreEqual(iter.Current, new Triple <string, string, string>("b", "b", "b"));
            NUnit.Framework.Assert.AreEqual(iter.Current, new Triple <string, string, string>("e", "e", "e"));
            NUnit.Framework.Assert.IsTrue(!iter.MoveNext());
        }
コード例 #21
0
        public virtual void TestListComparator()
        {
            IComparator <IList <string> > lc = Comparators.GetListComparator();

            string[] one   = new string[] { "hello", "foo" };
            string[] two   = new string[] { "hi", "foo" };
            string[] three = new string[] { "hi", "foo", "bar" };
            NUnit.Framework.Assert.IsTrue(lc.Compare(Arrays.AsList(one), Arrays.AsList(one)) == 0);
            NUnit.Framework.Assert.IsTrue(lc.Compare(Arrays.AsList(one), Arrays.AsList(two)) < 0);
            NUnit.Framework.Assert.IsTrue(lc.Compare(Arrays.AsList(one), Arrays.AsList(three)) < 0);
            NUnit.Framework.Assert.IsTrue(lc.Compare(Arrays.AsList(three), Arrays.AsList(two)) > 0);
        }
コード例 #22
0
	    public BlockBuilder(Stream stream, StorageState storageState, IComparator comparator, int blockRestartInterval)
        {
	        _storageState = storageState;
			if (blockRestartInterval < 1)
                throw new InvalidOperationException("BlockRestartInternal must be >= 1");
            _stream = new CrcStream(stream);
            IsEmpty = true;
            OriginalPosition = stream.Position;
	        _comparator = comparator;
			_blockRestartInterval = blockRestartInterval;
		    _lastKeyBuffer = storageState.Options.BufferPool.Take(storageState.Options.MaximumExpectedKeySize);
        }
コード例 #23
0
 public BackupAction(string name, string source, string destination, IBackup bmode, IComparator comparator,
                     int copies = 1, bool archive = false, string pass = "")
 {
     ActionName      = name;
     SourcePath      = source;
     DestinationPath = destination;
     FilesToCopy     = RecursiveFileFinder.ProcessPath(source, true);
     BackupProcessor = bmode;
     Comparator      = comparator;
     BackupCopies    = copies;
     Archive         = archive;
     ArchivePassword = pass;
 }
コード例 #24
0
 public DynamicTreeSplitting(
     IEvaluator <TState, TMetric> evaluator,
     IBrancher <TNode, TState, TMetric> brancher,
     IComparator <TMetric> comparator,
     IStateTransitions <TState, TNode, TMetric> stateTransitions
     )
 {
     _evaluator        = evaluator;
     _brancher         = brancher;
     _comparator       = comparator;
     _stateTransitions = stateTransitions;
     _manualResetEvent = new ManualResetEvent(false);
 }
コード例 #25
0
    public static AnyType findMax <AnyType>(AnyType[] a, IComparator <AnyType> cmp)
    {
        int maxIndex = 0;

        for (int i = 1; i < a.Length; i++)
        {
            if (cmp.Compare(a[i], a[maxIndex]) > 0)
            {
                maxIndex = i;
            }
        }

        return(a[maxIndex]);
    }
コード例 #26
0
    void Start()
    {
        HumanStrategy h1 = new HumanStrategy("Yamada", 170, 60, 20);
        HumanStrategy h2 = new HumanStrategy("Sato", 175, 55, 20);

        comparator = new AgeComparator();
        resultAge  = Compare(h1, h2);

        comparator   = new HeightComparator();
        resultHeight = Compare(h1, h2);

        print("age :" + resultAge);
        print("height :" + resultHeight);
    }
コード例 #27
0
    void Start()
    {
        Human h1 = new Human("aaa", 170, 60, 20);
        Human h2 = new Human("bbb", 175, 55, 20);

        _comparator = new AgeComparator();
        resultage   = compare(h1, h2);

        _comparator  = new HeightComparator();
        resultheight = compare(h1, h2);

        print("age :" + resultage);
        print("height :" + resultheight);
    }
コード例 #28
0
        public virtual void TestComparators()
        {
            c.Clear();
            c.SetCount("b", 3.0);
            c.SetCount("p", -5.0);
            c.SetCount("a", 2.0);
            c.SetCount("s", 4.0);
            IList <string>       list = new List <string>(c.KeySet());
            IComparator <string> cmp  = Counters.ToComparator(c);

            list.Sort(cmp);
            NUnit.Framework.Assert.AreEqual(4, list.Count);
            NUnit.Framework.Assert.AreEqual("p", list[0]);
            NUnit.Framework.Assert.AreEqual("a", list[1]);
            NUnit.Framework.Assert.AreEqual("b", list[2]);
            NUnit.Framework.Assert.AreEqual("s", list[3]);
            IComparator <string> cmp2 = Counters.ToComparatorDescending(c);

            list.Sort(cmp2);
            NUnit.Framework.Assert.AreEqual(4, list.Count);
            NUnit.Framework.Assert.AreEqual("p", list[3]);
            NUnit.Framework.Assert.AreEqual("a", list[2]);
            NUnit.Framework.Assert.AreEqual("b", list[1]);
            NUnit.Framework.Assert.AreEqual("s", list[0]);
            IComparator <string> cmp3 = Counters.ToComparator(c, true, true);

            list.Sort(cmp3);
            NUnit.Framework.Assert.AreEqual(4, list.Count);
            NUnit.Framework.Assert.AreEqual("p", list[3]);
            NUnit.Framework.Assert.AreEqual("a", list[0]);
            NUnit.Framework.Assert.AreEqual("b", list[1]);
            NUnit.Framework.Assert.AreEqual("s", list[2]);
            IComparator <string> cmp4 = Counters.ToComparator(c, false, true);

            list.Sort(cmp4);
            NUnit.Framework.Assert.AreEqual(4, list.Count);
            NUnit.Framework.Assert.AreEqual("p", list[0]);
            NUnit.Framework.Assert.AreEqual("a", list[3]);
            NUnit.Framework.Assert.AreEqual("b", list[2]);
            NUnit.Framework.Assert.AreEqual("s", list[1]);
            IComparator <string> cmp5 = Counters.ToComparator(c, false, false);

            list.Sort(cmp5);
            NUnit.Framework.Assert.AreEqual(4, list.Count);
            NUnit.Framework.Assert.AreEqual("p", list[3]);
            NUnit.Framework.Assert.AreEqual("a", list[2]);
            NUnit.Framework.Assert.AreEqual("b", list[1]);
            NUnit.Framework.Assert.AreEqual("s", list[0]);
        }
コード例 #29
0
        public static int Search(T[] collection, T key, IComparator <T> comparator)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }
            if (collection.Length == 0)
            {
                throw new ArgumentException(nameof(collection));
            }
            int min = 0;
            int max = collection.Length - 1;

            while (min <= max)
            {
                int mid           = (min + max) / 2;
                int comperedValue = 0;
                if (comparator != null)
                {
                    comperedValue = comparator.Compare(key, collection[mid]);
                }
                else
                {
                    var enumerable = key as IComparable <T>;
                    if (enumerable != null)
                    {
                        comperedValue = enumerable.CompareTo(collection[mid]);
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
                if (comperedValue == 0)
                {
                    return(mid);
                }
                if (comperedValue < 0)
                {
                    max = mid - 1;
                }
                else
                {
                    min = mid + 1;
                }
            }
            return(-1);
        }
コード例 #30
0
        /// <summary>Finds and returns the key in this Counter with the smallest count.</summary>
        /// <remarks>
        /// Finds and returns the key in this Counter with the smallest count.
        /// Ties are broken by comparing the objects using the given tie breaking
        /// Comparator, favoring Objects that are sorted to the front. This is useful
        /// if the keys are numeric and there is a bias to prefer smaller or larger
        /// values, and can be useful in other circumstances where random tie-breaking
        /// is not desirable. Returns null if this Counter is empty.
        /// </remarks>
        public virtual E Argmin(IComparator <E> tieBreaker)
        {
            int min    = int.MaxValue;
            E   argmin = null;

            foreach (E key in map.Keys)
            {
                int count = GetIntCount(key);
                if (argmin == null || count < min || (count == min && tieBreaker.Compare(key, argmin) < 0))
                {
                    min    = count;
                    argmin = key;
                }
            }
            return(argmin);
        }
コード例 #31
0
 public SerialAlfaBetaSearch(
     IEvaluator <TState, TMetric> evaluator,
     IBrancher <TNode, TState, TMetric> brancher,
     IComparator <TMetric> comparator,
     IStateTransitions <TState, TNode, TMetric> stateTransitions,
     TMetric maxValue,
     TMetric minValue
     )
 {
     _evaluator        = evaluator;
     _brancher         = brancher;
     _comparator       = comparator;
     _stateTransitions = stateTransitions;
     _minValue         = minValue;
     _maxValue         = maxValue;
 }
コード例 #32
0
        /// <summary>Finds and returns the key in this Counter with the largest count.</summary>
        /// <remarks>
        /// Finds and returns the key in this Counter with the largest count.
        /// Ties are broken by comparing the objects using the given tie breaking
        /// Comparator, favoring Objects that are sorted to the front. This is useful
        /// if the keys are numeric and there is a bias to prefer smaller or larger
        /// values, and can be useful in other circumstances where random tie-breaking
        /// is not desirable. Returns null if this Counter is empty.
        /// </remarks>
        public virtual E Argmax(IComparator <E> tieBreaker)
        {
            int max    = int.MinValue;
            E   argmax = null;

            foreach (E key in KeySet())
            {
                int count = GetIntCount(key);
                if (argmax == null || count > max || (count == max && tieBreaker.Compare(key, argmax) < 0))
                {
                    max    = count;
                    argmax = key;
                }
            }
            return(argmax);
        }
コード例 #33
0
        /// <summary> Sorts its argument (destructively) using insert sort; in the context of this package
        /// insertion sort is simple and efficient given its relatively small inputs.
        ///
        /// </summary>
        /// <param name="vector">vector to sort
        /// </param>
        /// <param name="comparator">comparator to define sort ordering
        /// </param>
        public static void InsertionSort(ArrayList vector, IComparator comparator)
        {
            int max = vector.Count;

            for (int i = 1; i < max; i++)
            {
                object value_Renamed = vector[i];
                int    j             = i - 1;
                object valueB;
                while (j >= 0 && comparator.Compare(valueB = vector[j], value_Renamed) > 0)
                {
                    vector[j + 1] = valueB;
                    j--;
                }
                vector[j + 1] = value_Renamed;
            }
        }
コード例 #34
0
        public static void Sort <T>(T[] arr, IComparator <T> comparator)
        {
            T temp = default(T);

            for (int iteration = 0; iteration < arr.Length; iteration++)
            {
                for (int index = 0; index < arr.Length - 1; index++)
                {
                    if (comparator.Compare(arr[index], arr[index + 1]) > 0)
                    {
                        temp           = arr[index + 1];
                        arr[index + 1] = arr[index];
                        arr[index]     = temp;
                    }
                }
            }
        }
コード例 #35
0
        public override void Sort(List <T> list, int start, int end, IComparator <T> comparator)
        {
            for (int i = start + 1; i < end; i++)
            {
                T current = list[i];
                T prev    = list[i - 1];

                if (comparator.Compare(current, prev) < 0)
                {
                    int j = i;
                    do
                    {
                        list[j--] = prev;
                    } while (j > start && comparator.Compare(current, prev = list[j - 1]) < 0);
                }
            }
        }
コード例 #36
0
 public SingleColumnValueFilter(
     byte[] columnFamily,
     byte[] columnQualifier,
     CompareType compareOp,
     IComparator comparatorObj,
     bool filterIfMissing,
     bool latestVersionOnly
     )
 {
     ColumnFamily      = columnFamily;
     ColumnQualifier   = columnQualifier;
     CompareOp         = compareOp;
     ComparatorObj     = comparatorObj;
     FilterIfMissing   = filterIfMissing;
     LatestVersionOnly = latestVersionOnly;
     Name = ConstString.FilterPath + nameof(SingleColumnValueFilter);
 }
コード例 #37
0
        /// <summary>
        /// Contructs a new instance of the FastPropertyReader
        /// </summary>
        /// <param name="wrappedPropertyReader">The <see cref="PropertyReader"/> to be wrapped</param>
        /// <param name="propertyName">The name of the property to be retrieved from the result</param>
        public FastPropertyReader(PropertyReader wrappedPropertyReader, string propertyName)
        {
            _fastPropertyGetter = new FastPropertyGetter(propertyName, wrappedPropertyReader.PropertyType);
            _wrappedPropertyReader = wrappedPropertyReader;

            if (_fastPropertyGetter.PropertyType == typeof(string))
            {
                _comparator = StringComparator.Instance;
            }
            else if (typeof(IConvertible).IsAssignableFrom(_fastPropertyGetter.PropertyType) &&
                     typeof(IComparable).IsAssignableFrom(_fastPropertyGetter.PropertyType))
            {
                _comparator = NumericComparator.Instance;
            }
            else
            {
                _comparator = ObjectComparator.Instance;
            }
        }
コード例 #38
0
 public DiceCoefficientComparator()
 {
     _subcomp = new ExactComparator();
 }
コード例 #39
0
			public BlockIterator(IComparator comparator, Block parent)
			{
				_comparator = comparator;
				_parent = parent;
				_keyBuffer = _parent._storageOptions.BufferPool.Take(_parent._storageOptions.MaximumExpectedKeySize);
			}
コード例 #40
0
		private bool BeforeFile(IComparator comparator, Slice key, FileMetadata file)
		{
			// Empty 'key' occurs after all keys and is therefore never before 'file'
			return (key.IsEmpty() == false && comparator.Compare(key, file.SmallestKey.UserKey) < 0);
		}
コード例 #41
0
		private bool AfterFile(IComparator comparator, Slice key, FileMetadata file)
		{
			// Empty 'key' occurs before all keys and is therefore never after 'file'
			return (key.IsEmpty() == false && comparator.Compare(key, file.LargestKey.UserKey) > 0);
		}
コード例 #42
0
		public ItemState Get(InternalKey key, ulong fileNumber, long fileSize, ReadOptions readOptions, IComparator comparator,
							 out Stream stream)
		{
			Table table = FindTable(fileNumber, fileSize);

			Tuple<Slice, Stream> result = table.InternalGet(readOptions, key);

			stream = null;

			if (result == null)
			{
				return ItemState.NotFound;
			}

			bool shouldDispose = true;
			try
			{
				InternalKey internalKey;
				if (!InternalKey.TryParse(result.Item1, out internalKey))
				{
					return ItemState.Corrupt;
				}

				if (comparator.Compare(internalKey.UserKey, key.UserKey) == 0)
				{
					bool isFound = internalKey.Type == ItemType.Value;
					if (!isFound)
					{
						return ItemState.Deleted;
					}

					stream = result.Item2;
					shouldDispose = false;
					return ItemState.Found;
				}

				return ItemState.NotFound;
			}
			finally
			{
				if (shouldDispose && result.Item2 != null)
					result.Item2.Dispose();
			}
		}
コード例 #43
0
 public JaccardIndexComparator()
 {
     _subcomp = new ExactComparator();
 }
コード例 #44
0
 public ProcessedVideoBuilder(IVideoAdjuster videoAdjuster, IAudioAdjuster audioAdjuster, IComparator comparator)
 {
     _videoAdjuster = videoAdjuster;
     _audioAdjuster = audioAdjuster;
     _comparator = comparator;
 }
コード例 #45
0
 public void SetComparator(IComparator comp)
 {
     _subcomp = comp;
 }
コード例 #46
0
ファイル: Layer.cs プロジェクト: backviet01/winengine
 public void Sort(IComparator<IEntity> comparator)
 {
     ZIndexSorter.Instance().Sort(children, comparator);
 }