소스 검색

restructured code, finalizing

master
David 4 년 전
부모
커밋
d8c6c0e53b
1개의 변경된 파일25개의 추가작업 그리고 23개의 파일을 삭제
  1. +25
    -23
      src/ChainQueue.java

+ 25
- 23
src/ChainQueue.java 파일 보기

@@ -94,6 +94,31 @@ public class ChainQueue<E> implements Queue<E> {
return false;
}

@Override
public E poll() { // poll next from queue and remove the first
E temp = null;
if (!this.isEmpty()) {
temp = getFirst().getData();
setFirst(getFirst().getNext());
}
return temp;
}

@Override
public E element() {
return null;
}

@Override
public E peek() { // only "see" into the queue and do not remove anything
if (!this.isEmpty()) {
return getFirst().getData();
}
return null;
}

/*** the following is not implemented because it's not needed here ***/

@Override
public Iterator<E> iterator() {
return null;
@@ -148,27 +173,4 @@ public class ChainQueue<E> implements Queue<E> {
public E remove() {
return null;
}

@Override
public E poll() { // poll next from queue and remove the first
E temp = null;
if (!this.isEmpty()) {
temp = getFirst().getData();
setFirst(getFirst().getNext());
}
return temp;
}

@Override
public E element() {
return null;
}

@Override
public E peek() { // only "see" into the queue and do not remove anything
if (!this.isEmpty()) {
return getFirst().getData();
}
return null;
}
}

불러오는 중...
취소
저장