Accessing the item at a specified index in a 'SortedSet'

Viewed 21469

How can I access the item at a specified index (position) in a SortedSet?

Unlike SortedList, SortedSet does not offer an Item property.

(Also, unlike SortedList, SortedSet enforces each of its members to be unique. That is, a SortedSet is guaranteed not to contain duplicates.)

4 Answers

If you intend to load the data into a set, then access the set, use HashSet and ImmutableSortedSet instead of SortedSet.

Load your data into the HashSet, then call ToImmutableSortedSet() to convert to an immutable sorted set that can be indexed.

you can use MCollections which do insert, edit, remove, search and index lookup In O(Lg(N)) time, it uses BST and stores count of sub-nodes in each node to access the item at a specified index

Related