Class LazyStringArrayList

All Implemented Interfaces:
Internal.ProtobufList<String>, LazyStringList, ProtocolStringList, Iterable<String>, Collection<String>, List<String>, RandomAccess, SequencedCollection<String>

public class LazyStringArrayList extends AbstractList<String> implements LazyStringList, RandomAccess
An implementation of LazyStringList that wraps an ArrayList. Each element is one of String, ByteString, or byte[]. 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.

  • Field Details

  • Constructor Details

    • LazyStringArrayList

      public LazyStringArrayList()
    • LazyStringArrayList

      public LazyStringArrayList(int initialCapacity)
    • LazyStringArrayList

      public LazyStringArrayList(LazyStringList from)
    • LazyStringArrayList

      public LazyStringArrayList(List<String> from)
  • Method Details