KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > kaha > impl > index > IndexLinkedList


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.kaha.impl.index;
19
20 import org.apache.activemq.kaha.StoreEntry;
21
22 /**
23 * Inteface to LinkedList of Indexes
24 *
25 * @version $Revision: 475999 $
26 */

27 public interface IndexLinkedList{
28     
29     /**
30      * @return the root used by the List
31      */

32     public IndexItem getRoot();
33     
34     /**
35      * Returns the first element in this list.
36      *
37      * @return the first element in this list.
38      */

39     public IndexItem getFirst();
40
41     /**
42      * Returns the last element in this list.
43      *
44      * @return the last element in this list.
45      */

46     public IndexItem getLast();
47
48     /**
49      * Removes and returns the first element from this list.
50      *
51      * @return the first element from this list.
52      */

53     public StoreEntry removeFirst();
54
55     /**
56      * Removes and returns the last element from this list.
57      *
58      * @return the last element from this list.
59      */

60     public Object JavaDoc removeLast();
61
62     /**
63      * Inserts the given element at the beginning of this list.
64      * @param item
65      */

66     public void addFirst(IndexItem item);
67
68     /**
69      * Appends the given element to the end of this list. (Identical in function to the <tt>add</tt> method; included
70      * only for consistency.)
71      * @param item
72      */

73     public void addLast(IndexItem item);
74
75     /**
76      * Returns the number of elements in this list.
77      *
78      * @return the number of elements in this list.
79      */

80     public int size();
81
82     /**
83      * is the list empty?
84      *
85      * @return true if there are no elements in the list
86      */

87     public boolean isEmpty();
88
89     /**
90      * Appends the specified element to the end of this list.
91      * @param item
92      *
93      * @return <tt>true</tt> (as per the general contract of <tt>Collection.add</tt>).
94      */

95     public boolean add(IndexItem item);
96
97     /**
98      * Removes all of the elements from this list.
99      */

100     public void clear();
101
102     // Positional Access Operations
103
/**
104      * Returns the element at the specified position in this list.
105      *
106      * @param index index of element to return.
107      * @return the element at the specified position in this list.
108      *
109      * @throws IndexOutOfBoundsException if the specified index is is out of range (<tt>index &lt; 0 || index &gt;= size()</tt>).
110      */

111     public IndexItem get(int index);
112
113     /**
114      * Inserts the specified element at the specified position in this list. Shifts the element currently at that
115      * position (if any) and any subsequent elements to the right (adds one to their indices).
116      *
117      * @param index index at which the specified element is to be inserted.
118      * @param element element to be inserted.
119      *
120      * @throws IndexOutOfBoundsException if the specified index is out of range (<tt>index &lt; 0 || index &gt; size()</tt>).
121      */

122     public void add(int index,IndexItem element);
123
124     /**
125      * Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts
126      * one from their indices). Returns the element that was removed from the list.
127      *
128      * @param index the index of the element to removed.
129      * @return the element previously at the specified position.
130      *
131      * @throws IndexOutOfBoundsException if the specified index is out of range (<tt>index &lt; 0 || index &gt;= size()</tt>).
132      */

133     public Object JavaDoc remove(int index);
134
135     // Search Operations
136
/**
137      * Returns the index in this list of the first occurrence of the specified element, or -1 if the List does not
138      * contain this element. More formally, returns the lowest index i such that
139      * <tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>, or -1 if there is no such index.
140      *
141      * @param o element to search for.
142      * @return the index in this list of the first occurrence of the specified element, or -1 if the list does not
143      * contain this element.
144      */

145     public int indexOf(StoreEntry o);
146
147     /**
148      * Retrieve the next entry after this entry
149      *
150      * @param entry
151      * @return next entry
152      */

153     public IndexItem getNextEntry(IndexItem entry);
154
155     /**
156      * Retrive the prev entry after this entry
157      *
158      * @param entry
159      * @return prev entry
160      */

161     public IndexItem getPrevEntry(IndexItem entry);
162
163     
164     /**
165      * remove an entry
166      * @param e
167      */

168     public void remove(IndexItem e);
169     
170     /**
171      * Ensure we have the up to date entry
172      * @param entry
173      * @return the entry
174      */

175     public StoreEntry getEntry(StoreEntry entry);
176     
177     /**
178      * Update the indexes of a StoreEntry
179      * @param current
180      * @return update StoreEntry
181      */

182     public StoreEntry refreshEntry(StoreEntry current);
183 }
184
Popular Tags