14d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com/* 24d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * [The "BSD licence"] 300fc68adf2e39aeb9fed35293f2576bbe729ec4bJesusFreke@JesusFreke.com * Copyright (c) 2010 Ben Gruver (JesusFreke) 44d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * All rights reserved. 54d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * 64d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * Redistribution and use in source and binary forms, with or without 74d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * modification, are permitted provided that the following conditions 84d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * are met: 94d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * 1. Redistributions of source code must retain the above copyright 104d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * notice, this list of conditions and the following disclaimer. 114d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * 2. Redistributions in binary form must reproduce the above copyright 124d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * notice, this list of conditions and the following disclaimer in the 134d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * documentation and/or other materials provided with the distribution. 144d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * 3. The name of the author may not be used to endorse or promote products 154d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * derived from this software without specific prior written permission. 164d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * 174d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 184d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 194d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 204d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 214d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 224d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 234d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 244d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 254d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 264d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 274d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com */ 284d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com 294d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.compackage org.jf.dexlib.Util; 304d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com 314d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.comimport java.util.AbstractList; 324d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.comimport java.util.RandomAccess; 334d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com 344d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.compublic class ReadOnlyArrayList<T> extends AbstractList<T> implements RandomAccess { 354d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com private final T[] arr; 364d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com 374d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com public ReadOnlyArrayList(T[] arr) { 384d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com this.arr = arr; 394d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com } 404d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com 414d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com public int size() { 424d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com return arr.length; 434d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com } 444d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com 454d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com public T get(int i) { 464d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com return arr[i]; 474d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com } 48b71c12967b9c5c133c46c5edb6c128e78f1baf2cBen Gruver 49b71c12967b9c5c133c46c5edb6c128e78f1baf2cBen Gruver public static <T> ReadOnlyArrayList<T> of(T... items) { 50b71c12967b9c5c133c46c5edb6c128e78f1baf2cBen Gruver return new ReadOnlyArrayList<T>(items); 51b71c12967b9c5c133c46c5edb6c128e78f1baf2cBen Gruver } 524d68e05fb5e3262c58bc9896befe910698daa6a8JesusFreke@JesusFreke.com} 53