blob: eb62cace7df0fc8e679df7c920b6e8f6b399861e [file] [log] [blame]
Aaron Kruglikov47047b22016-03-31 16:52:48 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Aaron Kruglikov47047b22016-03-31 16:52:48 -07003 *
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
17package org.onosproject.store.service;
18
19import java.util.Map;
Aaron Kruglikov6a164352016-07-25 11:46:17 -070020import java.util.NavigableMap;
Aaron Kruglikov47047b22016-03-31 16:52:48 -070021import java.util.NavigableSet;
22
23/**
24 * Tree map interface counterpart to {@link AsyncConsistentTreeMap}.
25 */
Aaron Kruglikov6a164352016-07-25 11:46:17 -070026 public interface ConsistentTreeMap<V> extends ConsistentMap<String, V> {
Aaron Kruglikov47047b22016-03-31 16:52:48 -070027
28 /**
29 * Returns the lowest key in the map.
30 *
31 * @return the key or null if none exist
32 */
Aaron Kruglikov6a164352016-07-25 11:46:17 -070033 String firstKey();
Aaron Kruglikov47047b22016-03-31 16:52:48 -070034
35 /**
36 * Returns the highest key in the map.
37 *
38 * @return the key or null if none exist
39 */
Aaron Kruglikov6a164352016-07-25 11:46:17 -070040 String lastKey();
Aaron Kruglikov47047b22016-03-31 16:52:48 -070041
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 Kruglikov6a164352016-07-25 11:46:17 -070048 Map.Entry<String, Versioned<V>> ceilingEntry(String key);
Aaron Kruglikov47047b22016-03-31 16:52:48 -070049
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 Kruglikov6a164352016-07-25 11:46:17 -070056 Map.Entry<String, Versioned<V>> floorEntry(String key);
Aaron Kruglikov47047b22016-03-31 16:52:48 -070057
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 Kruglikov6a164352016-07-25 11:46:17 -070064 Map.Entry<String, Versioned<V>> higherEntry(String key);
Aaron Kruglikov47047b22016-03-31 16:52:48 -070065
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 Kruglikov6a164352016-07-25 11:46:17 -070072 Map.Entry<String, Versioned<V>> lowerEntry(String key);
Aaron Kruglikov47047b22016-03-31 16:52:48 -070073
74 /**
75 * Returns the entry associated with the lowest key in the map.
76 *
77 * @return the entry or null
78 */
Aaron Kruglikov6a164352016-07-25 11:46:17 -070079 Map.Entry<String, Versioned<V>> firstEntry();
Aaron Kruglikov47047b22016-03-31 16:52:48 -070080
81 /**
82 * Returns the entry associated with the highest key in the map.
83 *
84 * @return the entry or null
85 */
Aaron Kruglikov6a164352016-07-25 11:46:17 -070086 Map.Entry<String, Versioned<V>> lastEntry();
Aaron Kruglikov47047b22016-03-31 16:52:48 -070087
88 /**
89 * Returns and removes the entry associated with the lowest key.
90 *
91 * @return the entry or null
92 */
Aaron Kruglikov6a164352016-07-25 11:46:17 -070093 Map.Entry<String, Versioned<V>> pollFirstEntry();
Aaron Kruglikov47047b22016-03-31 16:52:48 -070094
95 /**
96 * Returns and removes the entry associated with the highest key.
97 *
98 * @return the entry or null
99 */
Aaron Kruglikov6a164352016-07-25 11:46:17 -0700100 Map.Entry<String, Versioned<V>> pollLastEntry();
Aaron Kruglikov47047b22016-03-31 16:52:48 -0700101
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 Kruglikov6a164352016-07-25 11:46:17 -0700108 String lowerKey(String key);
Aaron Kruglikov47047b22016-03-31 16:52:48 -0700109
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 Kruglikov6a164352016-07-25 11:46:17 -0700116 String floorKey(String key);
Aaron Kruglikov47047b22016-03-31 16:52:48 -0700117
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 Kruglikov6a164352016-07-25 11:46:17 -0700124 String ceilingKey(String key);
Aaron Kruglikov47047b22016-03-31 16:52:48 -0700125
126 /**
127 * Returns the lowest key greater than key.
128 *
129 * @param key the key
130 * @return the key or null
131 */
Aaron Kruglikov6a164352016-07-25 11:46:17 -0700132 String higherKey(String key);
Aaron Kruglikov47047b22016-03-31 16:52:48 -0700133
134 /**
135 * Returns a navigable set of the keys in this map.
136 *
137 * @return a navigable key set
138 */
Aaron Kruglikov6a164352016-07-25 11:46:17 -0700139 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 Kruglikov47047b22016-03-31 16:52:48 -0700159
160}