* 打印跳表结构
*
* @return
*/
private void showNodes() {
List<V> values = Lists.newArrayList();
Node headFirst = bottomHead.next;
while (headFirst != null) {
values.add(headFirst.value);
headFirst = headFirst.next;
}
Node head = top, p;
while ((p = head) != null) {
int lineSepratorCount = 0;
List<Integer> downPointer = Lists.newArrayList();
while (p != null) {
if (p.key == HEAD_KEY) {
System.out.print("HEAD");
} else {
int valueIndex = values.indexOf(p.value);
int sepratorCount = head == bottomHead ? 1 : valueIndex + 1 - lineSepratorCount;
downPointer.add(valueIndex);
lineSepratorCount = lineSepratorCount + sepratorCount;
for (int i = 0; i < sepratorCount; i++) {
if (sepratorCount > 1 && i < sepratorCount - 1) {
printChar(1, '-');
}
printChar(4, '-');
System.out.print(">");
}
System.out.print(p.value);
}
p = p.next;
}
head = head.down;
if (head != null) {
System.out.println();
System.out.print(" | ");
for (int i = 0; i < lineSepratorCount; i++) {
printChar(5, ' ');
if (downPointer.contains(i)) {
System.out.print("|");
} else {
printChar(1, ' ');
}
}
System.out.println();
}
}
System.out.println();
}
* 输出空格
*/
private void printChar(int num, char cahr) {
for (int i = 0; i < num; i++) {
System.out.print(cahr);
}
}