From 8ac58b7d772a92b3d4cbcb06dba64644a3d7cd51 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 5 Nov 2014 14:27:24 -0700 Subject: [PATCH] add minimal NavigableMap interface --- classpath/java/util/NavigableMap.java | 6 ++++++ classpath/java/util/TreeMap.java | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 classpath/java/util/NavigableMap.java diff --git a/classpath/java/util/NavigableMap.java b/classpath/java/util/NavigableMap.java new file mode 100644 index 0000000000..05136159c6 --- /dev/null +++ b/classpath/java/util/NavigableMap.java @@ -0,0 +1,6 @@ +package java.util; + +public interface NavigableMap extends SortedMap { + Map.Entry firstEntry(); + Map.Entry lastEntry(); +} diff --git a/classpath/java/util/TreeMap.java b/classpath/java/util/TreeMap.java index e7258255cd..3c4de1b141 100644 --- a/classpath/java/util/TreeMap.java +++ b/classpath/java/util/TreeMap.java @@ -14,7 +14,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -public class TreeMap implements SortedMap { +public class TreeMap implements NavigableMap { private final Comparator comparator; private transient TreeSet> set; @@ -50,6 +50,16 @@ public class TreeMap implements SortedMap { return comparator; } + @Override + public Map.Entry firstEntry() { + return set.first(); + } + + @Override + public Map.Entry lastEntry() { + return set.last(); + } + @Override public K firstKey() { return set.first().key;