public bool IsItemsEqual(SelectionRange rangeIntersection, SelectionRangeWithItems rangeWithItemsToCompare) { OptimizedItemsList itemsToCompare = rangeWithItemsToCompare.m_items; if ((m_items == null) || (itemsToCompare == null)) { return(true); } SelectionRange rangeToCompare = rangeWithItemsToCompare.Range; int startIndex = Math.Min(rangeIntersection.StartIndex, rangeIntersection.EndIndex); int itemIndex1 = Math.Abs(startIndex - m_range.StartIndex); int itemIndex2 = Math.Abs(startIndex - rangeToCompare.StartIndex); bool inversedRange1 = m_range.StartIndex > m_range.EndIndex; bool inversedRange2 = rangeToCompare.StartIndex > rangeToCompare.EndIndex; int count = rangeIntersection.Length; for (int i = 0; i < count; i++) { if (!object.Equals(m_items[itemIndex1], itemsToCompare[itemIndex2])) { return(false); } itemIndex1 = inversedRange1 ? itemIndex1 - 1 : itemIndex1 + 1; itemIndex2 = inversedRange2 ? itemIndex2 - 1 : itemIndex2 + 1; } return(true); }
internal SelectionRangeWithItems( SelectionRange range, SharedList items ) { if( ( items.Count != range.Length ) && ( !range.IsEmpty ) ) throw new ArgumentException( "selectionRange and items must have the same length." ); m_items = new OptimizedItemsList( items ); m_range = range; }
internal SelectionRangeWithItems(SelectionRange range, SharedList items) { if ((items.Count != range.Length) && (!range.IsEmpty)) { throw new ArgumentException("selectionRange and items must have the same length."); } m_items = new OptimizedItemsList(items); m_range = range; }