|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnachos.kernel.threads.List
public class List
The following class defines a "list" -- a singly linked list of list elements, each of which points to a single item on the list. Although the Java API provides classes with functionality that subsume this one, linked lists are such an important data structure in operating systems that it seemed like a good idea to include here an implementation "from scratch". By using the sortedInsert() method, the list can be kept in sorted in increasing order with respect to a "sortKey". NOTE: Mutual exclusion must be provided by the caller. If you want a synchronized list, you must use the routines in synchlist.cc.
Nested Class Summary | |
---|---|
protected static class |
List.ListElement
The following class defines a "list element" -- which is used to keep track of one item on a list. |
Field Summary | |
---|---|
private List.ListElement |
first
Head of the list, null if list is empty |
private List.ListElement |
last
Last element of the list. |
Constructor Summary | |
---|---|
List()
|
Method Summary | |
---|---|
void |
append(java.lang.Object item)
Append an "item" to the end of the list. |
boolean |
isEmpty()
Determine if the list is empty (has no items). |
void |
List()
Initialize a list, empty to start with. |
void |
prepend(java.lang.Object item)
Put an "item" on the front of the list. |
java.lang.Object |
remove()
Remove the first "item" from the front of the list. |
void |
sortedInsert(java.lang.Object item,
long sortKey)
Insert an "item" into a list, so that the list elements are sorted in increasing order by "sortKey". |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private List.ListElement first
private List.ListElement last
Constructor Detail |
---|
public List()
Method Detail |
---|
public void List()
public void append(java.lang.Object item)
item
- The thing to put on the list, it can be any object.public void prepend(java.lang.Object item)
item
- The thing to put on the list, it can be any object.public java.lang.Object remove()
public boolean isEmpty()
public void sortedInsert(java.lang.Object item, long sortKey)
item
- The thing to put on the list, it can be any object.sortKey
- The priority of the item.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |