
SplDoublyLinkedList 클래스의 top 메서드는 가장 첫 번째 요소를 반환합니다.
top 메서드는 노드가 비어 있는 경우 NULL을 반환합니다.
SplDoublyLinkedList 클래스의 노드가 비어 있는 경우, top 메서드는 노드가 비어 있음을 의미하므로 NULL을 반환합니다.
예를 들어, SplDoublyLinkedList 클래스의 노드가 비어 있는 경우 다음과 같이 top 메서드를 호출할 수 있습니다.
#hostingforum.kr
php
$splDoublyLinkedList = new SplDoublyLinkedList();
echo $splDoublyLinkedList->top(); // NULL
top 메서드는 노드가 비어 있지 않은 경우 노드의 값을 반환합니다.
예를 들어, SplDoublyLinkedList 클래스의 노드가 비어 있지 않은 경우 다음과 같이 top 메서드를 호출할 수 있습니다.
#hostingforum.kr
php
$splDoublyLinkedList = new SplDoublyLinkedList();
$splDoublyLinkedList->push('값1');
$splDoublyLinkedList->push('값2');
echo $splDoublyLinkedList->top(); // '값1'
2025-03-04 17:02