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)

PUBLIC SortedSet()

PUBLIC SortedSet(INPUT comparer AS Progress.Collections.IComparer<T>)
comparer
An IComparer object that is used to order the values in the SortedSet<T>.

Super Class

Progress.Lang.Object class

Interfaces

Progress.Collections.ISet<T> interface

Public Properties

Count property (Collections) First property (Collections)
IsEmpty property (Collections) Last property (Collections)

Public Methods

Add( ) method (Collections) AddAll( ) method (Collections)
Clear( ) method (Collections) Contains( ) method (Collections)
Get( ) method (Set Collections) GetIterator( ) method (Collections)
Remove( ) method (Collections)

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.

USING Progress.Collections.*.

var SortedSet<Person> personSet1, personSet2.

// This is ok because Person implements IComparable<T>
personSet1 = new SortedSet<Person>().

// This one uses PersonComparer to order the elements
personSet2 = new SortedSet<Person>(new PersonComparer()).

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.

var Progress.Collections.ISet<President> presidentSet.
var Progress.Collections.IIterator<President> iterator.

presidentSet = new Progress.Collections.SortedSet<President>().

// Add 3 elements to the set
presidentSet:Add(new President("Thomas")).
presidentSet:Add(new President("George")).
presidentSet:Add(new President ("John")).

// Print out the number of presidents in the set
message presidentSet:Count.

// Iterate over the entries in the set
iterator = presidentSet:GetIterator().
repeat while iterator:MoveNext():
  message iterator:Current:ToString().
end.

Notes

  • The SortedSet implementation supports any object-oriented ABL object. This includes .NET objects, however you must specify your own comparer when adding .NET objects to a SortedSet (that is, natural ordering is not supported in this case).
  • The default constructor (with no parameters) creates an instance of SortedSet with a default comparer. The default comparer requires that the elements added to the collection implement Progress.Collection.IComparable<T>.
  • The custom constructor returns an instance of SortedSet with the specified comparer. The comparer is used by SortedSet to 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 implement IComparer<T> (if invoked dynamically), where T is the same type as SortedSet<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() or Compare() methods. The SortedSet itself 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 Sortedset is 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 the SortedSet in any way.

See also

<T> Generic type reference