Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.store.service; |
| 18 | |
| 19 | import java.util.Map; |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 20 | import java.util.NavigableMap; |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 21 | import java.util.NavigableSet; |
| 22 | |
| 23 | /** |
| 24 | * Tree map interface counterpart to {@link AsyncConsistentTreeMap}. |
| 25 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 26 | public interface ConsistentTreeMap<V> extends ConsistentMap<String, V> { |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * Returns the lowest key in the map. |
| 30 | * |
| 31 | * @return the key or null if none exist |
| 32 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 33 | String firstKey(); |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * Returns the highest key in the map. |
| 37 | * |
| 38 | * @return the key or null if none exist |
| 39 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 40 | String lastKey(); |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 41 | |
| 42 | /** |
| 43 | * Returns the entry associated with the least key greater than or equal to the key. |
| 44 | * |
| 45 | * @param key the key |
| 46 | * @return the entry or null |
| 47 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 48 | Map.Entry<String, Versioned<V>> ceilingEntry(String key); |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 49 | |
| 50 | /** |
| 51 | * Returns the entry associated with the greatest key less than or equal to key. |
| 52 | * |
| 53 | * @param key the key |
| 54 | * @return the entry or null |
| 55 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 56 | Map.Entry<String, Versioned<V>> floorEntry(String key); |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 57 | |
| 58 | /** |
| 59 | * Returns the entry associated with the lest key greater than key. |
| 60 | * |
| 61 | * @param key the key |
| 62 | * @return the entry or null |
| 63 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 64 | Map.Entry<String, Versioned<V>> higherEntry(String key); |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * Returns the entry associated with the largest key less than key. |
| 68 | * |
| 69 | * @param key the key |
| 70 | * @return the entry or null |
| 71 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 72 | Map.Entry<String, Versioned<V>> lowerEntry(String key); |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 73 | |
| 74 | /** |
| 75 | * Returns the entry associated with the lowest key in the map. |
| 76 | * |
| 77 | * @return the entry or null |
| 78 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 79 | Map.Entry<String, Versioned<V>> firstEntry(); |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 80 | |
| 81 | /** |
| 82 | * Returns the entry associated with the highest key in the map. |
| 83 | * |
| 84 | * @return the entry or null |
| 85 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 86 | Map.Entry<String, Versioned<V>> lastEntry(); |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 87 | |
| 88 | /** |
| 89 | * Returns and removes the entry associated with the lowest key. |
| 90 | * |
| 91 | * @return the entry or null |
| 92 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 93 | Map.Entry<String, Versioned<V>> pollFirstEntry(); |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 94 | |
| 95 | /** |
| 96 | * Returns and removes the entry associated with the highest key. |
| 97 | * |
| 98 | * @return the entry or null |
| 99 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 100 | Map.Entry<String, Versioned<V>> pollLastEntry(); |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 101 | |
| 102 | /** |
| 103 | * Returns the entry associated with the greatest key less than key. |
| 104 | * |
| 105 | * @param key the key |
| 106 | * @return the entry or null |
| 107 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 108 | String lowerKey(String key); |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 109 | |
| 110 | /** |
| 111 | * Returns the entry associated with the highest key less than or equal to key. |
| 112 | * |
| 113 | * @param key the key |
| 114 | * @return the entry or null |
| 115 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 116 | String floorKey(String key); |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 117 | |
| 118 | /** |
| 119 | * Returns the lowest key greater than or equal to key. |
| 120 | * |
| 121 | * @param key the key |
| 122 | * @return the key or null |
| 123 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 124 | String ceilingKey(String key); |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 125 | |
| 126 | /** |
| 127 | * Returns the lowest key greater than key. |
| 128 | * |
| 129 | * @param key the key |
| 130 | * @return the key or null |
| 131 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 132 | String higherKey(String key); |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 133 | |
| 134 | /** |
| 135 | * Returns a navigable set of the keys in this map. |
| 136 | * |
| 137 | * @return a navigable key set |
| 138 | */ |
Aaron Kruglikov | 6a16435 | 2016-07-25 11:46:17 -0700 | [diff] [blame] | 139 | NavigableSet<String> navigableKeySet(); |
| 140 | |
| 141 | /** |
| 142 | * Returns a navigable map containing the entries from the original map |
| 143 | * which are larger than (or if specified equal to) {@code lowerKey} AND |
| 144 | * less than (or if specified equal to) {@code upperKey}. |
| 145 | * |
| 146 | * @param upperKey the upper bound for the keys in this map |
| 147 | * @param lowerKey the lower bound for the keys in this map |
| 148 | * @param inclusiveUpper whether keys equal to the upperKey should be |
| 149 | * included |
| 150 | * @param inclusiveLower whether keys equal to the lowerKey should be |
| 151 | * included |
| 152 | * @return a navigable map containing entries in the specified range (this |
| 153 | * may be empty) |
| 154 | */ |
| 155 | NavigableMap<String, V> subMap(String upperKey, |
| 156 | String lowerKey, |
| 157 | boolean inclusiveUpper, |
| 158 | boolean inclusiveLower); |
Aaron Kruglikov | 47047b2 | 2016-03-31 16:52:48 -0700 | [diff] [blame] | 159 | |
| 160 | } |