TreeMap and TreeSet

Download java eBook

Introduction

TreeMap and TreeSet are basic Java collections added in Java 1.2. TreeMap is a mutable, ordered, Map implementation. Similarly, TreeSet is a mutable, ordered Set implementation.

TreeMap is implemented as a Red-Black tree, which provides O(log n) access times. TreeSet is implemented using a TreeMap with dummy values.

Both collections are not thread-safe.

Related Examples

Stats

61 Contributors: 2
Monday, May 22, 2017
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook