public class LineRangeList extends AbstractList<LineRange> implements Serializable
List of LineRange that stores values more efficiently at runtime.
This class thinks of LineRange as two integers (start and end-start), hence a list of LineRange
becomes a list of integers. The class then stores those integers in byte[]. Each number is packed to UTF-8
like variable length format. To store a long value N, we first split into 7 bit chunk, and store each 7 bit chunk as
a byte, in the little endian order. The last byte gets its 8th bit set to indicate that that's the last byte. Thus in
this format, 0x0 gets stored as 0x80, 0x1234 gets stored as {0x34,0xA4(0x24|0x80)}.
This variable length mode stores data most efficiently, since most line numbers are small. Access characteristic gets
close to that of LinkedList, since we can only traverse this packed byte[] from the start or from the end.
modCount| Constructor and Description |
|---|
LineRangeList()
Creates an empty
LineRangeList. |
LineRangeList(Collection<LineRange> copy)
Creates a new
LineRangeList with the specified elements. |
LineRangeList(int capacity)
Creates an empty
LineRangeList with the specified capacity. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
LineRange element) |
boolean |
add(LineRange lr) |
boolean |
addAll(Collection<? extends LineRange> c) |
void |
clear() |
boolean |
contains(Object o) |
LineRange |
get(int index) |
Iterator<LineRange> |
iterator() |
ListIterator<LineRange> |
listIterator() |
ListIterator<LineRange> |
listIterator(int index) |
LineRange |
remove(int index) |
LineRange |
set(int index,
LineRange element) |
int |
size() |
void |
trim()
Minimizes the memory waste by throwing away excess capacity.
|
addAll, equals, hashCode, indexOf, lastIndexOf, removeRange, subListcontainsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitcontainsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArrayparallelStream, removeIf, streampublic LineRangeList()
LineRangeList. It uses a capacity of DEFAULT_CAPACITY.public LineRangeList(int capacity)
LineRangeList with the specified capacity.capacity - the initial capacity of the listpublic LineRangeList(Collection<LineRange> copy)
LineRangeList with the specified elements.copy - the initial elementspublic final boolean addAll(@Nonnull Collection<? extends LineRange> c)
addAll in interface Collection<LineRange>addAll in interface List<LineRange>addAll in class AbstractCollection<LineRange>public boolean contains(Object o)
contains in interface Collection<LineRange>contains in interface List<LineRange>contains in class AbstractCollection<LineRange>public LineRange get(int index)
public int size()
size in interface Collection<LineRange>size in interface List<LineRange>size in class AbstractCollection<LineRange>public void add(int index,
LineRange element)
public LineRange remove(int index)
public final boolean add(LineRange lr)
add in interface Collection<LineRange>add in interface List<LineRange>add in class AbstractList<LineRange>public void clear()
clear in interface Collection<LineRange>clear in interface List<LineRange>clear in class AbstractList<LineRange>@Nonnull public ListIterator<LineRange> listIterator()
listIterator in interface List<LineRange>listIterator in class AbstractList<LineRange>@Nonnull public ListIterator<LineRange> listIterator(int index)
listIterator in interface List<LineRange>listIterator in class AbstractList<LineRange>public void trim()
Copyright © 2018. All rights reserved.