File tree Expand file tree Collapse file tree
src/com/zejian/structures/Queue Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments