中级农民
- 积分
- 196
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2016-6-14
- 最后登录
- 1970-1-1
|
终于写好了 碰到了两个问题
一是 head construct 之后没有指向自己QAQ
二是 一开始没有理解LockDList的模式
override时parameter时LockDListNode(wrong)应该是DListNode(right)同理,LockDlstNode的constructor中也是。- Now we are testing DList.
- Here is a list after insertBack 6, 9, 12: [ 6 9 12 ]
- Here is the same list after insertBack(15) and insertFront(3): [ 3 6 9 12 15 ]
- front() should be 3. It is: 3
- front's next should be 6. It is: 6
- front's next's prev should be 3. It is: 3
- After remove the front, the front() should be 6. It is: 6
- After insertBefore() and insertAfter(), The first 3 nodes should be 5,6,8. The list is: [ 5 6 8 9 12 15 ]
- Here is a list after construction: [ ]
- isEmpty() should be true. It is: true
- length() should be 0. It is: 0
- Here is a list after insertFront(3) to an empty list: [ 3 ]
- Here is a list after insertBack(5) on an empty list: [ 5 ]
- Here is a list after insertFront 3, 2, 1: [ 1 2 3 ]
- isEmpty() should be false. It is: false
- length() should be 3. It is: 3
- Here is the same list after insertBack(4): [ 1 2 3 4 ]
- Here is a list after insertBack 6, 7: [ 6 7 ]
- isEmpty() should be false. It is: false
- length() should be 2. It is: 2
- Here is the same list after insertFront(5): [ 5 6 7 ]
- Now we are testing LockDList.
- Here is a list after insertBack 6, 9, 12: [ 6 9 12 ]
- Here is the same list after insertBack(15) and insertFront(3): [ 3 6 9 12 15 ]
- front() should be 3. It is: 3
- front's next should be 6. It is: 6
- front's next's prev should be 3. It is: 3
- We lockNode front()= 3
- After remove the locked front, the front() should still be 3. It is: 3
- After remove the back, the back() should be 12. It is: 12
- After insertBefore(3) and insertAfter(3), The first 3 nodes should be 5,3,8. The list is: [ 5 3 8 6 9 12 ]
- Here is a list after construction: [ ]
- isEmpty() should be true. It is: true
- length() should be 0. It is: 0
- Here is a list after insertFront(3) to an empty list: [ 3 ]
- Here is a list after insertBack(5) on an empty list: [ 5 ]
- Here is a list after insertFront 3, 2, 1: [ 1 2 3 ]
- isEmpty() should be false. It is: false
- length() should be 3. It is: 3
- Here is the same list after insertBack(4): [ 1 2 3 4 ]
- Here is a list after insertBack 6, 7: [ 6 7 ]
- isEmpty() should be false. It is: false
- length() should be 2. It is: 2
- Here is the same list after insertFront(5): [ 5 6 7 ]
- [code]Now we are testing LockDList.
- Here is a list after insertBack 6, 9, 12: [ 6 9 12 ]
- Here is the same list after insertBack(15) and insertFront(3): [ 3 6 9 12 15 ]
- front() should be 3. It is: 3
- front's next should be 6. It is: 6
- front's next's prev should be 3. It is: 3
- We lockNode front()= 3
- After remove the locked front, the front() should still be 3. It is: 3
- After remove the back, the back() should be 12. It is: 12
- After insertBefore(3) and insertAfter(3), The first 3 nodes should be 5,3,8. The list is: [ 5 3 8 6 9 12 ]
- Here is a list after construction: [ ]
- isEmpty() should be true. It is: true
- length() should be 0. It is: 0
- Here is a list after insertFront(3) to an empty list: [ 3 ]
- Here is a list after insertBack(5) on an empty list: [ 5 ]
- Here is a list after insertFront 3, 2, 1: [ 1 2 3 ]
- isEmpty() should be false. It is: false
- length() should be 3. It is: 3
- Here is the same list after insertBack(4): [ 1 2 3 4 ]
- Here is a list after insertBack 6, 7: [ 6 7 ]
- isEmpty() should be false. It is: false
- length() should be 2. It is: 2
- Here is the same list after insertFront(5): [ 5 6 7 ]
复制代码 [/code]
个人理解 LockDListNode中是可以连着DListNode的 不知道对不对 |
|