Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 2768 was 2768, checked in by mkommend, 14 years ago

added solution folders and sources for the netron library (ticket #867)

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