File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ function LList() {
99 this . find = find ;
1010 this . insert = insert ;
1111 this . display = display ;
12+ this . dispReverse = dispReverse ;
13+ this . findLast = findLast ;
14+ this . remove = remove ;
1215}
1316
1417function find ( item ) {
@@ -41,3 +44,29 @@ function display() {
4144 }
4245}
4346
47+ function dispReverse ( ) {
48+ var currNode = this . head ;
49+ currNode = this . findLast ( ) ;
50+ while ( currNode . previous != null ) {
51+ console . log ( "Current:" , currNode . element ) ;
52+ currNode = currNode . previous ;
53+ }
54+ }
55+
56+ function remove ( item ) {
57+ var currNode = this . find ( item ) ;
58+ currNode . previous . next = currNode . next ;
59+ if ( currNode . next != null ) {
60+ currNode . next . previous = currNode . previous ;
61+ }
62+ currNode . previous = null ;
63+ currNode . next = null ;
64+ }
65+
66+ function findLast ( ) {
67+ var currNode = this . head ;
68+ while ( currNode . next != null ) {
69+ currNode = currNode . next ;
70+ }
71+ return currNode ;
72+ }
You can’t perform that action at this time.
0 commit comments