File tree Expand file tree Collapse file tree 1 file changed +38
-1
lines changed Expand file tree Collapse file tree 1 file changed +38
-1
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
- * @author Rashik Ansar
2
+ * @author Rashik Ansar and Luiz Guerra
3
+ *
3
4
*
4
5
* Implemtaion of Stack data structure
5
6
* Stack follows LIFO (Last In First Out) priniciple
@@ -62,6 +63,42 @@ class Stack {
62
63
}
63
64
return this . first . data ;
64
65
}
66
+
67
+ /**
68
+ * @returns size of the Stack
69
+ */
70
+ size ( ) {
71
+ return this . size ;
72
+ }
73
+
74
+ /**
75
+ * @returns if Stack is empty
76
+ */
77
+ isEmpty ( ) {
78
+ return this . size == 0 ;
79
+ }
80
+
81
+ /**
82
+ * clears the Stack
83
+ */
84
+ clear ( ) {
85
+ this . first = null ;
86
+ this . last = null ;
87
+ this . size = 0 ;
88
+ }
89
+
90
+ /**
91
+ * @returns the Stack
92
+ */
93
+ toString ( ) {
94
+ let str = "" ;
95
+ let aux = this . first ;
96
+ for ( let i = 0 ; i < this . count ; i ++ )
97
+ str += aux . element + " " ;
98
+ aux = aux . next ;
99
+ return str ;
100
+ }
101
+
65
102
}
66
103
67
104
class Node {
You can’t perform that action at this time.
0 commit comments