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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package Torello.Java.ReadOnly;

import Torello.Java.Additional.RemoveUnsupportedIterator;
    
import java.util.Collections;
import java.util.Set;
import java.util.Collection;
import java.util.Comparator;
import java.util.SortedSet;
import java.util.TreeSet;

class JavaHTMLReadOnlySortedSet<E> implements ReadOnlySortedSet<E>
{
    private final SortedSet<E> ss;

    JavaHTMLReadOnlySortedSet(SortedSet<E> ss)
    { this.ss = ss; }

    public Comparator<? super E> comparator()
    { return ss.comparator(); }

    public ReadOnlySortedSet<E> subSet(E fromElement, E toElement)
    { return new JavaHTMLReadOnlySortedSet<>(ss.subSet(fromElement, toElement)); }

    public ReadOnlySortedSet<E> headSet(E toElement)
    { return new JavaHTMLReadOnlySortedSet<>(ss.headSet(toElement)); }

    public ReadOnlySortedSet<E> tailSet(E fromElement)
    { return new JavaHTMLReadOnlySortedSet<>(ss.tailSet(fromElement)); }

    public E first()    { return ss.first(); }
    public E last()     { return ss.last(); }


    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    // Block Copied from ReadOnlySet
    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

    public int      size()                          { return ss.size(); }
    public boolean  isEmpty()                       { return ss.isEmpty(); }
    public boolean  contains(Object o)              { return ss.contains(o); }

    public Object[] toArray()                       { return ss.toArray(); }
    public <T> T[]  toArray(T[] a)                  { return ss.toArray(a); }
    public boolean  containsAll(Collection<?> c)    { return ss.containsAll(c); }

    public RemoveUnsupportedIterator<E> iterator()
    { return new RemoveUnsupportedIterator<>(ss.iterator()); }


    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    // To Java-Collections Types
    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

    @SuppressWarnings("unchecked")
    public Set<E> cloneToSet()
    { return new TreeSet<>(ss); }

    public Set<E> wrapToImmutableSet()
    { return Collections.unmodifiableSortedSet(ss); }


    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    // java.lang.Object
    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

    public int hashCode()
    { return ss.hashCode(); }

    public boolean equals(Object other)
    { return ROHelperEquals.roSetEq(this, other); }

    public String toString()
    { return ss.toString(); }
}