hudson.plugins.analysis.util.model
Class LineRangeList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<LineRange>
          extended by hudson.plugins.analysis.util.model.LineRangeList
All Implemented Interfaces:
Serializable, Iterable<LineRange>, Collection<LineRange>, List<LineRange>

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.

Author:
Kohsuke Kawaguchi
See Also:
Serialized Form

Nested Class Summary
static class LineRangeList.ConverterImpl
          Converter implementation for XStream.
 
Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
LineRangeList()
           
LineRangeList(Collection<LineRange> copy)
           
LineRangeList(int capacity)
           
 
Method Summary
 void add(int index, LineRange element)
           
 boolean add(LineRange lr)
           
 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.
 
Methods inherited from class java.util.AbstractList
addAll, equals, hashCode, indexOf, lastIndexOf, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

LineRangeList

public LineRangeList()

LineRangeList

public LineRangeList(int capacity)

LineRangeList

public LineRangeList(Collection<LineRange> copy)
Method Detail

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<LineRange>
Specified by:
contains in interface List<LineRange>
Overrides:
contains in class AbstractCollection<LineRange>

get

public LineRange get(int index)
Specified by:
get in interface List<LineRange>
Specified by:
get in class AbstractList<LineRange>

size

public int size()
Specified by:
size in interface Collection<LineRange>
Specified by:
size in interface List<LineRange>
Specified by:
size in class AbstractCollection<LineRange>

set

public LineRange set(int index,
                     LineRange element)
Specified by:
set in interface List<LineRange>
Overrides:
set in class AbstractList<LineRange>

add

public void add(int index,
                LineRange element)
Specified by:
add in interface List<LineRange>
Overrides:
add in class AbstractList<LineRange>

remove

public LineRange remove(int index)
Specified by:
remove in interface List<LineRange>
Overrides:
remove in class AbstractList<LineRange>

add

public boolean add(LineRange lr)
Specified by:
add in interface Collection<LineRange>
Specified by:
add in interface List<LineRange>
Overrides:
add in class AbstractList<LineRange>

clear

public void clear()
Specified by:
clear in interface Collection<LineRange>
Specified by:
clear in interface List<LineRange>
Overrides:
clear in class AbstractList<LineRange>

iterator

public Iterator<LineRange> iterator()
Specified by:
iterator in interface Iterable<LineRange>
Specified by:
iterator in interface Collection<LineRange>
Specified by:
iterator in interface List<LineRange>
Overrides:
iterator in class AbstractList<LineRange>

listIterator

public ListIterator<LineRange> listIterator()
Specified by:
listIterator in interface List<LineRange>
Overrides:
listIterator in class AbstractList<LineRange>

listIterator

public ListIterator<LineRange> listIterator(int index)
Specified by:
listIterator in interface List<LineRange>
Overrides:
listIterator in class AbstractList<LineRange>

trim

public void trim()
Minimizes the memory waste by throwing away excess capacity.



Copyright © 2004-2012 Hudson. All Rights Reserved.