Digester Digester.peek(int n) 메서드의 고찰

황제낙엽 2008.08.26 13:44 조회 수 : 13 추천:116

sitelink1  
sitelink2  
sitelink3  
extra_vars4  
extra_vars5  
extra_vars6  
1. API 내용
peek
public java.lang.Object peek(int n)Return the n'th object down the stack, where 0 is the top element and [getCount()-1] is the bottom element. If the specified index is out of range, return null.
peek 메서드는 스택에서 down 방향으로 n번째 객체를 리턴한다. n 이 0 인 경우는 최상위 객체이고 n 이 [getCount()-1] 인 경우는 최하위 객체를 의미한다. 만약 범위를 넘어서는 경우는 null 을 리턴한다.

Parameters:
n - Index of the desired element, where 0 is the top of the stack, 1 is the next element down, and so on.
0 은 최상위 1은 그 다음 객체

2. 스택에 객체가 Push 되는 순서
  최초의 객체가 스택에 push 되면 0번째에 쌓이게 된다. ([0, firstObj])
  다음 객체가 스택에 push 되면 다시 0번째에 쌓이게 된다. 0번째였던 최초의 객체는 1번째가 된다. ([0, secondObj], [1, firstObj])
  다음 객체가 스택에 push 되면 다시 0번째에 쌓이게 된다. 0번째였던 객체는 1번째가 되고, 1번째였던 객체는 2번째가 된다. ([0, thirdObj], [1, secondObj], [2, firstObj])