Util: Fix UnmodifiableSortedSet compiler warnings

This commit is contained in:
zzz
2022-07-05 12:02:28 -04:00
parent 9a9722dd3e
commit 9489b41cb7
2 changed files with 7 additions and 2 deletions

View File

@@ -39,14 +39,14 @@ public class OrderedProperties extends Properties {
public Set<Object> keySet() {
if (size() <= 1)
return super.keySet();
return new UnmodifiableSortedSet(super.keySet());
return new UnmodifiableSortedSet<Object>(super.keySet());
}
@Override
public Set<Map.Entry<Object, Object>> entrySet() {
if (size() <= 1)
return super.entrySet();
return new UnmodifiableSortedSet(super.entrySet(), ECOMP);
return new UnmodifiableSortedSet<Map.Entry<Object, Object>>(super.entrySet(), ECOMP);
}
private static class EntryComparator implements Comparator<Map.Entry<Object, Object>>, Serializable {

View File

@@ -39,6 +39,7 @@ public class UnmodifiableSortedSet<E> extends ArraySet<E> implements SortedSet<E
this(c, null);
}
@SuppressWarnings("unchecked")
public UnmodifiableSortedSet(Set<? extends E> c, Comparator<? super E> comparator) {
super(c, c.size());
comp = comparator;
@@ -58,6 +59,7 @@ public class UnmodifiableSortedSet<E> extends ArraySet<E> implements SortedSet<E
/**
* Warning: O(n**2)
*/
@SuppressWarnings("unchecked")
public UnmodifiableSortedSet(Collection<? extends E> c, Comparator<? super E> comparator) {
super(c, c.size());
comp = comparator;
@@ -69,12 +71,14 @@ public class UnmodifiableSortedSet<E> extends ArraySet<E> implements SortedSet<E
public Comparator<? super E> comparator() { return comp; }
@SuppressWarnings("unchecked")
public E first() {
if (isEmpty())
throw new NoSuchElementException();
return (E) _entries[0];
}
@SuppressWarnings("unchecked")
public E last() {
int sz = size();
if (sz <= 0)
@@ -145,6 +149,7 @@ public class UnmodifiableSortedSet<E> extends ArraySet<E> implements SortedSet<E
* Overridden to do binary search
*/
@Override
@SuppressWarnings("unchecked")
protected int indexOf(Object o) {
// don't do this if comp is not initialized and array is not sorted
if (! initialized)