1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.mybatis.scripting.velocity;
17
18 import java.io.Serializable;
19
20
21
22
23 public final class FastLinkedList<E extends Serializable> implements Serializable {
24
25 private static final long serialVersionUID = 1L;
26
27 private Node first;
28
29 private Node last;
30
31 public FastLinkedList() {
32 this.last = this.first;
33 }
34
35 public boolean isEmpty() {
36 return this.first == null;
37 }
38
39 public Node start() {
40 return this.first;
41 }
42
43 public void add(E e) {
44 final Node n = new Node(e);
45 if (this.first == null) {
46 this.first = n;
47 this.last = this.first;
48 } else {
49 this.last.next = n;
50 this.last = n;
51 }
52 }
53
54 public final class Node {
55
56 final E data;
57 Node next;
58
59 public Node(E newData) {
60 this.data = newData;
61 }
62
63 public boolean hasNext() {
64 return this.next != null;
65 }
66
67 }
68
69 }