from DataStructures by Paul Richards
Set and map datastructures implemented in pure Matlab

SortedSet(comparator)
function set = SortedSet(comparator)
    % Binary tree datastructure.
    % Can optionally take a comparator function to use specifying a custom
    % ordering. If none is given a default (using < and ==) comparator is
    % used.
    set.root = 0;
    if nargin < 1
        comparator = @DefaultComparator;
    end
    set.comparator = comparator;
        
    set = class(set, 'SortedSet');
end

Contact us at files@mathworks.com