コード例 #1
0
ファイル: RangeTree.cs プロジェクト: erdomke/RangeTree
        /// <summary>
        /// Removes the specified item. Tree will go out of sync.
        /// </summary>
        public bool Remove(RangeValuePair <TKey, TValue> item)
        {
            var removed = _items.Remove(item);

            _isInSync = _isInSync && !removed;
            return(removed);
        }
コード例 #2
0
        /// <summary>
        /// Returns less than 0 if this range's From is less than the other, greater than 0 if greater.
        /// If both are equal, the comparison of the To values is returned.
        /// 0 if both ranges are equal.
        /// </summary>
        /// <param name="y">The other.</param>
        /// <returns></returns>
        int IComparer <RangeValuePair <TKey, TValue> > .Compare(RangeValuePair <TKey, TValue> x, RangeValuePair <TKey, TValue> y)
        {
            var fromComp = _comparer.Compare(x.From, y.From);

            if (fromComp == 0)
            {
                return(_comparer.Compare(x.To, y.To));
            }
            return(fromComp);
        }
コード例 #3
0
ファイル: RangeTree.cs プロジェクト: erdomke/RangeTree
 public bool Contains(RangeValuePair <TKey, TValue> item)
 {
     return(_items.Contains(item));
 }
コード例 #4
0
ファイル: RangeTree.cs プロジェクト: erdomke/RangeTree
 /// <summary>
 /// Adds the specified item. Tree will go out of sync.
 /// </summary>
 public void Add(RangeValuePair <TKey, TValue> item)
 {
     Add(item.From, item.To, item.Value);
 }
コード例 #5
0
 public bool Equals(RangeValuePair <TKey, TValue> other)
 {
     return(EqualityComparer <TKey> .Default.Equals(From, other.From) &&
            EqualityComparer <TKey> .Default.Equals(To, other.To) &&
            EqualityComparer <TValue> .Default.Equals(Value, other.Value));
 }