Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Utils/SceneIndexComparer.cs @ 15682

Last change on this file since 15682 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 1.4 KB
Line 
1using System.Collections;
2using System.Collections.Generic;
3namespace Netron.Diagramming.Core {
4  /// <summary>
5  /// This <see cref="IComparer"/> compares two diagram entities with respect to their scene index.
6  /// A diagram entity is 'less' than another if the scene index is smaller. Note that two distinct entities can never
7  /// have the same scene index. Since this comparer is used in the first place to re-order the <see cref="IPaintable"/> collection
8  /// it will throw an exception if two indices are found to be the same.
9  /// </summary>
10  /// <typeparam name="T"></typeparam>
11  class SceneIndexComparer<T> : IComparer<T> where T : IDiagramEntity {
12    /// <summary>
13    /// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
14    /// </summary>
15    /// <param name="x">The first object to compare.</param>
16    /// <param name="y">The second object to compare.</param>
17    /// <returns>
18    /// Value Condition Less than zerox is less than y.Zerox equals y.Greater than zerox is greater than y.
19    /// </returns>
20    public int Compare(T x, T y) {
21      if (x.SceneIndex == y.SceneIndex)
22        throw new InconsistencyException("Inconsistent stack: two entities had the same scene index.");
23
24      if (x.SceneIndex < y.SceneIndex)
25        return -1;
26      else
27        return +1;
28    }
29
30
31  }
32}
Note: See TracBrowser for help on using the repository browser.