Progress.Collections.SortedSet<T> class
- Last Updated: March 15, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Represents a strongly-typed collection of unique objects that is maintained in sorted order. Provides properties and methods to search and manipulate sorted sets.
Serializable:
Yes
Constructor(s)
|
- comparer
- An
IComparerobject that is used to order the values in theSortedSet<T>.
Super Class
Interfaces
Public Properties
| Count property (Collections) | First property (Collections) |
| IsEmpty property (Collections) | Last property (Collections) |
Public Methods
Public Events
This class does not contain events.
Examples
The following example demonstrates how to instantiate a sorted set using the default comparer and a custom comparer.
|
The following example demonstrates how to add elements to, and iterate over,
a sorted set collection. The example assumes a class called President, which implements IComparable<T>,
which sorts the elements in alphabetical order by the name passed in.
|
Notes
- The
SortedSetimplementation supports any object-oriented ABL object. This includes .NET objects, however you must specify your own comparer when adding .NET objects to aSortedSet(that is, natural ordering is not supported in this case). - The default constructor (with no parameters) creates an instance of
SortedSetwith a default comparer. The default comparer requires that the elements added to the collection implementProgress.Collection.IComparable<T>. - The custom constructor returns an instance of
SortedSetwith the specified comparer. The comparer is used bySortedSetto perform the comparison of objects when sorting the elements. The constructor raises an error if the comparer object is not valid, or if the object does not implementIComparer<T>(if invoked dynamically), whereTis the same type asSortedSet<T>. - Duplicate elements are not allowed in the sorted set. Note that the
comparer implementation is what actually defines what a duplicate element is, by
the value returned by the
CompareTo()orCompare()methods. TheSortedSetitself does not participate in determining that an object is duplicate or not, it simply follows what the comparer implementation defines. - Explicitly deleting object instances while they are in a
Sortedsetis not supported. You should remove the element from the set before you delete the object instance, if you are still going to be interacting with theSortedSetin any way.