16232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson/* 26232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * Written by Doug Lea with assistance from members of JCP JSR-166 36232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * Expert Group and released to the public domain, as explained at 4a807b4d808d2591894daf13aab179b2e9c46a2f5Jesse Wilson * http://creativecommons.org/publicdomain/zero/1.0/ 56232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson */ 66232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson 76232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilsonpackage java.util.concurrent; 8edf43d27e240d82106f39ae91404963c23987234Narayan Kamath 9e8b323c7cb7d55be9a4df579231e44f04f53d766Przemyslaw Szczepaniakimport java.util.NavigableMap; 10e8b323c7cb7d55be9a4df579231e44f04f53d766Przemyslaw Szczepaniakimport java.util.NavigableSet; 116232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson 12a807b4d808d2591894daf13aab179b2e9c46a2f5Jesse Wilson// BEGIN android-note 13a807b4d808d2591894daf13aab179b2e9c46a2f5Jesse Wilson// removed link to collections framework docs 14a807b4d808d2591894daf13aab179b2e9c46a2f5Jesse Wilson// END android-note 15a807b4d808d2591894daf13aab179b2e9c46a2f5Jesse Wilson 166232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson/** 176232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * A {@link ConcurrentMap} supporting {@link NavigableMap} operations, 186232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * and recursively so for its navigable sub-maps. 196232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * 206232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @author Doug Lea 216232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @param <K> the type of keys maintained by this map 226232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @param <V> the type of mapped values 236232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @since 1.6 246232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson */ 256232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilsonpublic interface ConcurrentNavigableMap<K,V> 266232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson extends ConcurrentMap<K,V>, NavigableMap<K,V> 276232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson{ 286232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson /** 296232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws ClassCastException {@inheritDoc} 306232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws NullPointerException {@inheritDoc} 316232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws IllegalArgumentException {@inheritDoc} 326232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson */ 336232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson ConcurrentNavigableMap<K,V> subMap(K fromKey, boolean fromInclusive, 346232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson K toKey, boolean toInclusive); 356232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson 366232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson /** 376232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws ClassCastException {@inheritDoc} 386232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws NullPointerException {@inheritDoc} 396232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws IllegalArgumentException {@inheritDoc} 406232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson */ 416232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson ConcurrentNavigableMap<K,V> headMap(K toKey, boolean inclusive); 426232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson 436232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson /** 446232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws ClassCastException {@inheritDoc} 456232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws NullPointerException {@inheritDoc} 466232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws IllegalArgumentException {@inheritDoc} 476232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson */ 486232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson ConcurrentNavigableMap<K,V> tailMap(K fromKey, boolean inclusive); 496232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson 506232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson /** 516232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws ClassCastException {@inheritDoc} 526232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws NullPointerException {@inheritDoc} 536232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws IllegalArgumentException {@inheritDoc} 546232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson */ 556232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson ConcurrentNavigableMap<K,V> subMap(K fromKey, K toKey); 566232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson 576232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson /** 586232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws ClassCastException {@inheritDoc} 596232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws NullPointerException {@inheritDoc} 606232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws IllegalArgumentException {@inheritDoc} 616232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson */ 626232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson ConcurrentNavigableMap<K,V> headMap(K toKey); 636232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson 646232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson /** 656232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws ClassCastException {@inheritDoc} 666232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws NullPointerException {@inheritDoc} 676232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @throws IllegalArgumentException {@inheritDoc} 686232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson */ 696232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson ConcurrentNavigableMap<K,V> tailMap(K fromKey); 706232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson 716232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson /** 726232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * Returns a reverse order view of the mappings contained in this map. 736232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * The descending map is backed by this map, so changes to the map are 746232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * reflected in the descending map, and vice-versa. 756232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * 766232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * <p>The returned map has an ordering equivalent to 77e8b323c7cb7d55be9a4df579231e44f04f53d766Przemyslaw Szczepaniak * {@link java.util.Collections#reverseOrder(Comparator) Collections.reverseOrder}{@code (comparator())}. 786232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * The expression {@code m.descendingMap().descendingMap()} returns a 796232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * view of {@code m} essentially equivalent to {@code m}. 806232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * 816232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @return a reverse order view of this map 826232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson */ 836232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson ConcurrentNavigableMap<K,V> descendingMap(); 846232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson 856232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson /** 866232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * Returns a {@link NavigableSet} view of the keys contained in this map. 876232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * The set's iterator returns the keys in ascending order. 886232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * The set is backed by the map, so changes to the map are 896232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * reflected in the set, and vice-versa. The set supports element 906232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * removal, which removes the corresponding mapping from the map, 916232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * via the {@code Iterator.remove}, {@code Set.remove}, 926232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * {@code removeAll}, {@code retainAll}, and {@code clear} 936232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * operations. It does not support the {@code add} or {@code addAll} 946232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * operations. 956232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * 96e8b323c7cb7d55be9a4df579231e44f04f53d766Przemyslaw Szczepaniak * <p>The view's iterators and spliterators are 97e8b323c7cb7d55be9a4df579231e44f04f53d766Przemyslaw Szczepaniak * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. 986232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * 996232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @return a navigable set view of the keys in this map 1006232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson */ 101e8b323c7cb7d55be9a4df579231e44f04f53d766Przemyslaw Szczepaniak NavigableSet<K> navigableKeySet(); 1026232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson 1036232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson /** 1046232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * Returns a {@link NavigableSet} view of the keys contained in this map. 1056232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * The set's iterator returns the keys in ascending order. 1066232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * The set is backed by the map, so changes to the map are 1076232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * reflected in the set, and vice-versa. The set supports element 1086232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * removal, which removes the corresponding mapping from the map, 1096232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * via the {@code Iterator.remove}, {@code Set.remove}, 1106232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * {@code removeAll}, {@code retainAll}, and {@code clear} 1116232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * operations. It does not support the {@code add} or {@code addAll} 1126232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * operations. 1136232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * 114e8b323c7cb7d55be9a4df579231e44f04f53d766Przemyslaw Szczepaniak * <p>The view's iterators and spliterators are 115e8b323c7cb7d55be9a4df579231e44f04f53d766Przemyslaw Szczepaniak * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. 1166232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * 1176232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * <p>This method is equivalent to method {@code navigableKeySet}. 1186232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * 1196232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @return a navigable set view of the keys in this map 1206232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson */ 1216232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson NavigableSet<K> keySet(); 1226232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson 1236232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson /** 1246232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * Returns a reverse order {@link NavigableSet} view of the keys contained in this map. 1256232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * The set's iterator returns the keys in descending order. 1266232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * The set is backed by the map, so changes to the map are 1276232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * reflected in the set, and vice-versa. The set supports element 1286232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * removal, which removes the corresponding mapping from the map, 1296232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * via the {@code Iterator.remove}, {@code Set.remove}, 1306232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * {@code removeAll}, {@code retainAll}, and {@code clear} 1316232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * operations. It does not support the {@code add} or {@code addAll} 1326232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * operations. 1336232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * 134e8b323c7cb7d55be9a4df579231e44f04f53d766Przemyslaw Szczepaniak * <p>The view's iterators and spliterators are 135e8b323c7cb7d55be9a4df579231e44f04f53d766Przemyslaw Szczepaniak * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>. 1366232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * 1376232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson * @return a reverse order navigable set view of the keys in this map 1386232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson */ 139e8b323c7cb7d55be9a4df579231e44f04f53d766Przemyslaw Szczepaniak NavigableSet<K> descendingKeySet(); 1406232a5efed0ea103e35aec73206e5e03a8b82e0cJesse Wilson} 141