org.apache.activemq.kaha.impl.index
Class DiskIndexLinkedList

java.lang.Object
  extended by org.apache.activemq.kaha.impl.index.DiskIndexLinkedList
All Implemented Interfaces:
IndexLinkedList

public class DiskIndexLinkedList
extends Object
implements IndexLinkedList

A linked list used by IndexItems


Field Summary
protected  IndexManager indexManager
           
protected  IndexItem last
           
protected  IndexItem root
           
protected  int size
           
 
Constructor Summary
DiskIndexLinkedList(IndexManager im, IndexItem header)
          Constructs an empty list.
 
Method Summary
 boolean add(IndexItem item)
          Appends the specified element to the end of this list.
 void add(int index, IndexItem element)
          Inserts the specified element at the specified position in this list.
 void addFirst(IndexItem item)
          Inserts the given element at the beginning of this list.
 void addLast(IndexItem item)
          Appends the given element to the end of this list.
 void clear()
          Removes all of the elements from this list.
 IndexItem get(int index)
          Returns the element at the specified position in this list.
 StoreEntry getEntry(StoreEntry current)
          Ensure we have the up to date entry
 IndexItem getFirst()
          Returns the first element in this list.
 IndexItem getLast()
          Returns the last element in this list.
 IndexItem getNextEntry(IndexItem current)
          Retrieve the next entry after this entry
 IndexItem getPrevEntry(IndexItem current)
          Retrive the prev entry after this entry
 IndexItem getRoot()
           
 int indexOf(StoreEntry o)
          Returns the index in this list of the first occurrence of the specified element, or -1 if the List does not contain this element.
 boolean isEmpty()
          is the list empty?
 StoreEntry refreshEntry(StoreEntry current)
          Update the indexes of a StoreEntry
 void remove(IndexItem e)
          remove an entry
 Object remove(int index)
          Removes the element at the specified position in this list.
 StoreEntry removeFirst()
          Removes and returns the first element from this list.
 Object removeLast()
          Removes and returns the last element from this list.
 void setRoot(IndexItem e)
          Set the new Root
 int size()
          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
 

Field Detail

indexManager

protected IndexManager indexManager

root

protected transient IndexItem root

last

protected transient IndexItem last

size

protected transient int size
Constructor Detail

DiskIndexLinkedList

public DiskIndexLinkedList(IndexManager im,
                           IndexItem header)
Constructs an empty list.

Method Detail

getRoot

public IndexItem getRoot()
Specified by:
getRoot in interface IndexLinkedList
Returns:
the root used by the List

setRoot

public void setRoot(IndexItem e)
Description copied from interface: IndexLinkedList
Set the new Root

Specified by:
setRoot in interface IndexLinkedList

getFirst

public IndexItem getFirst()
Returns the first element in this list.

Specified by:
getFirst in interface IndexLinkedList
Returns:
the first element in this list.

getLast

public IndexItem getLast()
Returns the last element in this list.

Specified by:
getLast in interface IndexLinkedList
Returns:
the last element in this list.

removeFirst

public StoreEntry removeFirst()
Removes and returns the first element from this list.

Specified by:
removeFirst in interface IndexLinkedList
Returns:
the first element from this list.

removeLast

public Object removeLast()
Removes and returns the last element from this list.

Specified by:
removeLast in interface IndexLinkedList
Returns:
the last element from this list.

addFirst

public void addFirst(IndexItem item)
Inserts the given element at the beginning of this list.

Specified by:
addFirst in interface IndexLinkedList
Parameters:
o - the element to be inserted at the beginning of this list.

addLast

public void addLast(IndexItem item)
Appends the given element to the end of this list. (Identical in function to the add method; included only for consistency.)

Specified by:
addLast in interface IndexLinkedList
Parameters:
o - the element to be inserted at the end of this list.

size

public int size()
Returns the number of elements in this list.

Specified by:
size in interface IndexLinkedList
Returns:
the number of elements in this list.

isEmpty

public boolean isEmpty()
is the list empty?

Specified by:
isEmpty in interface IndexLinkedList
Returns:
true if there are no elements in the list

add

public boolean add(IndexItem item)
Appends the specified element to the end of this list.

Specified by:
add in interface IndexLinkedList
Parameters:
o - element to be appended to this list.
Returns:
true (as per the general contract of Collection.add).

clear

public void clear()
Removes all of the elements from this list.

Specified by:
clear in interface IndexLinkedList

get

public IndexItem get(int index)
Returns the element at the specified position in this list.

Specified by:
get in interface IndexLinkedList
Parameters:
index - index of element to return.
Returns:
the element at the specified position in this list.
Throws:
IndexOutOfBoundsException - if the specified index is is out of range (index < 0 || index >= size()).

add

public void add(int index,
                IndexItem element)
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Specified by:
add in interface IndexLinkedList
Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

remove

public Object remove(int index)
Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

Specified by:
remove in interface IndexLinkedList
Parameters:
index - the index of the element to removed.
Returns:
the element previously at the specified position.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()).

indexOf

public int indexOf(StoreEntry o)
Returns the index in this list of the first occurrence of the specified element, or -1 if the List does not contain this element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.

Specified by:
indexOf in interface IndexLinkedList
Parameters:
o - element to search for.
Returns:
the index in this list of the first occurrence of the specified element, or -1 if the list does not contain this element.

getNextEntry

public IndexItem getNextEntry(IndexItem current)
Retrieve the next entry after this entry

Specified by:
getNextEntry in interface IndexLinkedList
Parameters:
entry -
Returns:
next entry

getPrevEntry

public IndexItem getPrevEntry(IndexItem current)
Retrive the prev entry after this entry

Specified by:
getPrevEntry in interface IndexLinkedList
Parameters:
entry -
Returns:
prev entry

getEntry

public StoreEntry getEntry(StoreEntry current)
Description copied from interface: IndexLinkedList
Ensure we have the up to date entry

Specified by:
getEntry in interface IndexLinkedList
Returns:
the entry

refreshEntry

public StoreEntry refreshEntry(StoreEntry current)
Update the indexes of a StoreEntry

Specified by:
refreshEntry in interface IndexLinkedList
Parameters:
current -
Returns:
update StoreEntry

remove

public void remove(IndexItem e)
Description copied from interface: IndexLinkedList
remove an entry

Specified by:
remove in interface IndexLinkedList


Copyright © 2005-2013 The Apache Software Foundation. All Rights Reserved.