Merge pull request #40 from Liam0205/bugfix_java_09_queue

[JAVA][09_queue] bugfix and typofix.
This commit is contained in:
wangzheng0822 2018-10-12 17:47:00 +08:00 committed by GitHub
commit a7d5144a58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -36,7 +36,8 @@ public class CircularQueue {
} }
public void printAll() { public void printAll() {
for (int i = head; i < tail; ++i) { if (0 == n) return;
for (int i = head; i % n != tail; ++i) {
System.out.print(items[i] + " "); System.out.print(items[i] + " ");
} }
System.out.println(); System.out.println();

View File

@ -3,7 +3,7 @@ package queue;
/** /**
* Created by wangzheng on 2018/10/9. * Created by wangzheng on 2018/10/9.
*/ */
public class DynimacArrayQueue { public class DynamicArrayQueue {
// 数组items数组大小n // 数组items数组大小n
private String[] items; private String[] items;
private int n = 0; private int n = 0;
@ -12,7 +12,7 @@ public class DynimacArrayQueue {
private int tail = 0; private int tail = 0;
// 申请一个大小为capacity的数组 // 申请一个大小为capacity的数组
public DynimacArrayQueue(int capacity) { public DynamicArrayQueue(int capacity) {
items = new String[capacity]; items = new String[capacity];
n = capacity; n = capacity;
} }