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

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

public final class VMIndexLinkedList
extends Object
implements Cloneable, IndexLinkedList

A linked list used by IndexItems


Constructor Summary
VMIndexLinkedList(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 addBefore(IndexItem insert, IndexItem e)
           
 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.
 Object clone()
           
 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 entry)
          Retrieve the next entry after this entry
 IndexItem getPrevEntry(IndexItem entry)
          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 newRoot)
          Set the new Root
 int size()
          Returns the number of elements in this list.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VMIndexLinkedList

public VMIndexLinkedList(IndexItem header)
Constructs an empty list.

Parameters:
header -
Method Detail

setRoot

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

Specified by:
setRoot in interface IndexLinkedList

getRoot

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

getFirst

public IndexItem getFirst()
Description copied from interface: IndexLinkedList
Returns the first element in this list.

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

getLast

public IndexItem getLast()
Description copied from interface: IndexLinkedList
Returns the last element in this list.

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

removeFirst

public StoreEntry removeFirst()
Description copied from interface: IndexLinkedList
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()
Description copied from interface: IndexLinkedList
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)
Description copied from interface: IndexLinkedList
Inserts the given element at the beginning of this list.

Specified by:
addFirst in interface IndexLinkedList

addLast

public void addLast(IndexItem item)
Description copied from interface: IndexLinkedList
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

size

public int size()
Description copied from interface: IndexLinkedList
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()
Description copied from interface: IndexLinkedList
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)
Description copied from interface: IndexLinkedList
Appends the specified element to the end of this list.

Specified by:
add in interface IndexLinkedList
Returns:
true (as per the general contract of Collection.add).

clear

public void clear()
Description copied from interface: IndexLinkedList
Removes all of the elements from this list.

Specified by:
clear in interface IndexLinkedList

get

public IndexItem get(int index)
Description copied from interface: IndexLinkedList
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.

add

public void add(int index,
                IndexItem element)
Description copied from interface: IndexLinkedList
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.

remove

public Object remove(int index)
Description copied from interface: IndexLinkedList
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.

indexOf

public int indexOf(StoreEntry o)
Description copied from interface: IndexLinkedList
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 entry)
Description copied from interface: IndexLinkedList
Retrieve the next entry after this entry

Specified by:
getNextEntry in interface IndexLinkedList
Returns:
next entry

getPrevEntry

public IndexItem getPrevEntry(IndexItem entry)
Description copied from interface: IndexLinkedList
Retrive the prev entry after this entry

Specified by:
getPrevEntry in interface IndexLinkedList
Returns:
prev entry

addBefore

public void addBefore(IndexItem insert,
                      IndexItem e)

remove

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

Specified by:
remove in interface IndexLinkedList

clone

public Object clone()
Overrides:
clone in class Object
Returns:
clone

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


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