The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 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 android.util; |
| 18 | |
| 19 | import com.android.internal.util.ArrayUtils; |
Adam Lesinski | 776abc2 | 2014-03-07 11:30:59 -0500 | [diff] [blame] | 20 | import com.android.internal.util.GrowingArrayUtils; |
| 21 | |
| 22 | import libcore.util.EmptyArray; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * SparseArrays map integers to Objects. Unlike a normal array of Objects, |
Dianne Hackborn | b993f41 | 2013-07-12 17:46:45 -0700 | [diff] [blame] | 26 | * there can be gaps in the indices. It is intended to be more memory efficient |
| 27 | * than using a HashMap to map Integers to Objects, both because it avoids |
| 28 | * auto-boxing keys and its data structure doesn't rely on an extra entry object |
| 29 | * for each mapping. |
| 30 | * |
| 31 | * <p>Note that this container keeps its mappings in an array data structure, |
| 32 | * using a binary search to find keys. The implementation is not intended to be appropriate for |
| 33 | * data structures |
| 34 | * that may contain large numbers of items. It is generally slower than a traditional |
| 35 | * HashMap, since lookups require a binary search and adds and removes require inserting |
| 36 | * and deleting entries in the array. For containers holding up to hundreds of items, |
| 37 | * the performance difference is not significant, less than 50%.</p> |
| 38 | * |
| 39 | * <p>To help with performance, the container includes an optimization when removing |
| 40 | * keys: instead of compacting its array immediately, it leaves the removed entry marked |
| 41 | * as deleted. The entry can then be re-used for the same key, or compacted later in |
| 42 | * a single garbage collection step of all removed entries. This garbage collection will |
| 43 | * need to be performed at any time the array needs to be grown or the the map size or |
| 44 | * entry values are retrieved.</p> |
Flavio Lerda | 5771302 | 2013-09-08 18:04:58 +0100 | [diff] [blame] | 45 | * |
| 46 | * <p>It is possible to iterate over the items in this container using |
| 47 | * {@link #keyAt(int)} and {@link #valueAt(int)}. Iterating over the keys using |
| 48 | * <code>keyAt(int)</code> with ascending values of the index will return the |
| 49 | * keys in ascending order, or the values corresponding to the keys in ascending |
Newton Allen | ebb4795 | 2013-11-21 13:27:10 -0800 | [diff] [blame] | 50 | * order in the case of <code>valueAt(int)</code>.</p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | */ |
Svetoslav Ganov | 35bfede | 2011-07-14 17:57:06 -0700 | [diff] [blame] | 52 | public class SparseArray<E> implements Cloneable { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | private static final Object DELETED = new Object(); |
| 54 | private boolean mGarbage = false; |
| 55 | |
Svetoslav Ganov | 35bfede | 2011-07-14 17:57:06 -0700 | [diff] [blame] | 56 | private int[] mKeys; |
| 57 | private Object[] mValues; |
| 58 | private int mSize; |
| 59 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | /** |
| 61 | * Creates a new SparseArray containing no mappings. |
| 62 | */ |
| 63 | public SparseArray() { |
| 64 | this(10); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Creates a new SparseArray containing no mappings that will not |
| 69 | * require any additional memory allocation to store the specified |
Dianne Hackborn | f4bf0ae | 2013-05-20 18:42:16 -0700 | [diff] [blame] | 70 | * number of mappings. If you supply an initial capacity of 0, the |
| 71 | * sparse array will be initialized with a light-weight representation |
| 72 | * not requiring any additional array allocations. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | */ |
| 74 | public SparseArray(int initialCapacity) { |
Dianne Hackborn | f4bf0ae | 2013-05-20 18:42:16 -0700 | [diff] [blame] | 75 | if (initialCapacity == 0) { |
Adam Lesinski | 776abc2 | 2014-03-07 11:30:59 -0500 | [diff] [blame] | 76 | mKeys = EmptyArray.INT; |
| 77 | mValues = EmptyArray.OBJECT; |
Dianne Hackborn | f4bf0ae | 2013-05-20 18:42:16 -0700 | [diff] [blame] | 78 | } else { |
Adam Lesinski | 776abc2 | 2014-03-07 11:30:59 -0500 | [diff] [blame] | 79 | mValues = ArrayUtils.newUnpaddedObjectArray(initialCapacity); |
| 80 | mKeys = new int[mValues.length]; |
Dianne Hackborn | f4bf0ae | 2013-05-20 18:42:16 -0700 | [diff] [blame] | 81 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | mSize = 0; |
| 83 | } |
| 84 | |
Svetoslav Ganov | 35bfede | 2011-07-14 17:57:06 -0700 | [diff] [blame] | 85 | @Override |
| 86 | @SuppressWarnings("unchecked") |
| 87 | public SparseArray<E> clone() { |
| 88 | SparseArray<E> clone = null; |
| 89 | try { |
| 90 | clone = (SparseArray<E>) super.clone(); |
| 91 | clone.mKeys = mKeys.clone(); |
| 92 | clone.mValues = mValues.clone(); |
| 93 | } catch (CloneNotSupportedException cnse) { |
| 94 | /* ignore */ |
| 95 | } |
| 96 | return clone; |
| 97 | } |
| 98 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 99 | /** |
| 100 | * Gets the Object mapped from the specified key, or <code>null</code> |
| 101 | * if no such mapping has been made. |
| 102 | */ |
| 103 | public E get(int key) { |
| 104 | return get(key, null); |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Gets the Object mapped from the specified key, or the specified Object |
| 109 | * if no such mapping has been made. |
| 110 | */ |
Svetoslav Ganov | 35bfede | 2011-07-14 17:57:06 -0700 | [diff] [blame] | 111 | @SuppressWarnings("unchecked") |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 112 | public E get(int key, E valueIfKeyNotFound) { |
Dianne Hackborn | 3e82ba1 | 2013-07-16 13:23:55 -0700 | [diff] [blame] | 113 | int i = ContainerHelpers.binarySearch(mKeys, mSize, key); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 114 | |
| 115 | if (i < 0 || mValues[i] == DELETED) { |
| 116 | return valueIfKeyNotFound; |
| 117 | } else { |
| 118 | return (E) mValues[i]; |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Removes the mapping from the specified key, if there was any. |
| 124 | */ |
| 125 | public void delete(int key) { |
Dianne Hackborn | 3e82ba1 | 2013-07-16 13:23:55 -0700 | [diff] [blame] | 126 | int i = ContainerHelpers.binarySearch(mKeys, mSize, key); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 127 | |
| 128 | if (i >= 0) { |
| 129 | if (mValues[i] != DELETED) { |
| 130 | mValues[i] = DELETED; |
| 131 | mGarbage = true; |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | /** |
Dianne Hackborn | d23e0d6 | 2015-05-15 16:36:12 -0700 | [diff] [blame] | 137 | * @hide |
| 138 | * Removes the mapping from the specified key, if there was any, returning the old value. |
| 139 | */ |
| 140 | public E removeReturnOld(int key) { |
| 141 | int i = ContainerHelpers.binarySearch(mKeys, mSize, key); |
| 142 | |
| 143 | if (i >= 0) { |
| 144 | if (mValues[i] != DELETED) { |
| 145 | final E old = (E) mValues[i]; |
| 146 | mValues[i] = DELETED; |
| 147 | mGarbage = true; |
| 148 | return old; |
| 149 | } |
| 150 | } |
| 151 | return null; |
| 152 | } |
| 153 | |
| 154 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 155 | * Alias for {@link #delete(int)}. |
| 156 | */ |
| 157 | public void remove(int key) { |
| 158 | delete(key); |
| 159 | } |
| 160 | |
Dianne Hackborn | c801768 | 2010-07-06 13:34:38 -0700 | [diff] [blame] | 161 | /** |
| 162 | * Removes the mapping at the specified index. |
Phil Weaver | adaafb2 | 2016-05-19 10:32:52 -0700 | [diff] [blame^] | 163 | * |
| 164 | * <p>For indices outside of the range <code>0...size()-1</code>, |
| 165 | * the behavior is undefined.</p> |
Dianne Hackborn | c801768 | 2010-07-06 13:34:38 -0700 | [diff] [blame] | 166 | */ |
| 167 | public void removeAt(int index) { |
| 168 | if (mValues[index] != DELETED) { |
| 169 | mValues[index] = DELETED; |
| 170 | mGarbage = true; |
| 171 | } |
| 172 | } |
Elliott Hughes | 58aff7d | 2013-03-26 16:34:30 -0700 | [diff] [blame] | 173 | |
Dianne Hackborn | 3e82ba1 | 2013-07-16 13:23:55 -0700 | [diff] [blame] | 174 | /** |
| 175 | * Remove a range of mappings as a batch. |
| 176 | * |
| 177 | * @param index Index to begin at |
| 178 | * @param size Number of mappings to remove |
Phil Weaver | adaafb2 | 2016-05-19 10:32:52 -0700 | [diff] [blame^] | 179 | * |
| 180 | * <p>For indices outside of the range <code>0...size()-1</code>, |
| 181 | * the behavior is undefined.</p> |
Dianne Hackborn | 3e82ba1 | 2013-07-16 13:23:55 -0700 | [diff] [blame] | 182 | */ |
| 183 | public void removeAtRange(int index, int size) { |
| 184 | final int end = Math.min(mSize, index + size); |
| 185 | for (int i = index; i < end; i++) { |
| 186 | removeAt(i); |
| 187 | } |
| 188 | } |
| 189 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 190 | private void gc() { |
| 191 | // Log.e("SparseArray", "gc start with " + mSize); |
| 192 | |
| 193 | int n = mSize; |
| 194 | int o = 0; |
| 195 | int[] keys = mKeys; |
| 196 | Object[] values = mValues; |
| 197 | |
| 198 | for (int i = 0; i < n; i++) { |
| 199 | Object val = values[i]; |
| 200 | |
| 201 | if (val != DELETED) { |
| 202 | if (i != o) { |
| 203 | keys[o] = keys[i]; |
| 204 | values[o] = val; |
Svetoslav Ganov | d116d7c | 2011-11-21 18:41:59 -0800 | [diff] [blame] | 205 | values[i] = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | o++; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | mGarbage = false; |
| 213 | mSize = o; |
| 214 | |
| 215 | // Log.e("SparseArray", "gc end with " + mSize); |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * Adds a mapping from the specified key to the specified value, |
| 220 | * replacing the previous mapping from the specified key if there |
| 221 | * was one. |
| 222 | */ |
| 223 | public void put(int key, E value) { |
Dianne Hackborn | 3e82ba1 | 2013-07-16 13:23:55 -0700 | [diff] [blame] | 224 | int i = ContainerHelpers.binarySearch(mKeys, mSize, key); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 225 | |
| 226 | if (i >= 0) { |
| 227 | mValues[i] = value; |
| 228 | } else { |
| 229 | i = ~i; |
| 230 | |
| 231 | if (i < mSize && mValues[i] == DELETED) { |
| 232 | mKeys[i] = key; |
| 233 | mValues[i] = value; |
| 234 | return; |
| 235 | } |
| 236 | |
| 237 | if (mGarbage && mSize >= mKeys.length) { |
| 238 | gc(); |
| 239 | |
| 240 | // Search again because indices may have changed. |
Dianne Hackborn | 3e82ba1 | 2013-07-16 13:23:55 -0700 | [diff] [blame] | 241 | i = ~ContainerHelpers.binarySearch(mKeys, mSize, key); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 242 | } |
| 243 | |
Adam Lesinski | 776abc2 | 2014-03-07 11:30:59 -0500 | [diff] [blame] | 244 | mKeys = GrowingArrayUtils.insert(mKeys, mSize, i, key); |
| 245 | mValues = GrowingArrayUtils.insert(mValues, mSize, i, value); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 246 | mSize++; |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * Returns the number of key-value mappings that this SparseArray |
| 252 | * currently stores. |
| 253 | */ |
| 254 | public int size() { |
| 255 | if (mGarbage) { |
| 256 | gc(); |
| 257 | } |
| 258 | |
| 259 | return mSize; |
| 260 | } |
| 261 | |
| 262 | /** |
| 263 | * Given an index in the range <code>0...size()-1</code>, returns |
| 264 | * the key from the <code>index</code>th key-value mapping that this |
Elliott Hughes | 58aff7d | 2013-03-26 16:34:30 -0700 | [diff] [blame] | 265 | * SparseArray stores. |
Flavio Lerda | 5771302 | 2013-09-08 18:04:58 +0100 | [diff] [blame] | 266 | * |
| 267 | * <p>The keys corresponding to indices in ascending order are guaranteed to |
| 268 | * be in ascending order, e.g., <code>keyAt(0)</code> will return the |
| 269 | * smallest key and <code>keyAt(size()-1)</code> will return the largest |
| 270 | * key.</p> |
Phil Weaver | adaafb2 | 2016-05-19 10:32:52 -0700 | [diff] [blame^] | 271 | * |
| 272 | * <p>For indices outside of the range <code>0...size()-1</code>, |
| 273 | * the behavior is undefined.</p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 274 | */ |
| 275 | public int keyAt(int index) { |
| 276 | if (mGarbage) { |
| 277 | gc(); |
| 278 | } |
| 279 | |
| 280 | return mKeys[index]; |
| 281 | } |
Elliott Hughes | 58aff7d | 2013-03-26 16:34:30 -0700 | [diff] [blame] | 282 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 283 | /** |
| 284 | * Given an index in the range <code>0...size()-1</code>, returns |
| 285 | * the value from the <code>index</code>th key-value mapping that this |
Elliott Hughes | 58aff7d | 2013-03-26 16:34:30 -0700 | [diff] [blame] | 286 | * SparseArray stores. |
Flavio Lerda | 5771302 | 2013-09-08 18:04:58 +0100 | [diff] [blame] | 287 | * |
| 288 | * <p>The values corresponding to indices in ascending order are guaranteed |
| 289 | * to be associated with keys in ascending order, e.g., |
| 290 | * <code>valueAt(0)</code> will return the value associated with the |
| 291 | * smallest key and <code>valueAt(size()-1)</code> will return the value |
| 292 | * associated with the largest key.</p> |
Phil Weaver | adaafb2 | 2016-05-19 10:32:52 -0700 | [diff] [blame^] | 293 | * |
| 294 | * <p>For indices outside of the range <code>0...size()-1</code>, |
| 295 | * the behavior is undefined.</p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 296 | */ |
Svetoslav Ganov | 35bfede | 2011-07-14 17:57:06 -0700 | [diff] [blame] | 297 | @SuppressWarnings("unchecked") |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 298 | public E valueAt(int index) { |
| 299 | if (mGarbage) { |
| 300 | gc(); |
| 301 | } |
| 302 | |
| 303 | return (E) mValues[index]; |
| 304 | } |
| 305 | |
| 306 | /** |
| 307 | * Given an index in the range <code>0...size()-1</code>, sets a new |
| 308 | * value for the <code>index</code>th key-value mapping that this |
Elliott Hughes | 58aff7d | 2013-03-26 16:34:30 -0700 | [diff] [blame] | 309 | * SparseArray stores. |
Phil Weaver | adaafb2 | 2016-05-19 10:32:52 -0700 | [diff] [blame^] | 310 | * |
| 311 | * <p>For indices outside of the range <code>0...size()-1</code>, the behavior is undefined.</p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 312 | */ |
| 313 | public void setValueAt(int index, E value) { |
| 314 | if (mGarbage) { |
| 315 | gc(); |
| 316 | } |
| 317 | |
| 318 | mValues[index] = value; |
| 319 | } |
Elliott Hughes | 58aff7d | 2013-03-26 16:34:30 -0700 | [diff] [blame] | 320 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 321 | /** |
| 322 | * Returns the index for which {@link #keyAt} would return the |
| 323 | * specified key, or a negative number if the specified |
| 324 | * key is not mapped. |
| 325 | */ |
| 326 | public int indexOfKey(int key) { |
| 327 | if (mGarbage) { |
| 328 | gc(); |
| 329 | } |
| 330 | |
Dianne Hackborn | 3e82ba1 | 2013-07-16 13:23:55 -0700 | [diff] [blame] | 331 | return ContainerHelpers.binarySearch(mKeys, mSize, key); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | /** |
| 335 | * Returns an index for which {@link #valueAt} would return the |
| 336 | * specified key, or a negative number if no keys map to the |
| 337 | * specified value. |
Elliott Hughes | 58aff7d | 2013-03-26 16:34:30 -0700 | [diff] [blame] | 338 | * <p>Beware that this is a linear search, unlike lookups by key, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 339 | * and that multiple keys can map to the same value and this will |
| 340 | * find only one of them. |
Elliott Hughes | 58aff7d | 2013-03-26 16:34:30 -0700 | [diff] [blame] | 341 | * <p>Note also that unlike most collections' {@code indexOf} methods, |
| 342 | * this method compares values using {@code ==} rather than {@code equals}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 343 | */ |
| 344 | public int indexOfValue(E value) { |
| 345 | if (mGarbage) { |
| 346 | gc(); |
| 347 | } |
| 348 | |
| 349 | for (int i = 0; i < mSize; i++) |
| 350 | if (mValues[i] == value) |
| 351 | return i; |
| 352 | |
| 353 | return -1; |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * Removes all key-value mappings from this SparseArray. |
| 358 | */ |
| 359 | public void clear() { |
| 360 | int n = mSize; |
| 361 | Object[] values = mValues; |
| 362 | |
| 363 | for (int i = 0; i < n; i++) { |
| 364 | values[i] = null; |
| 365 | } |
| 366 | |
| 367 | mSize = 0; |
| 368 | mGarbage = false; |
| 369 | } |
| 370 | |
| 371 | /** |
| 372 | * Puts a key/value pair into the array, optimizing for the case where |
| 373 | * the key is greater than all existing keys in the array. |
| 374 | */ |
| 375 | public void append(int key, E value) { |
| 376 | if (mSize != 0 && key <= mKeys[mSize - 1]) { |
| 377 | put(key, value); |
| 378 | return; |
| 379 | } |
| 380 | |
| 381 | if (mGarbage && mSize >= mKeys.length) { |
| 382 | gc(); |
| 383 | } |
| 384 | |
Adam Lesinski | 776abc2 | 2014-03-07 11:30:59 -0500 | [diff] [blame] | 385 | mKeys = GrowingArrayUtils.append(mKeys, mSize, key); |
| 386 | mValues = GrowingArrayUtils.append(mValues, mSize, value); |
| 387 | mSize++; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 388 | } |
Elliott Hughes | 58aff7d | 2013-03-26 16:34:30 -0700 | [diff] [blame] | 389 | |
Dianne Hackborn | 3e82ba1 | 2013-07-16 13:23:55 -0700 | [diff] [blame] | 390 | /** |
| 391 | * {@inheritDoc} |
| 392 | * |
| 393 | * <p>This implementation composes a string by iterating over its mappings. If |
| 394 | * this map contains itself as a value, the string "(this Map)" |
| 395 | * will appear in its place. |
| 396 | */ |
| 397 | @Override |
| 398 | public String toString() { |
| 399 | if (size() <= 0) { |
| 400 | return "{}"; |
| 401 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 402 | |
Dianne Hackborn | 3e82ba1 | 2013-07-16 13:23:55 -0700 | [diff] [blame] | 403 | StringBuilder buffer = new StringBuilder(mSize * 28); |
| 404 | buffer.append('{'); |
| 405 | for (int i=0; i<mSize; i++) { |
| 406 | if (i > 0) { |
| 407 | buffer.append(", "); |
| 408 | } |
| 409 | int key = keyAt(i); |
| 410 | buffer.append(key); |
| 411 | buffer.append('='); |
| 412 | Object value = valueAt(i); |
| 413 | if (value != this) { |
| 414 | buffer.append(value); |
Dianne Hackborn | f4bf0ae | 2013-05-20 18:42:16 -0700 | [diff] [blame] | 415 | } else { |
Dianne Hackborn | 3e82ba1 | 2013-07-16 13:23:55 -0700 | [diff] [blame] | 416 | buffer.append("(this Map)"); |
Dianne Hackborn | f4bf0ae | 2013-05-20 18:42:16 -0700 | [diff] [blame] | 417 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 418 | } |
Dianne Hackborn | 3e82ba1 | 2013-07-16 13:23:55 -0700 | [diff] [blame] | 419 | buffer.append('}'); |
| 420 | return buffer.toString(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 421 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 422 | } |