Class DiffListByArrayList<T extends Comparable<Integer>>

java.lang.Object
org.apache.hadoop.hdfs.server.namenode.snapshot.DiffListByArrayList<T>
Type Parameters:
T - Type of the object in the list
All Implemented Interfaces:
Iterable<T>, DiffList<T>

public class DiffListByArrayList<T extends Comparable<Integer>> extends Object implements DiffList<T>
Resizable-array implementation of the DiffList interface.
  • Field Summary

    Fields inherited from interface org.apache.hadoop.hdfs.server.namenode.snapshot.DiffList

    EMPTY_LIST
  • Constructor Summary

    Constructors
    Constructor
    Description
    DiffListByArrayList(int initialCapacity)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds an element at the beginning of the list.
    boolean
    Adds an element at the end of the list.
    int
    binarySearch(int i)
    Searches the list for the specified object using the binary search algorithm.
    get(int i)
    Returns the element at the specified position in this list.
    getMinListForRange(int startIndex, int endIndex, INodeDirectory dir)
    Returns the list of minimal list of elements need to combine to generate cumulative sum from startIndex to endIndex.
    boolean
    Returns true if this list contains no elements.
     
    remove(int i)
    Removes the element at the specified position in this list.
    int
    Returns the number of elements in this list.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • DiffListByArrayList

      public DiffListByArrayList(int initialCapacity)
  • Method Details

    • get

      public T get(int i)
      Description copied from interface: DiffList
      Returns the element at the specified position in this list.
      Specified by:
      get in interface DiffList<T extends Comparable<Integer>>
      Parameters:
      i - index of the element to return
      Returns:
      the element at the specified position in this list
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: DiffList
      Returns true if this list contains no elements.
      Specified by:
      isEmpty in interface DiffList<T extends Comparable<Integer>>
      Returns:
      true if this list contains no elements
    • size

      public int size()
      Description copied from interface: DiffList
      Returns the number of elements in this list.
      Specified by:
      size in interface DiffList<T extends Comparable<Integer>>
      Returns:
      the number of elements in this list.
    • remove

      public T remove(int i)
      Description copied from interface: DiffList
      Removes the element at the specified position in this list.
      Specified by:
      remove in interface DiffList<T extends Comparable<Integer>>
      Parameters:
      i - the index of the element to be removed
      Returns:
      the element previously at the specified position
    • addLast

      public boolean addLast(T t)
      Description copied from interface: DiffList
      Adds an element at the end of the list.
      Specified by:
      addLast in interface DiffList<T extends Comparable<Integer>>
      Parameters:
      t - element to be appended to this list
      Returns:
      true, if insertion is successful
    • addFirst

      public void addFirst(T t)
      Description copied from interface: DiffList
      Adds an element at the beginning of the list.
      Specified by:
      addFirst in interface DiffList<T extends Comparable<Integer>>
      Parameters:
      t - element to be added to this list
    • binarySearch

      public int binarySearch(int i)
      Description copied from interface: DiffList
      Searches the list for the specified object using the binary search algorithm.
      Specified by:
      binarySearch in interface DiffList<T extends Comparable<Integer>>
      Parameters:
      i - key to be searched for
      Returns:
      the index of the search key, if it is contained in the list otherwise, (-insertion point - 1).
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T extends Comparable<Integer>>
    • getMinListForRange

      public List<T> getMinListForRange(int startIndex, int endIndex, INodeDirectory dir)
      Description copied from interface: DiffList
      Returns the list of minimal list of elements need to combine to generate cumulative sum from startIndex to endIndex.
      Specified by:
      getMinListForRange in interface DiffList<T extends Comparable<Integer>>
      Returns:
      list of T