diff options
| author | Paul Buetow <paul@buetow.org> | 2025-06-06 08:02:52 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-06-06 08:02:52 +0300 |
| commit | 1d99762c7965d351510cfb5e08eac25e48d96038 (patch) | |
| tree | f469493e911878ab9055ccf0494211bf9015922d /src/main/java/utils/VSPriorityQueue.java | |
| parent | 4d35597bd92607c4d194686e20b125044506c79a (diff) | |
Modernize project structure, update Maven config, move sources, add logging config, update README and .gitignore
Diffstat (limited to 'src/main/java/utils/VSPriorityQueue.java')
| -rw-r--r-- | src/main/java/utils/VSPriorityQueue.java | 32 |
1 files changed, 32 insertions, 0 deletions
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<T> extends PriorityQueue<T> { + /** 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; + } +} |
