File tree Expand file tree Collapse file tree 2 files changed +12
-12
lines changed
contents/stacks_and_queues/code/java Expand file tree Collapse file tree 2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -48,24 +48,24 @@ public class Queue<T> implements IQueue<T> {
48
48
private List <T > list ;
49
49
50
50
public Queue () {
51
- this .list = new ArrayList ();
51
+ this .list = new ArrayList ();
52
52
}
53
53
54
54
public T dequeue () {
55
- return this .list .remove (0 );
55
+ return this .list .remove (0 );
56
56
}
57
57
58
58
public int enqueue (T element ) {
59
- this .list .add (element );
60
- return this .size ();
59
+ this .list .add (element );
60
+ return this .size ();
61
61
}
62
62
63
63
public int size () {
64
- return this .list .size ();
64
+ return this .list .size ();
65
65
}
66
66
67
67
public T peek () {
68
- return this .list .get (0 );
68
+ return this .list .get (0 );
69
69
}
70
70
71
71
}
Original file line number Diff line number Diff line change @@ -47,24 +47,24 @@ public class Stack<T> implements IStack<T> {
47
47
private List <T > list ;
48
48
49
49
public Stack () {
50
- this .list = new ArrayList <>();
50
+ this .list = new ArrayList <>();
51
51
}
52
52
53
53
public T pop () {
54
- return this .list .remove (this .size () - 1 );
54
+ return this .list .remove (this .size () - 1 );
55
55
}
56
56
57
57
public int push (T element ) {
58
- this .list .add (element );
59
- return this .size ();
58
+ this .list .add (element );
59
+ return this .size ();
60
60
}
61
61
62
62
public int size () {
63
- return this .list .size ();
63
+ return this .list .size ();
64
64
}
65
65
66
66
public T peek () {
67
- return this .list .get (this .size () - 1 );
67
+ return this .list .get (this .size () - 1 );
68
68
}
69
69
70
70
}
You can’t perform that action at this time.
0 commit comments