Ejemplo n.º 1
0
        private int BinarySearch <K>(K key, IItemComparer <K, T> comparer)
        {
            int start = 0;
            int size  = this.size;

            while ((size - start) > 8)
            {
                int index = (size + start) / 2;
                int num4  = comparer.Compare(key, this.buffer[index]);
                if (num4 < 0)
                {
                    size = index;
                }
                else
                {
                    if (num4 > 0)
                    {
                        start = index + 1;
                        continue;
                    }
                    return(index);
                }
            }
            return(this.LinearSearch <K>(key, comparer, start, size));
        }
Ejemplo n.º 2
0
        private int BinarySearch <K>(K key, IItemComparer <K, T> comparer)
        {
            // [low, high)
            int low = 0;
            int high = Count;
            int mid, result;

            // Binary search is implemented here so we could look for a type that is different from the
            // buffer type.  Also, the search switches to linear for 8 or fewer elements.
            while (high - low > 8)
            {
                mid    = (high + low) / 2;
                result = comparer.Compare(key, _buffer[mid]);
                if (result < 0)
                {
                    high = mid;
                }
                else if (result > 0)
                {
                    low = mid + 1;
                }
                else
                {
                    return(mid);
                }
            }

            return(LinearSearch <K>(key, comparer, low, high));
        }
Ejemplo n.º 3
0
 private int Search <K>(K key, IItemComparer <K, T> comparer)
 {
     if (this.size <= 8)
     {
         return(this.LinearSearch <K>(key, comparer, 0, this.size));
     }
     return(this.BinarySearch <K>(key, comparer));
 }
 public ContentItemInstaller()
 {
     _logger      = Bootstrap.Container.Resolve <IDefaultLogger>();
     _scDatastore = Bootstrap.Container.Resolve <IDataStore>(_logger);
     _sitecore    = Bootstrap.Container.Resolve <ISitecoreDataAccessService>();
     _jsonSerializationService = Bootstrap.Container.Resolve <IJsonSerializationService>();
     _comparer = Bootstrap.Container.Resolve <IItemComparer>();
 }
Ejemplo n.º 5
0
 int Search <K>(K key, IItemComparer <K, T> comparer)
 {
     if (this.size <= 8)
     {
         return(LinearSearch <K>(key, comparer, 0, this.size));
     }
     else
     {
         return(BinarySearch(key, comparer));
     }
 }
Ejemplo n.º 6
0
 private int Search <K>(K key, IItemComparer <K, T> comparer)
 {
     if (Count <= 8)
     {
         return(LinearSearch <K>(key, comparer, 0, Count));
     }
     else
     {
         return(BinarySearch(key, comparer));
     }
 }
Ejemplo n.º 7
0
        public SerializedAsMasterEvaluator(ISerializedAsMasterEvaluatorLogger logger, IItemComparer itemComparer, IFieldFilter fieldFilter, ISourceDataStore sourceDataStore)
        {
            Assert.ArgumentNotNull(logger, "logger");
            Assert.ArgumentNotNull(itemComparer, "itemComparer");
            Assert.ArgumentNotNull(fieldFilter, "fieldFilter");
            Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore");

            _logger          = logger;
            _itemComparer    = itemComparer;
            _fieldFilter     = fieldFilter;
            _sourceDataStore = sourceDataStore;
        }
Ejemplo n.º 8
0
        public SerializedAsMasterEvaluator(ISerializedAsMasterEvaluatorLogger logger, IItemComparer itemComparer, IFieldFilter fieldFilter, ISourceDataStore sourceDataStore)
        {
            Assert.ArgumentNotNull(logger, "logger");
            Assert.ArgumentNotNull(itemComparer, "itemComparer");
            Assert.ArgumentNotNull(fieldFilter, "fieldFilter");
            Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore");

            _logger = logger;
            _itemComparer = itemComparer;
            _fieldFilter = fieldFilter;
            _sourceDataStore = sourceDataStore;
        }
Ejemplo n.º 9
0
        public SerializedAsMasterEvaluator(ILogger globalLogger, ISerializedAsMasterEvaluatorLogger logger, IItemComparer itemComparer, IFieldFilter fieldFilter, ISourceDataStore sourceDataStore, ITargetDataStore targetDataStore) : base(logger, sourceDataStore, targetDataStore)
        {
            Assert.ArgumentNotNull(globalLogger, "globalLogger");
            Assert.ArgumentNotNull(logger, "logger");
            Assert.ArgumentNotNull(itemComparer, "itemComparer");
            Assert.ArgumentNotNull(fieldFilter, "fieldFilter");
            Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore");

            _globalLogger    = globalLogger;
            _logger          = logger;
            _itemComparer    = itemComparer;
            _fieldFilter     = fieldFilter;
            _sourceDataStore = sourceDataStore;
        }
Ejemplo n.º 10
0
		public SerializedAsMasterEvaluator(ILogger globalLogger, ISerializedAsMasterEvaluatorLogger logger, IItemComparer itemComparer, IFieldFilter fieldFilter, ISourceDataStore sourceDataStore, ITargetDataStore targetDataStore, IConfiguration parentConfiguration) : base(logger, sourceDataStore, targetDataStore, parentConfiguration)
		{
			Assert.ArgumentNotNull(globalLogger, "globalLogger");
			Assert.ArgumentNotNull(logger, "logger");
			Assert.ArgumentNotNull(itemComparer, "itemComparer");
			Assert.ArgumentNotNull(fieldFilter, "fieldFilter");
			Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore");

			_globalLogger = globalLogger;
			_logger = logger;
			_itemComparer = itemComparer;
			_fieldFilter = fieldFilter;
			_sourceDataStore = sourceDataStore;
			_parentConfiguration = parentConfiguration;
		}
Ejemplo n.º 11
0
 private int LinearSearch <K>(K key, IItemComparer <K, T> comparer, int start, int bound)
 {
     for (int i = start; i < bound; i++)
     {
         int num = comparer.Compare(key, this.buffer[i]);
         if (num == 0)
         {
             return(i);
         }
         if (num < 0)
         {
             return(~i);
         }
     }
     return(~bound);
 }
Ejemplo n.º 12
0
 public void Sort(IItemComparer <T> comparer)
 {
     for (var i = 0; i < _list.Count - 1; i++)
     {
         for (var j = i + 1; j < _list.Count; j++)
         {
             var left  = (T)_list[i];
             var right = (T)_list[j];
             if (comparer.Compare(left, right) > 0)
             {
                 var temp = left;
                 _list[i] = _list[j];
                 _list[j] = temp;
             }
         }
     }
 }
        /*
         * public void SortById()
         * {
         *  for (var i = 0; i < Count - 1; i++)
         *  {
         *      for (var j = i + 1; j < Count; j++)
         *      {
         *          var leftProduct = (Product)list[i];
         *          var rightProduct = (Product)list[j];
         *          if (leftProduct.Id > rightProduct.Id)
         *          {
         *              var temp = leftProduct;
         *              list[i] = list[j];
         *              list[j] = temp;
         *          }
         *      }
         *  }
         * }
         */

        public void Sort(IItemComparer <T> comparer)
        {
            for (var i = 0; i < Count - 1; i++)
            {
                for (var j = i + 1; j < Count; j++)
                {
                    var leftItem  = (T)list[i];
                    var rightItem = (T)list[j];
                    if (comparer.Compare(leftItem, rightItem) > 0)
                    {
                        var temp = leftItem;
                        list[i] = list[j];
                        list[j] = temp;
                    }
                }
            }
        }
Ejemplo n.º 14
0
 public void Sort(IItemComparer <T> comparer)
 {
     for (var i = 0; i < this.list.Count - 1; i++)
     {
         for (var j = i + 1; j < this.list.Count; j++)
         {
             var p1 = (T)this.list[i];
             var p2 = (T)this.list[j];
             if (comparer.Compare(p1, p2) > 0)
             {
                 var temp = this.list[i];
                 this.list[i] = this.list[j];
                 this.list[j] = temp;
             }
         }
     }
 }
Ejemplo n.º 15
0
        // [start, bound)
        private int LinearSearch <K>(K key, IItemComparer <K, T> comparer, int start, int bound)
        {
            int result;

            for (int i = start; i < bound; ++i)
            {
                result = comparer.Compare(key, _buffer[i]);
                if (result == 0)
                {
                    return(i);
                }

                if (result < 0)
                {
                    // Return the bitwise negation of the insertion index
                    return(~i);
                }
            }

            // Return the bitwise negation of the insertion index
            return(~bound);
        }
Ejemplo n.º 16
0
 internal int IndexOfKey <K>(K key, IItemComparer <K, T> itemComp)
 {
     return(Search(key, itemComp));
 }
 protected MatchProcessor(IEvaluator <T> evaluator, IItemComparer <T> comparer, ILogger?logger)
 {
     _evaluator = evaluator ?? throw new ArgumentNullException(nameof(evaluator));
     _comparer  = comparer ?? throw new ArgumentNullException(nameof(comparer));
     _logger    = logger;
 }
Ejemplo n.º 18
0
 public DescendingProductComparer(IItemComparer <Product> comparer)
 {
     this._comparer = comparer;
 }
Ejemplo n.º 19
0
		public static void SetDefaultSortComparer(ListView element, IItemComparer value)
		{
			element.SetValue(DefaultSortComparerProperty, value);
		}
Ejemplo n.º 20
0
 public Identifiers(IItemComparer comparer, bool order)
 {
     this.comparer = comparer;
     this.order    = order;
 }
Ejemplo n.º 21
0
 public Identifiers(IItemComparer comparer, bool order)
 {
     this.comparer = comparer;
       this.order = order;
 }
Ejemplo n.º 22
0
		private static void DoSort(ListView listView, IItemComparer comparer)
		{
			var tree = (TreeList)listView;
			if (tree != null && comparer != null)
				tree.Root.RunSort(comparer);
		}
 protected ElementMatchProcessor(IEvaluator <T> evaluator, IItemComparer <T> comparer, ILogger?logger) : base(evaluator, comparer, logger)
 {
 }
Ejemplo n.º 24
0
 public EmergingPatternComparer(IItemComparer comparer)
 {
     this.comparer = comparer;
 }
Ejemplo n.º 25
0
		public void RunSort(IItemComparer itemComparer)
		{
			if (SortDirection == null)
				SortDirection = ListSortDirection.Ascending;
			ItemComparer = itemComparer;
			var selected = SelectedTreeNode;
			Sort();
			SelectedTreeNode = selected;
		}
Ejemplo n.º 26
0
		public void RunSort(GridViewColumn column, IItemComparer itemComparer)
		{
			SortDirection = column == SortColumn ? (SortDirection == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending) : ListSortDirection.Ascending;
			SortColumn = column;
			RunSort(itemComparer);
		}
Ejemplo n.º 27
0
 public MatchFinder(
     IItemComparer <TTransaction2, TTransaction1> comparer)
 {
     this.comparer = comparer;
 }
		private IList<string> GetFieldSyncStatus(IItemData itemData, IItemData serializedItemData, IFieldFilter fieldFilter, IItemComparer itemComparer)
		{
			var comparison = itemComparer.Compare(new FilteredItem(itemData, fieldFilter), new FilteredItem(serializedItemData, fieldFilter));

			var db = Factory.GetDatabase(itemData.DatabaseName);

			var changedFields = comparison.ChangedSharedFields
				.Concat(comparison.ChangedVersions.SelectMany(version => version.ChangedFields))
				.Select(field => db.GetItem(new ID((field.SourceField ?? field.TargetField).FieldId)))
				.Where(field => field != null)
				.Select(field => field.DisplayName)
				.ToList();

			if (comparison.IsMoved) changedFields.Add("Item has been moved");
			if (comparison.IsRenamed) changedFields.Add("Item has been renamed");
			if (comparison.IsTemplateChanged) changedFields.Add("Item's template has changed");
			if (comparison.ChangedVersions.Any(version => version.SourceVersion == null || version.TargetVersion == null)) changedFields.Add("Item versions do not match");

			return changedFields;
		}
 public EmergingPatternSimplifier(IItemComparer comparer)
 {
     _collection = new FilteredCollection <Item>(comparer.Compare, SubsetRelation.Subset);
 }
        private SerializedAsMasterEvaluator CreateTestEvaluator(ISerializedAsMasterEvaluatorLogger logger = null, IDeserializer deserializer = null, IItemComparer comparer = null)
        {
            if (deserializer == null) deserializer = Substitute.For<IDeserializer>();

            var dataStore = new ConfigurationDataStore(new Lazy<IDataStore>(() => new SitecoreDataStore(deserializer)));

            if (comparer == null)
            {
                comparer = Substitute.For<IItemComparer>();
                comparer.FastCompare(Arg.Any<IItemData>(), Arg.Any<IItemData>()).Returns(new ItemComparisonResult(new FakeItem(), new FakeItem()));
            }

            return new SerializedAsMasterEvaluator(Substitute.For<ILogger>(), logger ?? Substitute.For<ISerializedAsMasterEvaluatorLogger>(), comparer, CreateTestFieldFilter(), dataStore, Substitute.For<ITargetDataStore>(), Substitute.For<IConfiguration>());
        }
 public Wrapper(IEvaluator <IClassDefinition> evaluator, IItemComparer <IClassDefinition> comparer,
                ILogger?logger) : base(evaluator, comparer, logger)
 {
 }
Ejemplo n.º 32
0
        private SerializedAsMasterEvaluator CreateTestEvaluator(ISerializedAsMasterEvaluatorLogger logger = null, IDeserializer deserializer = null, IItemComparer comparer = null)
        {
            if (deserializer == null)
            {
                deserializer = Substitute.For <IDeserializer>();
            }

            var dataStore = new ConfigurationDataStore(new Lazy <IDataStore>(() => new SitecoreDataStore(deserializer)));

            if (comparer == null)
            {
                comparer = Substitute.For <IItemComparer>();
                comparer.FastCompare(Arg.Any <IItemData>(), Arg.Any <IItemData>()).Returns(new ItemComparisonResult(CreateTestItem(), CreateTestItem()));
            }

            return(new SerializedAsMasterEvaluator(Substitute.For <ILogger>(), logger ?? Substitute.For <ISerializedAsMasterEvaluatorLogger>(), comparer, CreateTestFieldFilter(), dataStore, Substitute.For <ITargetDataStore>(), Substitute.For <IConfiguration>()));
        }
Ejemplo n.º 33
0
        private IList <string> GetFieldSyncStatus(IItemData itemData, IItemData serializedItemData, IFieldFilter fieldFilter, IItemComparer itemComparer)
        {
            var comparison = itemComparer.Compare(new FilteredItem(itemData, fieldFilter), new FilteredItem(serializedItemData, fieldFilter));

            var db = Factory.GetDatabase(itemData.DatabaseName);

            var changedFields = comparison.ChangedSharedFields
                                .Concat(comparison.ChangedVersions.SelectMany(version => version.ChangedFields))
                                .Select(field => db.GetItem(new ID((field.SourceField ?? field.TargetField).FieldId)))
                                .Where(field => field != null)
                                .Select(field => field.DisplayName)
                                .ToList();

            if (comparison.IsMoved)
            {
                changedFields.Add("Item has been moved");
            }
            if (comparison.IsRenamed)
            {
                changedFields.Add("Item has been renamed");
            }
            if (comparison.IsTemplateChanged)
            {
                changedFields.Add("Item's template has changed");
            }
            if (comparison.ChangedVersions.Any(version => version.SourceVersion == null || version.TargetVersion == null))
            {
                changedFields.Add("Item versions do not match");
            }

            return(changedFields);
        }
Ejemplo n.º 34
0
		public static void SetSortComparer(GridViewColumn element, IItemComparer value)
		{
			element.SetValue(SortComparerProperty, value);
		}