Skip to content

Commit 88a2981

Browse files
committed
Queue源码更新
1 parent 1934148 commit 88a2981

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/com/zejian/structures/Queue/PriorityQueue.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public PriorityQueue(boolean asc){
3131
this.asc=asc;//默认升序
3232
}
3333

34+
35+
public void setMaxSize(int maxSize) {
36+
this.maxSize = maxSize;
37+
}
38+
3439
@Override
3540
public int size() {
3641
return list.size();
@@ -65,7 +70,7 @@ public boolean offer(T data) {
6570
if (data==null)
6671
throw new NullPointerException("The data can\'t be null");
6772
if (list.size()>=maxSize)
68-
throw new IllegalArgumentException("The capacity of LinkedQueue has reached its maxSize:128");
73+
throw new IllegalArgumentException("The capacity of PriorityQueue has reached its maxSize:128");
6974

7075
return add(data);
7176
}
@@ -89,7 +94,7 @@ public T peek() {
8994
@Override
9095
public T element() {
9196
if(isEmpty()){
92-
throw new NoSuchElementException("The LinkedQueue is empty");
97+
throw new NoSuchElementException("The PriorityQueue is empty");
9398
}
9499
return peek();
95100
}

0 commit comments

Comments
 (0)