If I have a TreeSet and I use contains() on the Set view of keySet() is the time complexity O(1)?
Map<String, Integer> map1 = new TreeMap<>();
map1.keySet().contains(xyz);
I am wondering as for example contains() for HashSet and LinkedHashSet is O(1) but for a TreeSet is O(log(N)) but the keySet() method is not returning a HashSet, LinkedSet or TreeSet but just a Set view in general thus making me unsure.
I checked here and here but could not find any performance related information.
I have since found this question: What is a view of a collection?
This makes me think the call of contains() is then made by the TreeMap and not the Set and would therefore be O(log(N))?