com.google.protobuf
Class LazyStringArrayList
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<String>
com.google.protobuf.LazyStringArrayList
- All Implemented Interfaces:
- LazyStringList, Iterable<String>, Collection<String>, List<String>, RandomAccess
public class LazyStringArrayList
- extends AbstractList<String>
- implements LazyStringList, RandomAccess
An implementation of LazyStringList
that wraps an ArrayList. Each
element is either a ByteString or a String. It caches the last one requested
which is most likely the one needed next. This minimizes memory usage while
satisfying the most common use cases.
Note that this implementation is not synchronized.
If multiple threads access an ArrayList instance concurrently,
and at least one of the threads modifies the list structurally, it
must be synchronized externally. (A structural modification is
any operation that adds or deletes one or more elements, or explicitly
resizes the backing array; merely setting the value of an element is not
a structural modification.) This is typically accomplished by
synchronizing on some object that naturally encapsulates the list.
If the implementation is accessed via concurrent reads, this is thread safe.
Conversions are done in a thread safe manner. It's possible that the
conversion may happen more than once if two threads attempt to access the
same element and the modifications were not visible to each other, but this
will not result in any corruption of the list or change in behavior other
than performance.
- Author:
- jonp@google.com (Jon Perlow)
Methods inherited from interface java.util.List |
add, addAll, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, retainAll, subList, toArray, toArray |
EMPTY
public static final LazyStringList EMPTY
LazyStringArrayList
public LazyStringArrayList()
LazyStringArrayList
public LazyStringArrayList(List<String> from)
get
public String get(int index)
- Specified by:
get
in interface List<String>
- Specified by:
get
in class AbstractList<String>
size
public int size()
- Specified by:
size
in interface Collection<String>
- Specified by:
size
in interface List<String>
- Specified by:
size
in class AbstractCollection<String>
set
public String set(int index,
String s)
- Specified by:
set
in interface List<String>
- Overrides:
set
in class AbstractList<String>
add
public void add(int index,
String element)
- Specified by:
add
in interface List<String>
- Overrides:
add
in class AbstractList<String>
addAll
public boolean addAll(int index,
Collection<? extends String> c)
- Specified by:
addAll
in interface List<String>
- Overrides:
addAll
in class AbstractList<String>
remove
public String remove(int index)
- Specified by:
remove
in interface List<String>
- Overrides:
remove
in class AbstractList<String>
clear
public void clear()
- Specified by:
clear
in interface Collection<String>
- Specified by:
clear
in interface List<String>
- Overrides:
clear
in class AbstractList<String>
add
public void add(ByteString element)
- Description copied from interface:
LazyStringList
- Appends the specified element to the end of this list (optional
operation).
- Specified by:
add
in interface LazyStringList
- Parameters:
element
- element to be appended to this list
getByteString
public ByteString getByteString(int index)
- Description copied from interface:
LazyStringList
- Returns the element at the specified position in this list as a ByteString.
- Specified by:
getByteString
in interface LazyStringList
- Parameters:
index
- index of the element to return
- Returns:
- the element at the specified position in this list
Copyright © 2008-2011. All Rights Reserved.