forked from IF-LK-2020/queue-stack
enqueue and dequeue implemented
This commit is contained in:
BIN
Queue.class
Normal file
BIN
Queue.class
Normal file
Binary file not shown.
15
Queue.ctxt
Normal file
15
Queue.ctxt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#BlueJ class context
|
||||||
|
comment0.target=Queue
|
||||||
|
comment1.params=
|
||||||
|
comment1.target=Queue()
|
||||||
|
comment2.params=pContentObject
|
||||||
|
comment2.target=void\ enqueue(java.lang.Object)
|
||||||
|
comment3.params=
|
||||||
|
comment3.target=void\ dequeue()
|
||||||
|
comment4.params=
|
||||||
|
comment4.target=java.lang.Object\ front()
|
||||||
|
comment4.text=\r\n\ Liefert\ das\ Inhaltsobjekt\ vom\ ersten\ Knotens\ der\ Schlange\r\n\ vom\ Typ\ ContentType,\ falls\ die\ Schlange\ nicht\ leer\ ist,\r\n\ ansonsten\ null.\r\n\r\n\ @return\ Das\ Inhaltsobjekt\ oder\ null.\r\n
|
||||||
|
comment5.params=
|
||||||
|
comment5.target=boolean\ isEmpty()
|
||||||
|
comment5.text=\r\n\ Pr\u00FCft,\ ob\ die\ Schlange\ leer\ ist.\r\n\r\n\ @return\ true,\ wenn\ die\ Schlange\ keine\ Knoten\ enthaelt\r\n
|
||||||
|
numComments=6
|
||||||
16
Queue.java
16
Queue.java
@@ -9,11 +9,23 @@ public class Queue<ContentType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void enqueue( ContentType pContentObject ) {
|
public void enqueue( ContentType pContentObject ) {
|
||||||
// TODO: Implementiere enqueue
|
if (head == null) {
|
||||||
|
head = new QueueNode<ContentType>(pContentObject);
|
||||||
|
tail = head;
|
||||||
|
} else {
|
||||||
|
QueueNode<ContentType> node = new QueueNode<ContentType>(pContentObject);
|
||||||
|
tail.setNext(node);
|
||||||
|
tail = node;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dequeue() {
|
public void dequeue() {
|
||||||
// TODO: Implementiere dequeue
|
if (head != tail) {
|
||||||
|
head = head.getNext();
|
||||||
|
} else if (head != null) {
|
||||||
|
head = null;
|
||||||
|
tail = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
BIN
QueueNode.class
Normal file
BIN
QueueNode.class
Normal file
Binary file not shown.
15
QueueNode.ctxt
Normal file
15
QueueNode.ctxt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#BlueJ class context
|
||||||
|
comment0.target=QueueNode
|
||||||
|
comment1.params=pContentObject
|
||||||
|
comment1.target=QueueNode(java.lang.Object)
|
||||||
|
comment1.text=\r\n\ Ein\ neues\ Objekt\ vom\ Typ\ Node<ContentType>\ wird\ erschaffen.\r\n\ Der\ Inhalt\ wird\ per\ Parameter\ gesetzt.\ Der\ Verweis\ ist\ leer.\r\n\r\n\ @param\ pContentObject\ das\ Inhaltselement\ des\ Knotens\ vom\ Typ\ ContentType\r\n
|
||||||
|
comment2.params=pNext
|
||||||
|
comment2.target=void\ setNext(QueueNode)
|
||||||
|
comment2.text=\r\n\ Der\ Verweis\ wird\ auf\ das\ Objekt,\ das\ als\ Parameter\ uebergeben\ wird,\r\n\ gesetzt.\r\n\r\n\ @param\ pNext\ der\ Nachfolger\ des\ Knotens\r\n
|
||||||
|
comment3.params=
|
||||||
|
comment3.target=QueueNode\ getNext()
|
||||||
|
comment3.text=\r\n\ Liefert\ das\ naechste\ Element\ des\ aktuellen\ Knotens.\r\n\r\n\ @return\ das\ Objekt\ vom\ Typ\ QueueNode,\ auf\ das\ der\ aktuelle\ Verweis\ zeigt\r\n
|
||||||
|
comment4.params=
|
||||||
|
comment4.target=java.lang.Object\ getContent()
|
||||||
|
comment4.text=\r\n\ Liefert\ das\ Inhaltsobjekt\ des\ Knotens\ vom\ Typ\ ContentType.\r\n\r\n\ @return\ das\ Inhaltsobjekt\ des\ Knotens\r\n
|
||||||
|
numComments=5
|
||||||
BIN
QueueTest.class
Normal file
BIN
QueueTest.class
Normal file
Binary file not shown.
11
QueueTest.ctxt
Normal file
11
QueueTest.ctxt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#BlueJ class context
|
||||||
|
comment0.target=QueueTest
|
||||||
|
comment1.params=
|
||||||
|
comment1.target=void\ testeEnqueue()
|
||||||
|
comment2.params=
|
||||||
|
comment2.target=void\ testeDequeue()
|
||||||
|
comment3.params=
|
||||||
|
comment3.target=void\ testeFront()
|
||||||
|
comment4.params=
|
||||||
|
comment4.target=void\ testeIsEmpty()
|
||||||
|
numComments=5
|
||||||
BIN
Stack.class
Normal file
BIN
Stack.class
Normal file
Binary file not shown.
15
Stack.ctxt
Normal file
15
Stack.ctxt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#BlueJ class context
|
||||||
|
comment0.target=Stack
|
||||||
|
comment1.params=
|
||||||
|
comment1.target=Stack()
|
||||||
|
comment2.params=pContentObject
|
||||||
|
comment2.target=void\ push(java.lang.Object)
|
||||||
|
comment3.params=
|
||||||
|
comment3.target=void\ pop()
|
||||||
|
comment4.params=
|
||||||
|
comment4.target=java.lang.Object\ top()
|
||||||
|
comment4.text=\r\n\ Liefert\ das\ Inhaltsobjekt\ vom\ obersten\ Knoten\ des\ Stapels\r\n\ vom\ Typ\ ContentType,\ falls\ die\ Schlange\ nicht\ leer\ ist,\r\n\ ansonsten\ null.\r\n\r\n\ @return\ Das\ Inhaltsobjekt\ oder\ null.\r\n
|
||||||
|
comment5.params=
|
||||||
|
comment5.target=boolean\ isEmpty()
|
||||||
|
comment5.text=\r\n\ Pr\u00FCft,\ ob\ der\ Stapel\ leer\ ist.\r\n\r\n\ @return\ true,\ wenn\ der\ Stapel\ keine\ Knoten\ enthaelt\r\n
|
||||||
|
numComments=6
|
||||||
BIN
StackNode.class
Normal file
BIN
StackNode.class
Normal file
Binary file not shown.
15
StackNode.ctxt
Normal file
15
StackNode.ctxt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#BlueJ class context
|
||||||
|
comment0.target=StackNode
|
||||||
|
comment1.params=pContentObject
|
||||||
|
comment1.target=StackNode(java.lang.Object)
|
||||||
|
comment1.text=\r\n\ Ein\ neues\ Objekt\ vom\ Typ\ Node<ContentType>\ wird\ erschaffen.\r\n\ Der\ Inhalt\ wird\ per\ Parameter\ gesetzt.\ Der\ Verweis\ ist\ leer.\r\n\r\n\ @param\ pContentObject\ das\ Inhaltselement\ des\ Knotens\ vom\ Typ\ ContentType\r\n
|
||||||
|
comment2.params=pNext
|
||||||
|
comment2.target=void\ setNext(StackNode)
|
||||||
|
comment2.text=\r\n\ Der\ Verweis\ wird\ auf\ das\ Objekt,\ das\ als\ Parameter\ uebergeben\ wird,\r\n\ gesetzt.\r\n\r\n\ @param\ pNext\ der\ Nachfolger\ des\ Knotens\r\n
|
||||||
|
comment3.params=
|
||||||
|
comment3.target=StackNode\ getNext()
|
||||||
|
comment3.text=\r\n\ Liefert\ das\ naechste\ Element\ des\ aktuellen\ Knotens.\r\n\r\n\ @return\ das\ Objekt\ vom\ Typ\ QueueNode,\ auf\ das\ der\ aktuelle\ Verweis\ zeigt\r\n
|
||||||
|
comment4.params=
|
||||||
|
comment4.target=java.lang.Object\ getContent()
|
||||||
|
comment4.text=\r\n\ Liefert\ das\ Inhaltsobjekt\ des\ Knotens\ vom\ Typ\ ContentType.\r\n\r\n\ @return\ das\ Inhaltsobjekt\ des\ Knotens\r\n
|
||||||
|
numComments=5
|
||||||
BIN
StackTest.class
Normal file
BIN
StackTest.class
Normal file
Binary file not shown.
11
StackTest.ctxt
Normal file
11
StackTest.ctxt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#BlueJ class context
|
||||||
|
comment0.target=StackTest
|
||||||
|
comment1.params=
|
||||||
|
comment1.target=void\ testePush()
|
||||||
|
comment2.params=
|
||||||
|
comment2.target=void\ testePop()
|
||||||
|
comment3.params=
|
||||||
|
comment3.target=void\ testeTop()
|
||||||
|
comment4.params=
|
||||||
|
comment4.target=void\ testeIsEmpty()
|
||||||
|
numComments=5
|
||||||
Reference in New Issue
Block a user