classlib: small PriorityQueue fixes (#823)

This commit is contained in:
Ivan Hetman 2023-10-16 14:59:35 +03:00 committed by GitHub
parent 1900852cd8
commit 65681e74d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,8 +48,8 @@ public class TPriorityQueue<E> extends TAbstractQueue<E> implements TSerializabl
initFromSortedSet((TSortedSet<? extends E>) c); initFromSortedSet((TSortedSet<? extends E>) c);
} else { } else {
data = new Object[c.size()]; data = new Object[c.size()];
fillFromCollection(c);
setComparator(null); setComparator(null);
fillFromCollection(c);
} }
} }
@ -170,6 +170,9 @@ public class TPriorityQueue<E> extends TAbstractQueue<E> implements TSerializabl
if (version != knownVersion) { if (version != knownVersion) {
throw new TConcurrentModificationException(); throw new TConcurrentModificationException();
} }
if (index >= size) {
throw new TNoSuchElementException();
}
removeIndex = index; removeIndex = index;
return (E) data[index++]; return (E) data[index++];
} }