forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSortedSet.cs
55 lines (51 loc) · 1.89 KB
/
SortedSet.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* Copyright © 2002-2004 by Aidant Systems, Inc., and by Jason Smith. */
using System;
using System.Collections;
namespace Iesi.Collections
{
/// <summary>
/// Implements a set based on a sorted tree. This gives good performance for operations on very
/// large data-sets, though not as good - asymptotically - as a <see cref="HashedSet" />.
/// However, iteration occurs in order. Elements that you put into this type of collection must
/// implement <see cref="IComparable" />, and they must actually be comparable. You can't mix
/// <see cref="string" /> and <see cref="int" /> values, for example.
/// </summary>
[Serializable]
public class SortedSet : DictionarySet
{
/// <summary>
/// Creates a new set instance based on a sorted tree.
/// </summary>
public SortedSet()
{
InternalDictionary = new SortedList();
}
/// <summary>
/// Creates a new set instance based on a sorted tree.
/// </summary>
/// <param name="comparer">The <see cref="IComparer"/> to use for sorting.</param>
public SortedSet(IComparer comparer)
{
InternalDictionary = new SortedList(comparer);
}
/// <summary>
/// Creates a new set instance based on a sorted tree and
/// initializes it based on a collection of elements.
/// </summary>
/// <param name="initialValues">A collection of elements that defines the initial set contents.</param>
public SortedSet(ICollection initialValues) : this()
{
this.AddAll(initialValues);
}
/// <summary>
/// Creates a new set instance based on a sorted tree and
/// initializes it based on a collection of elements.
/// </summary>
/// <param name="initialValues">A collection of elements that defines the initial set contents.</param>
/// <param name="comparer">The <see cref="IComparer"/> to use for sorting.</param>
public SortedSet(ICollection initialValues, IComparer comparer) : this(comparer)
{
this.AddAll(initialValues);
}
}
}