Contents

61B-5: DLLists, Arrays

Contents

Doubly Linked Lists

/61b-5/image.png

/61b-5/image-1.png

/61b-5/image-2.png 注意只有sentinel时要讨论一些特殊情况,特别是环状链表。

Generic Lists 泛型列表

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
public class SLList<BleepBlorp> {
   private IntNode sentinel;
   private int size;


   public class IntNode {
      public BleepBlorp item;
      public IntNode next;
      ...
   }
   ...
}

SLList<Integer> s1 = new SLList<>(5);
s1.insertFront(10);
 
SLList<String> s2 = new SLList<>("hi");
s2.insertFront("apple");

/61b-5/image-3.png

Arrays, AList

/61b-5/image-4.png 介绍了System.arraycopy()用来resize /61b-5/image-5.png

2D Arrays

/61b-5/image-6.png

Arrays vs. Classes

array的runtime动态索引(和cpp不一样) /61b-5/image-7.png class runtime /61b-5/image-8.png /61b-5/image-9.png