From 1d99762c7965d351510cfb5e08eac25e48d96038 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 6 Jun 2025 08:02:52 +0300 Subject: Modernize project structure, update Maven config, move sources, add logging config, update README and .gitignore --- src/main/java/utils/VSPriorityQueue.java | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/utils/VSPriorityQueue.java (limited to 'src/main/java/utils/VSPriorityQueue.java') diff --git a/src/main/java/utils/VSPriorityQueue.java b/src/main/java/utils/VSPriorityQueue.java new file mode 100644 index 0000000..d706352 --- /dev/null +++ b/src/main/java/utils/VSPriorityQueue.java @@ -0,0 +1,32 @@ +package utils; + +import java.util.PriorityQueue; + +/** + * The class VSPriorityQueue. This class is the same like the standard + * VSPriorityQueue of the Java API. It only overrides the get(int) method. + * + * @author Paul C. Buetow + */ +public final class VSPriorityQueue extends PriorityQueue { + /** The serial version uid */ + private static final long serialVersionUID = 1L; + + /** + * Gets the specific element. If the index is out of bounds, it will return + * null. + * + * @param index the index + * + * @return the element, or null, if out of bounds + */ + public T get(int index) { + int i = 0; + + for (T t : this) + if (i++ == index) + return t; + + return null; + } +} -- cgit v1.2.3