Search code examples
javaandroidtreeset

Are TreeSet.floor() and TreeSet.ceiling() methods missing in Android?


this one is a deep mystery to me.

Take a look at this:

TreeSet<Long> s = new TreeSet<Long>();
s.add(Long.valueOf(1));
s.add(Long.valueOf(4));
s.add(Long.valueOf(6));
s.add(Long.valueOf(9));

Long upper = s.ceiling(Long.valueOf(5));
Long lower = s.floor(Long.valueOf(5));

In a normal Java VM, this compiles and runs beautifully.

If I take a look at Android's API doc, and even according to: http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/util/TreeSet.java.htm

the methods ceiling and floor should be there.

But if I try to use them in Eclipse + Android SDK (Build Target is "8"), Eclipse is telling me that floor(Long) and ceiling(Long) are not defined for class TreeSet

Any idea?

Thanks, Karlheinz


Solution

  • floor is API level 9, same goes for ceiling.

    Android javadoc for TreeSet