Exemple #1
0
        void Merge(DistanceLineCounterEntry entry, bool checkPrevious)
        {
            DistanceLineCounterSource value         = entry.Value;
            DistanceLineCounterEntry  previousEntry = null;

            if (checkPrevious)
            {
                previousEntry = rbTree.GetPreviousEntry(entry);
            }
            DistanceLineCounterEntry nextEntry = rbTree.GetNextEntry(entry);

            bool dirty = false;

            if (previousEntry != null &&
                (previousEntry.Value).SingleLineDistance == value.SingleLineDistance)
            {
                value.LineCount += (previousEntry.Value).LineCount;
                //previousEntry.InvalidateCounterBottomUp(true);
                rbTree.Remove(previousEntry);
                dirty = true;
            }

            if (nextEntry != null && (nextEntry.Value).SingleLineDistance == value.SingleLineDistance)
            {
                value.LineCount += (nextEntry.Value).LineCount;
                //nextEntry.InvalidateCounterBottomUp(true);
                rbTree.Remove(nextEntry);
                dirty = true;
            }

            if (dirty)
            {
                entry.InvalidateCounterBottomUp(true);
            }
        }
Exemple #2
0
        /// <summary>
        /// Assigns a collection with nested entities to an item.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="nestedCollection">The nested collection.</param>
        public void SetNestedDistances(int index, IDistanceCounterCollection nestedCollection)
        {
            CheckRange("index", 0, Count - 1, index);

            if (GetNestedDistances(index) != nestedCollection)
            {
                if (index >= InternalCount)
                {
                    EnsureTreeCount(index + 1);
                }

                DistanceLineCounterEntry entry = Split(index);
                Split(index + 1);

                if (nestedCollection != null)
                {
                    var vcs = new NestedDistanceCounterCollectionSource(this, nestedCollection, entry);
                    entry.Value = vcs;
                }
                else
                {
                    entry.Value = new DistanceLineCounterSource(0, 1);
                }
                entry.InvalidateCounterBottomUp(true);
            }
        }
Exemple #3
0
        /// <summary>
        /// Gets or sets the distance for an entity.
        /// </summary>
        /// <param name="index">The index for the entity</param>
        /// <returns></returns>
        public double this[int index]
        {
            get
            {
                CheckRange("index", 0, Count - 1, index);

                if (index >= InternalCount)
                {
                    return(DefaultDistance);
                }

                LineIndexEntryAt e = InitDistanceLine(index, false);
                return(e.rbValue.SingleLineDistance);
            }
            set
            {
                CheckRange("index", 0, Count - 1, index);
                if (value < 0)
                {
                    throw new ArgumentOutOfRangeException("value must not be negative.");
                }

                if (!value.Equals(this[index]))
                {
                    if (index >= InternalCount)
                    {
                        EnsureTreeCount(Count);
                    }

                    DistanceLineCounterEntry entry = Split(index);
                    Split(index + 1);
                    entry.Value.SingleLineDistance = value;
                    entry.InvalidateCounterBottomUp(true);
                }
            }
        }